Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are you supposed to do with old SVN branches?

Tags:

We had a SVN branch recently that had been merged back to trunk, and some more work on that feature/functional area was needed. I suggested using the same branch but was told you shouldn't re-use a branch once it has been integrated into trunk (a reference in SVN docs was given, I can't find it now). That suggests a branch is fairly useless once you merge back to trunk, so my question is once a branch is no longer needed, should it simply be deleted or kept?

like image 911
Mr. Boy Avatar asked May 24 '10 20:05

Mr. Boy


People also ask

How do I delete a branch in svn repository?

For those using TortoiseSVN, you can accomplish this by using the Repository Browser (it's labeled "Repo-browser" in the context menu.) Find the branch folder you want to delete, right-click it, and select "Delete." Enter your commit message, and you're done.

Does svn merge delete the branch?

If you merge a branch into trunk using "svn merge --reintegrate", you are recommended to delete the branch. If you want to do further development in that branch, you should "re-branch", effectively create a new branch with the same name, but rooted at the same revision as you merged the branch into trunk.

Can we merge two branches in svn?

In the From URL option, you should specify the branch to which you want to merge. For example, assume that there are 2 branches, branch A and branch B , and you want to merge branch B to branch A . In TortoiseSVN, click on Merge option and then select Merge two different trees option.


2 Answers

When I integrate a branch, I move it from branches/ to branches/integrated/. Keeps branches/ clean so its easy to find current work, but also makes it easy to dig up old branches to see what changes were made without needing to do a lot of revision-number archeology.

like image 139
Stephen Canon Avatar answered Sep 20 '22 19:09

Stephen Canon


SVN 1.5 introduced the "mergeinfo" property, which allow you to easily reintegrate branches to the trunk while supporting repeated branch updates. This allows you to create a branch, perodiocally update the branch from the trunk , and finally reintegrate the branch to the trunk ( svn merge --reintegrate ). This is useful for example when you create a branch to fix a bug or to develop a functionality.

The way mergeinfo is implemented doesn't allow you to do a subsequent reintegration, so this is the reason why you are recommended not to reuse the branch.

This is problematic for "release branches" when you want to develop the bug fixes on the release branch and do periodic reintegration to the trunk.

If you want to reuse a branch, the usual pattern is to create a new copy ( branch ) with the same name:

  1. delete the branch
  2. commit
  3. recreate the branch ( branching in a path with the same name )
  4. commit
  5. work on the new branch

When you "recreate" the branch, in step 3, the mergeinfo is restored, so you can reintegrate in the future without problems.

Back to your question: "so my question is once a branch is no longer needed, should it simply be deleted or kept?" I would keep the branch, so it would be visible in the HEAD revision. Having branches disappear is confusing ( "hey, did we create a branch for release 0.1 last week? " "hmm, I don't remember... check the repo history" )

As for reusing the branch, I would use the convention to never reuse a branch, and if you need to "add somethig to it", recreate it. But in my opinion it is much clearer to use a different branch name. You probably can use a naming convention to identify the branches. For example, the original would be branches/Issue-1 and subsequent extensions branches/Issue-1.0 , branches/Issue-1.1 , etc

Mergeinfo references.

http://blogs.open.collab.net/svn/2008/07/subversion-merg.html http://blogs.open.collab.net/svn/2009/11/where-did-that-mergeinfo-come-from.html

like image 32
Ramiro González Maciel Avatar answered Sep 16 '22 19:09

Ramiro González Maciel