I'm looking to script a very common yet neglected till the last minute action, SVN merge.
Ideally it should run for the current user and for lets say the last 2 days' commits under your name. So in a scenario where you've worked on a branch, running this script will merge your changes to trunk and launch the commit dialogue, so you can verify before committing.
Our branching strategy allows for a trunk-branch1-branch1.1, so you'll start at the end and merge your way to trunk.
Given we're a large number of developers I'm not looking for the silver bullet, but rather something that can facilitate the process.
I had a look at the svn command (mergeinfo) but there not sure how to apply the 'by user' filter.
Much appreciated
I don't really understand why you're trying to merge by user. Honestly it seems like you're making your life seem much more difficult. For one thing merging one users merges like this is highly likely to create conflicts, which in my opinion defeats the entire purpose of scripting the merge.
But you could use svn mergeinfo --show-revs eligible ^/branches/mybranch ^/trunk
to find the revs eligible for merging back to trunk for your branch. Then run svn log -r $REV
on each revision and ignore revisions that aren't in the proper date range or user. Then merge those commits. When 1.9 comes out mergeinfo
will have --xml
and --log
options. So you could combine the two steps into a single command and use XSLT to do the filtering for you similar to the answer I gave in: List all files which are changed b/w two revision by a user
All that said, you should just use svn merge --reintegrate ^/branches/mybranch
where your current directory is an update to date and unmodified working copy of trunk which will merge all changes from the branch. If you're using 1.8 you can leave off the --reintegrate
option since 1.8 detects if a merge is a reintegration automatically. Doing it like this would minimize conflicts.
If you have nested branches you have to merge up through all the branches to get to trunk. So if you have a branch named branch1 off trunk and branch1.1 off branch1 then you need to reintegrate to branch1 from branch1.1 before merging back from trunk.