Doing a merge between two branches in subversion
November 2017
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
About
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments
Recent Trackbacks
Categories
OpenBSD (9 items)
BSD (0 items)
FreeBSD (19 items)
Linux (3 items)
Security (3 items)
Python (22 items)
Zope (13 items)
Daily (144 items)
e-shell (9 items)
Hacks (14 items)
PostgreSQL (3 items)
OSX (8 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (1 items)
Django (24 items)
Music (12 items)
Plone (7 items)
Varnish (0 items)
Lugo (2 items)
Sendmail (0 items)
europython (7 items)
Cherokee (1 items)
self (1 items)
Nature (1 items)
Hiking (0 items)
uwsgi (0 items)
nginx (0 items)
cycling (9 items)
Networking (1 items)
DNS (0 items)
Archives

Syndicate this site (XML)

RSS/RDF 0.91

01 noviembre
2009

Doing a merge between two branches in subversion

they should add this to the svn book

UPDATE: I've fixed a typo in the proper way to do the merge, I wrote -r 210:240 but it should be -r 127:240 (from the point where the branch is created to the latest revision)

I would like to write some lines about this, as it took some time for me to realize how to do it correctly. Let me explain it with an example.

Imagine we have a svn repo like this one:

A scheme of a sample svn repo

In this repo we have the usual trunk, branches and tags repo layout. Let's forget about tags, as we are not going to use it for the purpose of this post. We start to use the repo with the initial import (r1, aka revision 1) inside the trunk. Then we continue adding more changes to the code, up to revision 127 (r127), where we create a new branch (called mybranch) using the svn copy command (r128).

At this point the development continue, but some developers work on the mybranch branch (doing commits up to r240) and some other developers work on the trunk code (doing commits up to r210).

And now is when the problem happens. Imagine we need to unify the development process in only one branch of development. As our main development was inside the mybranch branch we try to get the changes made into trunk (since we created mybranch) back into mybranch itself.

So, let's go to the Subversion book and search for how to do this. If you read the nightly build of the book, you will find that, in the basic merging section, the merge would be done like:

$ svn merge svn+ssh://svn.myproject.org/svn/trunk .

(you have to be in a clean checkout of the branch)

The problem with that is that it doesn't work at all. It will do some strange merges (for example, it will try to merge back things from revisions like r29 which changes are already in mybranch).

So, we try another approach:

$ svn merge svn+ssh://svn.myproject.org/svn/branches/mybranch \
svn+ssh://svn.myproject.org/svn/trunk .

(you have to be in a clean checkout of the branch too)

This doesn't work either, it will put your working copy into r210, deleting all the changes specific from mybranch...

So, what else could we do? Well, we can do it just using the -r flag to force the revisions between we want to do the merge, just like this:

$ svn merge -r 127:240 svn+ssh://svn.myproject.org/svn/trunk .

(once again, you have to be in a clean checkout of the branch)

This will merge back the changes made in trunk into mybranch.

And, now to end my post, just a curious annotation about the Subversion book. If you search for subversion book in google and you click in the direct links (Multi-page html for example), you will access the 1.4 version of the book, this one, where you can find the proper way to do the merge. But, if you go to the main subversion book page, you only have access to the nightly build and older versions of the book, where you can find the other two options I've mentioned...

Posted by wu at 17:06 | Comments (0) | Trackbacks (0)
<< Tonight is halloween | Main | Latest Amazon order is here! >>
Comments
There are no comments.
Trackbacks
Please send trackback to:http://blog.e-shell.org/192/tbping
There are no trackbacks.
Post a comment