How do I force revert back so a specific revision number using command line SVN?
Asked Answered
W

3

5

I spoke too soon in my previous post about breaking things.

I am trying to revert back to revision 1124 using the command svn update -r 1124 but I keep getting an error message as follows:

[prague]$ svn update -r1024
U    app/webroot/css/group_themes/green.css
U    app/webroot/css/style.css
Skipped 'app/webroot/index.php'
svn: Failed to add directory 'app/webroot/images/users': an unversioned directory of the same name already exists

We got some stuff back up but still not the exact version which I know I had checked out last night... I thought it would be much easier to just revert back to a specific revision :(

Wycliffite answered 2/3, 2011 at 8:35 Comment(3)
Posting the error message might help ...Smother
btw- I think i hit "svn update 124" right before that so now i just want to force it back to 1124... i have the local copy on my machine but thought i could just "tell" svn to "undo" so to speakWycliffite
latest error based on comments below [prague]$ svn update -r 1124 Skipped 'app/webroot/index.php' svn: Failed to add directory 'app/webroot/images/users': an unversioned directory of the same name already exists [prague]$Wycliffite
B
13

Without commit

Try to checkout revision 1124 in a new empty directory, so you won't have conflicts with already existing directories.

So svn checkout -r 1124 in a new directory.

With commit

According to the svn manual, if you want to commit a previous revision, you need to use reverse merging. See http://svnbook.red-bean.com/en/1.0/ch04s04.html, 'Undoing Changes'.

svn merge -c -1124 http://svn.example.com/repos/calc/trunk followed by

svn commit -m "Rollback merge to revision 1124"

Boudreaux answered 2/3, 2011 at 8:43 Comment(17)
and once its checked out anew i should be able to just commit version 1124 in the command line?Wycliffite
Agreed. (Re?)moving the directory works, but using another directory to checkout from altogether might even be easier to do.Tryptophan
is there a second step... i checked out the new version into a new folder on my local machine... is there a step in betweenWycliffite
i now have a fresh directory on my local- but still cant commitWycliffite
latest error based on comments below [prague]$ svn update -r 1124 Skipped 'app/webroot/index.php' svn: Failed to add directory 'app/webroot/images/users': an unversioned directory of the same name already exists [prague]$ – adam 9 mins ago (sorry i added it to the question not to this thread)Wycliffite
If checking out a new revision also didn't work, try reverse merging like this: svn merge -c -1124 /path/to/repo and then svn commit. I will update my answer if this works for you.Boudreaux
but Skipped 'app/webroot/index.php' svn: Failed to add directory 'app/webroot/images/users': an unversioned directory of the same name already exists [prague]$Wycliffite
I updated my answer. Check the link I provided when you want to commit reverted changes, it should work ;).Boudreaux
i REALLY though we were there it "took" when i got the right url/path but now its asking for a password:)Wycliffite
Authentication realm: <svn.neighborrow.com:80> Private Area Username: neighborrow Password for 'neighborrow': svn: OPTIONS of 'svn.neighborrow.com/trac/repos/calc/trunk': authorization failed (svn.neighborrow.com) [prague]$ svn merge -c 1124 svn.neighborrow.com/trac/repos/calc/trunk Authentication realm: <svn.neighborrow.com:80> Private Area Password for 'neighborrow': Authentication realm: <svn.neighborrow.com:80> Private Area Username: adam Password for 'adam': svn: 'svn.neighborrow.com/trac/repos/calc/trunk' path not found [prague]$Wycliffite
The URL needs to point to your specific repository. The one I provided was just an example. That's why it says: path not found, because the directory doesn't exist. Does it work when you omit the url?Boudreaux
svn.neighborrow.com/trac IS the repository afaik - i knew to replace the example.com partWycliffite
and thanks for being patient- if we dont get it soon my team will probably be up by now to take a look themselves... i just get a kick out of trying to do it myselfWycliffite
[prague]$ svn merge -c 1124 svn.neighborrow.com/trac/calc/trunk Authentication realm: <svn.neighborrow.com:80> Private Area Password for 'neighborrow': Authentication realm: <svn.neighborrow.com:80> Private Area Username: adam Password for 'adam': svn: 'svn.neighborrow.com/trac/calc/trunk' path not found [prague]$Wycliffite
didnt catch that extra /repos/ thought that was finally going to do itWycliffite
Hmm I'm out of ideas, sorry! I thought it would work because I think I did exactly this to roll back my repo. Update your progress in your question so it gets bumped.Boudreaux
no apologies needed- i just wanted to see if we could get there! i have my team working on it ill have them post the solution shortlyWycliffite
T
3

Failed to add directory 'app/webroot/images/users': an unversioned directory of the same name already exists

Sounds clear to me: there already is a directory with that name, and it's not versioned. You can opt for two things: either remove the directory and update again, or rename (probably smartest) and update again.

 $ mv app/webroot/images/users app/webroot/images/users.orig/
 $ svn update -r1024

As an aside, do yourself a favour and look at some of the alternatives to SVN, such as Mercurial, Bazaar or Git. I've found the switch to be very pleasant ;)

Tryptophan answered 2/3, 2011 at 8:44 Comment(1)
thanks for the tips... ill definitely try those- i thought SVN/tortoise was my license to mess with code... but all it has done is taken away my fear of breaking things without really making it easy to revert things - even my team who knows this stuff doesnt love itWycliffite
D
0

You can simply do an update to revision using

svn up -r 1124 

But this will not let you commit the changes as SVN needs you to update your working copy to HEAD before you can commit. What you can do instead is

svn merge -r HEAD:1124 yourFile
svn ci yourFile -m "Reverting back to rev 1124 "
Dworman answered 13/10, 2015 at 9:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.