3

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.

lwijono
  • 389
  • 2
  • 5
  • 18
  • If the only difference between step 2 and 3 is the one new file, I would just refresh your branch from trunk. I think when they are merged using the method above, that new files in your branch doesn't exist in trunk, at least as far as the branch knows. – user1231231412 Jan 24 '12 at 00:44
  • On the actual code, there would be a lot of files being moved. Some of the files (moved and not moved) may also be modified. – lwijono Jan 24 '12 at 04:59

2 Answers2

2

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

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • By using method 1 you will create subtree merge info which will make further reintegrate merges impossible. – Peter Parker Jan 24 '12 at 19:24
  • I am having a problem understanding method 1. Correct me if I'm wrong but is this what you mean? First, merge all modified files in branch with their corresponding file (original) from trunk. Then, I need commit the code from branch to the (branch) repository. Next, I merge the revision from the branch back to trunk (latest). Is this what you mean? – lwijono Jan 25 '12 at 00:15
  • @lwijono - when you merge files, you merge to trunk, not branch – Lazy Badger Jan 25 '12 at 03:15
  • I tried to merge the moved/renamed code from the branch back to trunk. However, if the codes itself is also changed in trunk then this way will not work for me. – lwijono Jan 25 '12 at 13:56
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).

lwijono
  • 389
  • 2
  • 5
  • 18
  • I reorganized a big enterprise project with svn. Its a tedious process and takes hell lot of time. So, my recommendation is to keep the branch up to date with trunk frequently. Don't let the branch run behind the trunk and then you ll end with a huge merge problem. – Sri Aug 15 '15 at 04:19
  • Also note, that you might loose some history during the sync (trunk to branch). – Sri Aug 15 '15 at 04:20