如何在SVN中分支单个文件? [英] How do I branch an individual file in SVN?

查看:118
本文介绍了如何在SVN中分支单个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

分支的颠覆概念似乎集中在创建要在其上进行开发的整个存储库的[un] stable分支上。是否有创建单个文件分支的机制?

The subversion concept of branching appears to be focused on creating an [un]stable fork of the entire repository on which to do development. Is there a mechanism for creating branches of individual files?

对于一个用例,请考虑具有多个平台特定源的通用头文件(* .h)( * .c)实现。这种分支是永久分支。所有这些分支都会看到偶尔的跨分支合并的持续发展。这与通常具有有限寿命的不稳定的开发/稳定发行分支形成鲜明对比。

For a use case, think of a common header (*.h) file that has multiple platform-specific source (*.c) implementations. This type of branch is a permanent one. All of these branches would see ongoing development with occasional cross-branch merging. This is in sharp contrast to unstable development/stable release branches which generally have a finite lifespan.

不想希望分支整个存储库(是否便宜),因为这样会造成不必要的维护费用,无法在主干和所有分支之间不断合并。目前,我使用的是ClearCase,它具有不同的分支概念,因此操作起来很容易。我曾被要求考虑过渡到SVN,但这种范例差异很重要。我更关心的是能够轻松地为单个文件创建替代版本,而不是像剪切稳定的发布分支之类的事情。

I do not want to branch the entire repository (cheap or not) as it would create an unreasonable amount of maintenance to continuously merge between the trunk and all the branches. At present I'm using ClearCase, which has a different concept of branching that makes this easy. I've been asked to consider transitioning to SVN but this paradigm difference is important. I'm much more concerned about being able to easily create alternate versions for individual files than about things like cutting a stable release branch.

推荐答案

<遗憾的是,我认为真正的答案是ClearCase处理这种情况要比Subversion好得多。使用Subversion时,您必须分支一切,但是ClearCase允许一种惰性分支的想法,这意味着仅分支了特定的一组文件,其余文件仍然遵循主干(或分支中的任何一个)

Sadly, I think the real answer here is that ClearCase handles this situation a lot better than Subversion. With subversion, you have to branch everything, but ClearCase allows a kind of "lazy branch" idea that means only a certain group of files are branched, the rest of them still follow the trunk (or whichever branch you specify).

此处提供的其他解决方案并不能真正按照您的预期工作,它们只是将文件复制到其他路径。现在您必须做一些奇怪的事情才能实际使用该文件。

The other solutions provided here don't really work as you intend, they are just copying the file to a different path. Now you have to do odd things to actually use that file.

Erm,对不起。那不是一个很好的答案。但是Subversion并没有很好的解决方案。它的模型是分支和合并。

Erm, sorry. That wasn't really a very good answer. But there isn't a good solution to this with Subversion. Its model is branch and merge.

编辑:好的,所以请扩展一下crashmstr所说的内容。您可以这样做:

OK, so expanding on what crashmstr said. You could do this:

svn cp $REP/trunk/file.h $REP/branched_files/file.h
svn co $REP/trunk
svn switch $REP/branched_files/file.h file.h

但是,哇!,这容易出错。每当您执行svn st时,您都会看到以下内容:

But wow!, is that prone to errors. Whenever you do a svn st you will see this:

svn st
    S  file.h

有点吵。而且,当您想要在大型源存储库中分支一些文件或模块时,它将变得非常混乱。

A bit noisy that. And when you want to branch a few files or modules within a large source repository it will start to get very messy.

实际上,这里可能有一个不错的项目,用于模拟带有svn属性的ClearCase分支文件,然后进行切换,围绕沼泽标准svn客户端编写包装器以处理所有问题烂摊子。

Actually, there's probably a decent project in here for simulating something like ClearCase's branched files with svn properties and switching, writing a wrapper around the bog standard svn client to deal with all the mess.

这篇关于如何在SVN中分支单个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆