Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subversion: Merge, Revert, Merge again. Why does it silently fail?

Tags:

svn

Is this a nasty Subversion bug or am I approaching it the wrong way?

Merge a branch into a trunk. ->HelloWorld.txt updates

Revert HelloWorld.txt

Do the same merge again. ->No files update.

Why doesn't the second merge update HelloWorld again? It's acting as if that change has already been copied over. Shouldn't the revert reset it?

If you revert the entire folder HelloWorld is in, the second merge properly applies the change again. It's only if you revert a file that it fails.

This is a little scary. What if I need to revert some files for now. Any future merge will silently fail to copy over critical code.

Subversion 1.6 OS X 10.6.4

like image 202
Stephen Avatar asked Sep 29 '10 16:09

Stephen


People also ask

How do I undo a merge in svn?

You can use svn merge to “undo” the change in your working copy, and then commit the local modification to the repository. All you need to do is to specify a reverse difference. (You can do this by specifying --revision 392:391 , or by an equivalent --change -392 .)

What does svn revert do?

Reverts any local changes to a file or directory and resolves any conflicted states. svn revert will revert not only the contents of an item in your working copy, but also any property changes.


2 Answers

This comportment is documented in svn documentation Advanced Merging section (see note 23). When you first merge your change, the merged revision number is tracked in the svn:mergeinfo property. If you undo your changes, the revision is still marked as merged, to prevent you from merging it again by mistake. The fact is that if you removed it, there's little chance you want it back...

If however you really want to merge it again, then you can use the --ignore-ancestry option that will not check in svn:mergeinfo if the revision has been merged previously. Another solution is to deliberately remove this revision from svn:mergeinfo, so that it can be merged again in the future. But don't do it by hand, use the --record-only option of the svn merge command for that.

like image 176
liberforce Avatar answered Sep 23 '22 07:09

liberforce


Subversion performs merge tracking, meaning it will record what revisions have already been merged. The merge info is recorded in a property called svn:mergeinfo on the root of the merge (ie whatever you entered as target after svn merge). You reverted the file, but probably didn't revert the merge root that contains the modified or added svn:mergeinfo property.

like image 37
Sander Rijken Avatar answered Sep 21 '22 07:09

Sander Rijken