32

I have a svn working copy which I attempted to reverse merge a couple of recent revisions into. I cancelled the merge before it completed as I changed my mind. Now my working copy has a couple of thousand "changes" from updates to the ancestry related properties on most of the files. I have about 10 files with real code changes mixed in which I don't want to have to seperate out by hand.

Is there a way for me to revert all of the property changes without affecting the content changes?

6 Answers 6

33
svn revert `svn status | grep '^ M' | sed 's/^ M \+//g'`
2
  • 1
    Thank you Chris, I forgot to replace my bash alias :) Jan 31, 2012 at 20:06
  • 2
    You should use '^ M' instead of ' M'. Also, what about files like 'MM' with relevant text changes but propertie changes to discard?
    – calandoa
    Oct 7, 2013 at 17:15
22

If you use the revert option --depth empty, you'll revert changes only to paths explicitly specified on the command line and not recursively. So if those changes are property changes, that will be the only thing you revert.

Example: if you have the directory foo with unwanted property changes, but its content has modifications, the following will revert the property changes, but keep the modifications of its content:

$ svn revert --depth empty foo

as is demonstrated here:

$ svn status foo
 M      foo
M       foo/bar
$ svn revert --depth empty foo
$ svn status foo
M       foo/bar
9

Turns out that Tortoise SVN can do this really nicely. In the commit dialog you can sort the "modified" files by "text status" or "properties status". I simply sorted by text status and then reverted all the "modified" files which had "normal" "text status".

1
  • This works for revert too (and I imagine any other Tortoise command). Thanks for the tip!
    – sam
    Feb 3, 2011 at 12:23
1

Revert all property changes with PowerShell.

> @(svn status) -match '^ M' | `
>>> % { ($_ -split 'M\s+')[1] } | `
>>> % { svn revert --depth empty $_ }

Credit to Jerome Jaglale and TheJuice for the general approach.

Note the backtick ` symbol indicates a new line.

0

You can submit your changes and then revert the property changes from that revision:

svn merge -c -REV -depth empty

where REV is the revision where you want to revert the property changes

-4

I would just copy/backup the 10 files with the real code change somewhere else, and just svn revert -R the whole project, then copy back the 10 files.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.