working with branches
Submitted by mark on Thu, 2007-07-05 07:44.
| CVS vs. Subversion | Comment | ||
|---|---|---|---|
| Checkout | CVS |
cvs -d directory co repository cd directory |
Checkout was already mentioned on the initialize repository page, but to simplify the examples below, the subversion command show here checks out the the full repository, so that copying to the tag and branch directories becomes easier. |
| Subversion |
svn repository directory cd directory/trunk |
||
| Create Branch | CVS |
cvs tag MYBRANCH_0 cvs tag -b MYBRANCH |
The examples shown here do a bit more than just creating a branch because from time to time you may want to merge parts of a branch into another branch and to do so, you need to specify a start- and an endpoint which span the changes you want to merge into another tree. Because of this it is recommended for CVS to create a tag when a branch is created (MYBRANCH_0 in this example) and a tag (MYBRANCH_1 in the example below) when you do the merge so that successive merges can be done from MYBRANCH_0 to MYBRANCH_1, MYBRANCH_1 to MYBRANCH_2 and so on. The same can be done with subversion but you may also use Subversion's revision numbers instead of tags and provide the required information in the commit messages instead. (The names “MYBRANCH” and “MYBRANCH_...” are just an example.) |
| Subversion |
cd .. svn copy trunk tags/MYBRANCH_0 svn copy trunk branches/MYBRANCH svn commit or svn copy trunk branches/MYBRANCH |
||
| List available tags and branches | CVS | cvs status -v some file | In CVS you guess the oldest file in your repository and run 'cvs status' on it. In SVN you list the contents of the tags or branches directory. |
| Subversion |
svn ls repository/tags/
or svn ls repository/branches/ |
||
| Switch to Branch | CVS | cvs update -r MYBRANCH |
Switch to the branch. With CVS you can convert your current working directory into another branch and “cvs status” can show you in which branch certain file resides. (Yes, as CVS is file based, files in a single directory may belong to different branches but this is unusual.) With Subversion you just change directories when you checked out all branches or you run “svn checkout” for the branch. |
| Subversion |
cd branches/MYBRANCH
or svn checkout repository/branches/MYBRANCH |
||
| Switch to HEAD/trunk | CVS | cvs update -A | Switching back into the HEAD/trunk branch. |
| Subversion |
cd ../../trunk
or svn checkout repository/trunk |
||
| Merging from another Branch | CVS |
cvs tag -r MYBRANCH MYBRANCH_1 cvs update -kk -j MYBRANCH_0 -j MYBRANCH_1 cvs commit -m "merged MYBRANCH_0 to MYBRANCH_1" |
From time to time one my merge changes from one branch into another. The row Create Branch above also explained why CVS requires the role of tags during a merge and the alternatives in subversion. The “-kk” option given to CVS tells CVS to ignore its keyword substitution, otherwise the merge may create a bunch of additional useless conflicts. The merge's commit message should always tell what has been merged so you can see how to avoid overlaps in subsequential merges. The second Subversion command shown on the left uses revision numbers instead of tags. |
| Subversion |
svn copy ../branches/MYBRANCH ../tags/MYBRANCH_1 svn merge ../tags/MYBRANCH_0 ../tags/MYBRANCH_1 svn commit -m "merged MYBRANCH_0 to MYBRANCH_1" or svn merge -rfrom:to ../branches/MYBRANCH |

- elektronische medien, find their site at