且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在将文件签入和签入CVS时出现问题(Sticky标签)

更新时间:2023-10-04 22:03:58

解决问题的自然方法是分支。但是,如果这种情况很少出现
,并且决心避免分支,则
可以将所有版本放在HEAD上并相应地设置标签。

The natural solution to your problem is branching. However if you have this scenario infrequently and are determined to avoid branches, you can put all your versions on the HEAD and set the tags accordingly.

让我们说您具有以下版本的DatabaseFacade.java:

Lets say you have the following version of DatabaseFacade.java:

1.1: original version, which has the bug
1.2: version with new feature, which you do not want to release yet

您签出了1.1和修复了您的错误,但是-可惜-您无法提交
,因为您处在粘性标签上。要解决此问题,请执行以下操作(我没有
测试代码,但应该可以说明这一点):

You checked out 1.1 and made your bug fix, but - alas - you can't commit it because you are on a sticky tag. To solve it, do the following (I didn't test the code, but it should illustrate the idea):

# backup file with fixes
mv DatabaseFacade.java DatabaseFacade.java-fixed

# revert to HEAD: remove the sticky-ness
cvs update -A DatabaseFacade.java

# get revision 1.1 (non sticky)
cvs update -p -r1.1 DatabaseFacade.java > DatabaseFacade.java

# commit it
cvs ci -m "reverted to revision 1.1." DatabaseFacade.java

# commit your file with fixes
mv DatabaseFacade.java-fixed DatabaseFacade.java
cvs ci -m "fixed BUG434" DatabaseFacade.java

# restore the latest development version to HEAD
cvs update -p -r1.2 DatabaseFacade.java > DatabaseFacade.java
cvs ci -m "reverted to revision 1.2." DatabaseFacade.java

# also fix the bug in the latest development version
cvs ci -m "fixed BUG434" DatabaseFacade.java

因此,现在DatabaseFacade.java将具有以下版本:

So now DatabaseFacade.java will have the following versions:

1.1: original version, which has the bug
1.2: version with new feature, which you do not want to release yet
1.3: same as 1.1
1.4: your bugfix to 1.1
1.5: same as 1.2
1.6: version with new feature and bugfix

现在您可以新版本的标签修订版1.4:

Now you can tag revision 1.4 for the new release:

cvs tag -r 1.4 LIVE-REL-2.5 DatabaseFacade.java

采用这种方法时,应确保没有
的其他开发人员运行 cvs更新,而您正在玩
历史记录,即1.3或1.4是HEAD上的最新记录。

When you take this approach, you should make sure that none of your fellow developers runs a cvs update while you are "playing with the history", i.e. while either 1.3 or 1.4 is the latest on the HEAD.

切换到Subversion没有任何好处。它不会帮助您解决这类问题。如果您正在认真考虑使用
不同的版本管理系统,则应查看
Mercurial或任何其他分布式版本管理系统。
Mercurial中,合并无痛且容易,因此分支是
常见且无害的。

There is no benefit in switching to Subversion. It will not help you with these kind of problems. If you are seriously considering a different version management system, you should take a look at Mercurial or any other Distributed Versionmanagement System. In Mercurial, merging is painless and easy, and so branching is commonplace and harmless.

顺便说一句:由于您正在用
Bug-identifier标记新文件,标签(例如 BUG434),您可能还希望使用相同的标签将与该错误修正相关的任何现有文件标记为

By the way: Since you are tagging your new files with bug-identifier-tags (e.g. "BUG434"), you might also want to tag any existing file related to that bugfix with the same tag.