Tuesday, September 27, 2005

CVS Tricks

Objective: You want to merge from a branch Branch_Q into branch Branch_P

cvs -q update -j Branch_P -j Branch_Q

Objective: Create a branch Branch_P at the location where a branch Branch_M has been tagged.

cvs rtag -r Branch_M Branch_P directory

Objective: TAGGING, BRANCHING and MERGING.
Let's say you want to try something out but still be able to easily come back to the current version of the code if your experiment doesn't work. However, you want to keep the experiment around, or you want to be able to edit the main branch at the same time.

1. Commit current code.

> cvs commit

2. Tag the current code

> cvs tag before_new_image_code

3. Create a new branch

> cvs tag -b new_image_code

4. Move to new branch

> cvs update -r new_image_code

Now any changes which are made will be commited to the new branch. To switch back and forth between the branch and the trunk use the following commands.

* Move back to trunk/main version of code.

cvs update -A

* Move back to specified branch

cvs update -r new_image_code

Make sure to do a commit before switching to another branch. Update will overwrite your current working files with the latest version from the branch you specify, so all changes will be lost unless they have been committed.

Let's say your experiment worked and you want to merge the branches.

1. Move to main branch

> cvs update -A

2. See what the differences are between the branch we want to merge with and the main branch.

> cvs diff -r new_image_code

3. Merge the branch into the main branch.

> cvs update -j new_image_code

You will be told about any conflicts during the merge, and you won't be allowed to commit the files until those conflicts are dealt with.

REFERENCE
CVS Notes

No comments: