Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

SVN – Branching & Merging

František Kačmarik
Branches

● What's a Branch
● Using Branches
Release Branches
● Developers commit all new work to the trunk
● The trunk is copied to a “release” branch
● Teams continue to work parallel
● Testing release branch, implementing new features
in trunk
● Bugs are ported back and forth
● After time, the branch is frozen, tagged and
released
● The branch is maintained over time
Feature Branches

● Temporary branch created to work on a


complex change without interfering with the
stability of trunk
● approach depends on the project
Vendor Branch

● usually third-party's libraries


● project depends on specific library version
● modifications to the library
Creating a Branch

● svn copy <from> <to>


● “remote” svn copy
vs. svn copy on local
working copy
● “cheap copies”
● Not working between
different repositories
Keeping a Branch in Sync

● sync frequently
● svn status
● working copy of the branch must be “clean” when
merging
● snv merge sourceURL1[@N] sourceURL2[@M]
[WCPATH]
● svn merge ^/calc/trunk
● svn commit
SVN mergeinfo

● svn:mergeinfo -> property of SVN, tracks


changesets, changes that have been merged to
which branches
● svn propget svn:mergeinfo
● svn mergeinfo ^/calc/trunk
● svn mergeinfo ^/calc/trunk --show-revs eligible
● svn merge ^/calc/trunk --dry-run
Reintegrating a Branch

● Branch must be synchronized ( final version,


svn merge, svn commit)
● Change to the place where branch should be
merged(trunk) - svn switch or new svn checkout
● svn merge --reintegrate
^/calc/branches/my_branch
Reintegrating a Branch

● Branch is merged to trunk, should remove it


● svn delete ^/calc/branches/my_branch
● still can be found in history (svn log) and be
resurrected
● After --reintegrate is used, branch is no longer
usable for further work. It should be deleted and
re-created from the trunk.
Merge Options

● Cherrypicking
● want to apply only one specific change
● this changes will be skipped in following merge
● svn merge -c 355 ^/calc/trunk
Merge Options
● --record-only option in svn merge
● blocking changes
● change has already been made
● omit some changes
$ cd my-calc-branch
$ svn update
Updated to revision 393.
$ svn merge --record-only -c 391 ^/calc/trunk
--- Recording mergeinfo for merge of r391 into '.':
U .
$ svn commit -m "Block revision 391 from being merged into my-
calc-branch."
Sending .
Committed revision 394.
SVN blame, SVN log

● who changed what, when


● --use-merge-history (-g) – show changes that
were made by merging, originally in the trunk
Resurrecting a file
● svn log -v in directory were file was stored
● svn merge(reverse merging) or svn copy
$ svn copy ^/calc/trunk/real.c@807 \ $ svn merge -c -303 ^/calc/trunk
./real.c --- Reverse-merging r303 into
$ svn status 'integer.c':
A + real.c U integer.c
$ svn commit -m "Resurrected real.c $ svn status
from revision 807, /calc/trunk/real.c." M .
Adding real.c M integer.c
Transmitting file data . $ svn diff
Committed revision 1390. …#
verify that the change is removed

$ svn commit -m "Undoing change
committed in r303."
Sending integer.c
Transmitting file data .
Committed revision 350.
Sources

● http://svnbook.red-bean.com/nightly/en/svn-
book.pdf

You might also like