When you have multiple branches of the same project in SVN, you probably want to keep these branches in sync, at least to a certain extend.
One example of this would be feature branches, i.e. a branch were a bigger feature is developed. You usually want to keep that feature branch in sync with trunk by merging all commits from trunk into that feature branch. Once the feature branch is ready to be merged back to trunk, you want to do just that with as little work as possible.
Another example are the KDEPIM enterprise branches. All changes from the enterprise branches are merged to trunk, but only some changes from trunk are merged back to the enterprise branches.
In both situation, svnmerge.py will help you by keeping track of the merges and assisting you in the process of merging.
It has the following useful features:
See also the svnmerge wiki page.
Note that svnmerge.py should not be confused with svn merge. The later is a normal SVN command, which is used, among others, by svnmerge.py. When refering to svnmerge on this page, I always mean svnmerge.py. Also, when referring to svn merge, I mean the built-in subversion command.
svnmerge somehow needs to keep track of which commits are merged and which are not. For this, it uses the SVN properties of the top-level project directory. The properties contain a list with revisions, and that list is updated each time you merge something with svnmerge.
You can view that list with
svn propedit svnmerge-blocked .
svn propedit svnmerge-integrated .
Never change those properties manually!
Download svnmerge.py from the svnmerge home page. The trunk version should be fine.
Then, put it into /usr/local/bin and make sure it has executable permissions by issuing
chmod +x /usr/local/bin/svnmerge.py
You need to have Python installed, probably with some add-on modules.
After creating a new work branch, you need to tell svnmerge about this, so it can set up the initial revision list in the properties. You can skip this section if somebody else already did set up merge tracking for your branches.
To get help in doing so, type
svnmerge.py help init
After you executed the correct svnmerge.py init command, make sure you commit your changes. Only the SVN properties should have changed, type svn status to confirm this.
Afterwards, commit it with
svn ci -F svnmerge-commit-message
First of all, you probably want a list of revisions that are not yet merged. This list can be retrieved with svnmerge avail. The avail command supports many options, to get help, type:
svnmerge.py help avail
Sometimes you already know the revision numbers of the commits you want to merge, in this case you don't need to run svnmerge avail. But be careful, it is easy to forget commits when you don't run this command.
A good practice is get the list of revisions to be merged together with their log message, which often comes in handy. Run the following to store that list in a file:
svnmerge.py avail --log -b > avail.txt &
Note that the command can take a long time, so we run it in the background with &. Also, svnmerge issues a lot of SVN command in the background, so be sure your passphrase is cached when using svn+ssh, by using ssh-add and ssh-agent.
When you have got multiple branches to merge from, you need to specify the target branch with the -S option. This is the case in the enterprise4 branch, which can merge from the enterprise35 branch or the KDE 4.2.x branch.
svnmerge.py avail --log -b -S enterprise > avail.txt &
getting available/unmerged revisions svnmerge --avail --log -b -S bla > avail trick (takes a lot of time!) open in text edit
block, merge or merge -M revisions from list merging more than one revision - when and when not to do
edit commit message: SVN_SILENT, small explaination sometimes svn ci -F svnmerge-commit-message
conflicts on . -> svn resolved + use mergediff to confirm (!) problems with korganizer/views problems with kcal in e3->e4