Working on a long term svn branch

I work on a reasonably small team and for the most part everyone works in trunk. But it can happen where you need to switch over to a long term feature branch (more than a week or two) that can last sometimes months. The problem here is that your branch can easily diverge from trunk. If the intent is that the feature branch will eventually become the master (trunk) then you should merge the feature branch frequently. For me, this method has worked really well.

Merging often lets you take the trunk fixes that happen and you manually resolve any conflicts as they come in. Since the feature branch is going to be the final thing (when the feature is done), svn needs to know how to deal with these conflicts. It’s much better to deal with them as they come in, rather than try to integrate a feature branch after months of work only to see an svn merge with hundreds of conflicts.

The problem with resolving those conflicts later is that contextually you can’t remember what they were doing anymore. If you have a conflict that spans 2 or 3 files, it’s easy to get lost in what needs to be discarded, what needs to be modified, and what needs to be resolved with local or repo changes. This just means that your QA is going to absolutely hate you because nobody is confident that the merge was complete: something could be missing, or a logical piece isn’t right. By merging frequently from trunk into the branch you make svn’s job easier. It knows how to resolve potential conflicts because you already did it.

You can take this one step further and do the same thing with multiple feature branches. Lets say you have a setup like this:

svn

You have two feature branches and trunk. Periodically you should merge the first branch from trunk (I do this every monday morning). Then periodically also merge the second branch from the first branch. When the first branch is done, you can easily reintegrate it.

After you integrate the first branch, you can start to merge the second branch back off of trunk

svn2

Eventually when the second branch is done, you can reintegrate it back into trunk and you won’t have any conflicts.

The important thing here is to do your due diligence in making sure all the conflicts and merges are properly done and done often. Don’t wait till the last minute to do this, it can be time consuming but it’s a lot easier to do this upfront then all at the end.

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>