Friday, March 8, 2013

Resolving tree conflicts in Subversion

On the list of things I can never remember how to do when I need to do it: resolving tree conflicts in Subversion. Tree conflicts happen to me often when I am working in a branch of the main code and I merge from trunk to keep things current. I can't explain why they happen a lot in the system I work with (perhaps I should find out?), but I can fix them easily when they come up. But I always have to look up the simple command to do it. Well here is how it is done...
...but first, a quick note on what I am doing to make sure this command fits the bill.  I have a working copy (this is what Subversion calls the local copy) of a branch of the code on my computer.  I have just done a merge to bring in any changes from trunk and I see this:

$svn merge http://blah.blah/blah/blah/trunk/project .

--- Merging r32357 through r32391 into .

   C src/main/java/blah/blah/
   C src/main/java/blah/blah/blah/
 G   .
--- Recording mergeinfo for merge of r32357 through r32391 into '.':
 U   .
Summary of conflicts:
  Tree conflicts: 2

The items with the C in front of them have not changed, but Subversion is announcing a "Tree Conflict" because there is some attribute mismatch between my files and the server files. These happen to be the files I was working on, so it is not entirely random, but a comparison of the files and diffs and any other investigation shows that the contents of my working copy files are exactly what I want them to be. (You really need to check because with regular conflicts Subversion will stick some diff information in your files.)  I have determined that my working copy files are correct and I want to tell Subversion that so the conflict will be resolved and I can be sure my working copy and the repository are in sync. To tell Subversion that I am verifying my working copies are good, I could issue the following comands:

svn resolve --accept working src/main/java/blah/blah/

svn resolve --accept working src/main/java/blah/blah/blah/

In this case, though, I know that I want to resolve everything it found, so I can also do this:

svn resolve -R --accept working .

Which includes the -R flag for recursive, and uses the . to denote the current directory.  This will clear up all the tree conflicts in the file.

No comments:

Post a Comment