views:

509

answers:

3

Our company recently began creating CVS branches to mark each release. Formerly we had been using tags, and if we fixed something during the testing period that needed to go out with the release, we simply moved the tag forward. This works well until two changes are made to the same file: one that should be released and the other that shouldn't. Now we need to apply the same change to both the head and the release branch.

I'm using Eclipse's CVS plugin to interact with CVS. When I look at a file's history, I see a i20090529Release tag in the Tags section (in this case on revision 1.30 of the file), and when I "Show Tag Viewer" within the History view, the icon indicates that this is a Branch tag, as opposed to a Version tag. When I look at revisions that have been committed since the Branch occurs I see that the next revision made to the head becomes version 1.31, and the next revision made to the branch becomes version 1.30.2.1. My question is, why does the i20090529Release tag stay with version 1.30 of the file, which is not the most recent revision on the i20090529 branch? Is this really even a bona-fide "tag," or is it more of a conceptual idea that the branch began branching off at this point? I notice I can't apply this tag to any other revision of the file. Why does it appear in the Tags column at all?

Thanks in advance for any clarification you can provide.

+2  A: 

It's the idea that the branch began branching off at that point.

A branch is a set of versions that branch off the main trunk at some point, and maintain their own independent development (which may of course be closely coordinated). It isn't a set of changes that will be automatically applied to later versions.

It's not a tag in the usual sense: if you check out according to a tag, you'll get a snapshot of the source tree at the time the tag was made, while the results of checking out according to a branch will vary over time, as changes are made to the branch. It is similar to a tag, and does work in much the same way; CVS uses the old RCS file format, and uses RCS tags both for branches and CVS tags.

There's several good references for CVS. Read up on tags and branches.

David Thornley
I'll mark this the correct response because you answered my main question: It's the idea that the branch began branching off at that point. I have read several references on CVS, particularly the parts about tags and branches. What I couldn't find information on was why this tag appeared on the original revision, even after I had committed new changes to the branch.
StriplingWarrior
CVS started as a set of scripts over the older RCS, and kept the RCS file format. RCS doesn't (or at least didn't) have the same concept of a branch, so RCS tags were used both as regular tags and as branch markers. The RCS tag 1.12.0.2 is the start of the 1.12.2 branch, and tags like 1.12.2.3 are versions along that branch. There's lots of little oddities like that, which is one reason lots of people have moved to Subversion.
David Thornley
A: 

Normal tags are set to a specific file revision and will never move. If taged 1.30 it will say 1.30 until it is manually changed.

Branch tags is taged to a branch revision, if branching a file with revision 1.30 the first branch will be 1.30.2 (or next free even number). First file commited to this branch will get 1.30.2.1, next commit 1.30.2.2 etc. (see details in Oliver Giesen's comment)

Checking out this file from this (1.30.2) branch will always fetch the latest file revision in that branch (1.30.2.x).

One can also do branches in branches.. then revisions would endup like 1.30.2.2.2 (first branch of the 1.30.2.2 file revision) Revisions in cvs are <branchrevision>.<filerevison>[.<branchrevision>.<filerevison>][.<branchrevision>.<filerevison>]... and so on. First branchrevision is always 1 (afaik).

edit: fixed the even number error pointed out by Oliver Giesen

Joakim Elofsson
Your description of how revision numbers are formed is not quite correct. The only way to get an odd branch number is by using the Import command. If you create a branch yourself then the branch number will always be an even number that will be equal to the highest branch number existing on a file in the same directory.
Oliver Giesen
...or 2 if this is the first branch created in that directory.
Oliver Giesen
+1  A: 

It probably doesn't move because you're not using it -- based on your description, you're still committing all revisions to the HEAD.

To use a branch, you first have to tag all the files with the branch tag (this example from the CVS manual):

cvs tag -b rel-1-0-patches

At the same time, I strongly recommend a snapshot tag that you never move or update, so that you can always rebuild the code at that point in time:

cvs tag rel-1-0

To use the branch, you have to check out the branch into your working directory:

cvs co -r rel-1-0-patches example

Then, when you commit changes against the branch, you'll see the branch tag applied to the change. What you won't see is any change on HEAD. To do that, you'll need to merge the branch changes into HEAD, and that's a little too complex to put in an SO answer, so go to the docs: http://ximbiot.com/cvs/manual/cvs-1.11.23/cvs_5.html#SEC54

kdgregory
This doesn't quite jive with what I'm seeing. I should mention again, I am using Eclipse's CVS manager. I use "Switch to another branch or version" to check out the branch, and when I commit I see that the revision number has changed format similar to what Joakim shows. However, in Eclipse, I still see a branch "tag" attached to the original revision.
StriplingWarrior
StriplingWarrior: don't be so attached to the graphical representation of the branch. the fact that the tag is attached to the base revision does not change the fact that if you actually check out using the branch tag you will get the tip revision of that branch rather than the revision that the graph associates directly with the branch tag.
Oliver Giesen