Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to revert svn property changes for a file without reverting changes to the file's contents?

Tags:

svn

After a merge, I might have both content-changes as well as property-changes to a file:

>svn st foo.h

MM      foo.h

Is there a way to keep the content-changes, but revert the property-changes?

I could copy the file to a temporary location, revert, then copy back:

>cp foo.h /tmp

>svn revert foo.h

>mv -f /tmp/foo.h foo.h

>svn st foo.h

M       foo.h

But that would be cumbersome with many files, without writing a separate script.

I was hoping there may be an svn option that I've missed.

like image 833
jason.rickman Avatar asked May 19 '11 19:05

jason.rickman


People also ask

How do I revert changes in svn?

Right click on the selected revision(s), then select Context Menu → Revert changes from this revision. Or if you want to make an earlier revision the new HEAD revision, right click on the selected revision, then select Context Menu → Revert to this revision. This will discard all changes after the selected revision.

What is svn revert option?

svn revert will revert not only the contents of an item in your working copy, but also any property changes. Finally, you can use it to undo any scheduling operations that you may have performed (e.g., files scheduled for addition or deletion can be “unscheduled”).

Can we revert commit in svn?

Note that the svn merge command reverts a commit in the sense of having another commit undoing your changes, but keeping your wrong commit in the history.


2 Answers

Sorry, I don't know of any way to just revert properties… But if I was faced with that situation, I think I would run:

$ svn proplist -v -r $REV foo.h
... # output, which I would copy to the clipboard
$ svn propedit foo.h
... paste in properties ...

And that could probably even be scripted, if you had to revert the properties for a bunch of files.

like image 93
David Wolever Avatar answered Oct 13 '22 07:10

David Wolever


Ran into this situation myself this morning. Here's a bash script that does the trick ...

for f in $( svn st . | grep '^MM' | cut -c 3- )
do 
   cp $f $f.$$ && svn revert $f && mv $f.$$ $f 
done
like image 40
andreas buykx Avatar answered Oct 13 '22 09:10

andreas buykx