Merge

Overview

I recently cut a branch to do some namespace refatoring of the T-PRO code base. I would like to merge this branch back into trunk. Fortunately for me this should be pretty easy since trunk has not received any development in the mean time. Thus, I should not have any conflicts to resolve. Here is the process I used which follows closely to Sepcot’s blog page on SVN Merging1

Checkout Both the Branch and Trunk

Make sure I have a copy of both the branch and trunk checked out. I was using Eclispe w/ subclipse plugin will allows me to import a project into my workspace by checking it out from SVN. I started with File - Import which brought up the project import window:


I then proceeded to checkout the projects.

Get the Revision Range You want to Merge

In order to do a merge, one must decide what range of revisions (commits) they would like to merge. This means choosing a starting point and a stopping point.

Start Revison

One can get the start revision by examining when the branch was created. A way to do so is look at the output of svn log using the stop-on-copy parameter while in the branch repo:

svn log --stop-on-copy

We’re looking for the last line in the display which shows the oldest revision (smallest r#). This is the first revision of the branch, when it was copied from the trunk2

My last few log lines looked like:

r773 | hunter | 2009-06-03 19:44:05 -0400 (dc, 03 jun 2009) | 3 lines

IRDA to Facade
MVC to higher namespace
Mention of IRDA pretty much gone.
------------------------------------------------------------------------
r772 | hunter | 2009-06-03 17:32:20 -0400 (dc, 03 jun 2009) | 1 line

rework Schema Namespace to be more Catalyst like
------------------------------------------------------------------------
r771 | hunter | 2009-06-03 17:09:35 -0400 (dc, 03 jun 2009) | 1 line

Reduce NameSpace tech debt
------------------------------------------------------------------------

Therefore I was able to ascertain the revision 771, r771, was the first revision of the branch and the point at which I’d like to start the merger.

Stop Revison

I want the merge to happen all the way through the lastest revision on the branch. I can get this from either the branch or trunk. Let’s go to trunk since we’re going to do the merge there anyway. While in trunk, update the your working copy

svn update

You will see output of the latest revision number such as:

At revision 807.

The Merger

Now that we have the revision number range, 771-807, for the merge, let’s do it:

Pull Branch Changes into Trunk

svn merge -r771:807 https://my.server.org/svn/project/branches/wanted_branch

Resolve Conflicts

In my case, since trunk was not developed on after revision 770, I didn’t have to resolve conflicts. If you are using the procedure to merge a branch when trunk did have simulutaneous development you may have conflicts to resolve by hand.

Commit Merge back to Repo

At this point we just have a working copy of turnk with a branch merged in. We need to get this back to the central repository for all the world to enjoy and make it lasting.

svn commit -m "MERGE my_project my_branch from revision 771 to 807 into trunk"

Foot Notes

1 Sepcot Blog Page: http://www.sepcot.com/blog/2007/04/SVN-Merge-Branch-Trunk

2 This revision and the one before are identical wrt. The branch meta information is the only difference.

My tags:
 
Popular tags:
 
Powered by MojoMojo