md4
md4

Reputation: 1669

Avoiding tree conflicts when merging structural changes

I have made a branch to do some cleanup and structural changes on a website. The contents of trunk were simply the website files, like so (abbreviated for brevity):

/trunk/css/
/trunk/images/
/trunk/js/
/trunk/index.html

After branching, I moved the contents down one level and created another directory for non-website content (mostly PSD files) that I nonetheless need to keep and work with. The structure is now:

/branches/cleanup/www/css/
/branches/cleanup/www/images/
/branches/cleanup/www/js/
/branches/cleanup/www/index.html
/branches/cleanup/support/psd/

How do I cleanly merge this back into the trunk without a ton of tree conflicts? I'm sure I've done this before. Problem is, I can't for the life of me remember how.

I made a number of trunk changes since the branch was created, so I am flooded with tree conflicts.

I'm happy to accept a less-than-ideal solution at this point, so my backup plan is to forget merging and instead perform an svn move on the trunk to something like /branches/old-trunk/, then svn move the cleanup branch into /trunk/ and go from there.

Will there be any nasty side-effects of doing this, besides having to manually apply the trunk changes to the cleanup branch?

Upvotes: 2

Views: 740

Answers (2)

ThisSuitIsBlackNot
ThisSuitIsBlackNot

Reputation: 24063

If you're willing to throw away the changes you made to trunk since making your branch, you can use the --accept option to svn merge to specify that you always want to use the branch version in case of conflict:

svn checkout TRUNK_URL WC_PATH
svn merge --accept theirs-full BRANCH_URL WC_PATH

You could also try theirs-conflict instead of theirs-full to only take the conflicted regions of files from the branch, instead of each file in its entirety. In your case, since you moved everything into a separate directory, I don't think there will be any difference, but I would try both and compare.

Ultimately, though, you probably made those changes to trunk for a reason. I would just bite the bullet and resolve the conflicts instead of tossing your work in the trash. There are other possible workarounds that could make the process less painful, like moving things in your branch back into the same directory structure as trunk, doing the merge, re-branching, and just changing the directory structure, but then you're introducing extra complication.

As an aside, this is why you should merge often. The introduction of automatic merge tracking in SVN 1.5 makes the process a lot less painful than it used to be.

Upvotes: 1

If there were no changes to the files in trunk, you will not get any conflicts.

If you changed any of the files inside trunk, that were also moved within the branch, there is no way to resolve this within Subversion without getting tree conflicts.

Update

If you move your branch to use it as the new trunk, it will break the automatic merge resolution for any other branches you might have. Other than that, there should be no issues with this move, since trunk is in no way "special" or different from any other directory when svn is concerned.

Upvotes: 3

Related Questions