Subversion (SVN)

Branches

Creation of a branch

From a working copy you can directly copy the trunk to the branch and switch on it:

svn copy ^/Maven/gazelle-tm/trunk ^/Maven/gazelle-tm/branches/my-branch -m "Create my branch"
svn switch ^/Maven/gazelle-tm/branches/my-branch

If you had previous modification on your working copy they will be keeped locally during the switch. Your are now ready to commit on the branch.

svn commit -m "new feature"

It is important to give a clear log message when you create the branch to easily find its revision number.

Know your branching revision number

Inria's forge does not support the auto detection of branching points, so you have to know the revision number of the branch creation for all merge commands. To do so, display the history:

svn log

You can limit the number of the history to avoid getting all the history of the project

svn log -l 20

And you can also get all the history of your branch directly with

svn log --stop-on-copy

The last line will be the branch creation revision.

Keep your branch synchronized with the trunk

All along your work on the branch, to avoid a final painful merge, it is well advise to regularly getting modification from the trunk into your branch.

First commit your work to get a clean working copy. Then merge the trunk into your local working copy of the branch:

svn merge -r 57456:HEAD ^/Maven/gazelle-tm/trunk

57456 is the branch creation revision number.

Resolve the confilcts if so, verify compilation and test your project before committing on the branch.

Merging

When your work is finally done on the branch, commited and ready to be share, you will need to reintegrate all modifications back in the trunk.

First, perform a last trunk synchronization (see above paragraph) and commit on the branch.

Then get a clean working copy of the trunk, by performing a checkout in another directory

svn checkout https://.../Maven/gazelle-tm/trunk tm-trunk

or performing an svn switch

svn switch ^/Maven/gazelle-tm/trunk

Make sure your working copy is up to date

svn update

And merge your branch into the local copy of the trunk

svn merge -r 57456:HEAD ^/Maven/gazelle-tm/my-branch

Resolve the confilcts if so, verify compilation and test your project before committing on the trunk.

svn commit -m "merge new feature"

Once the merge is finished and you have verified it is completely integrated, you can delete the old branch

svn delete ^/Maven/gazelle-tm/my-branch -m "Delete merged branch"

Troubleshouting

Error E160013: '/svn/xxx/!svn/xxx' path not found*

Perform a checkout in a new directory to get clean working copies. If you're merging two branches, do it for both branches.

Go fetch a coffee

Congratulation you've masterized svn branching !