subversion best practice to merge branch to trunk where the file structures in the branch has been modified

StackOverflow https://stackoverflow.com/questions/8980685

Question

I am facing a situation at which my development team would like to re-organize the file structures in our repositories. This process will take about 2-3 months. During the file re-structurization, we still have to do a software releases. So, after the re-structurization process, we want to merge the organized files from the branch back to trunk. It is important to preserve the file history and also we need to be able to merge the code changes in trunk since first creating the branch.

My initial attempt was by creating a branch and then simply merge it. Unfortunately, it is not as simple as I thought. One of my test scenarios was the following:

  1. Created the branch from trunk
  2. Update a file in trunk
  3. Move the file in the branch
  4. update the file in the branch
  5. Doing a merge from branch back to trunk

At step 5, I got a "tree conflict" error on the file that I update in trunk. TortoiseSVN does not give information on what file in branch that that the conflicted file related to. In my scenario, it is not that difficult to figure out the files with problems; however, in our real repository it will be very difficult because we have thousands of files and many of those files have the same filenames (in a different folders).

Does anyone have experiences in the same situation as I am in? Any suggestion / best practices that I should/can do to make ensure the integrity of the codes?

Thanks for all the helps.

Was it helpful?

Solution 2

This is what I ended up doing: 1. Merge all renamed and modified files in the branch with all the updates (when applicable) from trunk 2. Commit branch to repository. The branch now has the latest code including changes from trunk since the branch was first created 3. Merge all changes from the branch back to trunk. Trunk will not have all the updated files structure and all changes that happens in both trunk and the re-organization branch

Note: Expect to still get Tree conflict for files that are updated in trunk and moved to another location in the branch. All I needed to do was removing those files.

Step #1 is a tedious process but it works on my test. This may not the best solution but it works for me (maintain updates from both trunk and branch and also preserve history).

OTHER TIPS

You can go two ways

1. Pure-SVN method

After refactoring before merge /branches/branchname /trunk directories, merge all renamed/moved files from branch with their trunk originals, i.e /branches/branchname/some/branchfile1 /trunk/trunkfile1 ... and merge dirs at last step

2. DVCS method

Use any DVCS with good merge (they all have it - Git, Mercurial, Bazaar...) and svn-bridge (git-svn, hgsubversion...), perform refactor-merges in DVCS-mirrored repo. After all - linearize repository (SVN history in line, DVCS -DAG) with DVCS tools (... rebase) and push resul to SVN-repo. If rebase will be too hard task for you, you can export final result from DVCS-of-choice (for SVN background I'll think about Mercurial or Bazaar, not Git) into unversioned tree and just do one-direction sync WC of trunk with this tree

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top