Thursday, June 9, 2011

Merging from a deleted branch in SVN with pegged revisions

A co-worker showed me a trick the other day in order to allow me to merge from a delete branch in SVN.

My problem was that I had merged my branch to trunk, then deleted it, but some work for a specific ticket needed to be merged to another branch:
  • Branch A - My branch (deleted @ revision 1000)
  • Trunk - ....
  • Branch B - Other branch
When I merged to trunk, I just reintegrated the whole branch, so the commit wasn't broken down by ticket. I needed one ticket for Branch B. What I didn't know is that you can specify a SVN path on a merge with a given revision, for example, one where a delete path still existed.

Here is the merge command example:

$ svn merge -r 2009:2010 svn_branch_b

Where "svn_branch_b" is a local working copy of "Branch B" merging from deleted "Branch A". Notice on the SVN path in the merge "@999", this is the revision before the delete, so the path still existed at that point.

This syntax is a "pegged version", or is at least what my co-worker described as. 

No comments:

Share on Twitter