0

After checking out a repository, I want to revert it to the oldest version. Is there a way to do it? Anything short of running

svn log | grep '|' > log

(I have to do this for multiple folders). And then getting the first word of the last line and then removing the 'r' and then converting it to an integer. And this assumes that no commit messages have '|' in them, which I guess is a safe assumption, but isn't "correct", as such.

Note: I know how to check out out a specific revision number.

Running svn revert ./* within the directory didn't work either. After doing that, when I ran svn up, it said "At revision __" (latest revision). Running svn co -r works fine

4
  • I am confused. Why can't you just checkout a specific version number?
    – Zoredache
    Aug 6, 2013 at 1:16
  • I can. But I need to do this for around 19 folders, so I'd have to run 'svn log', wait for the result, then find the last number, and then checkout that revision. revert seems to be what I'm looking for, but it isn't working, for some reason Aug 6, 2013 at 8:59
  • 1
    @asymptotically: revert actually undoes local changes made to the working: svnbook.red-bean.com/en/1.7/svn.ref.svn.c.revert.html
    – mthomas
    Aug 6, 2013 at 20:25
  • So if I checkout the lastest revision and revert, it doesn't do anything? Oh ... Aug 7, 2013 at 5:27

1 Answer 1

0

You have two problems. The first, is "how do I quickly find the first revision for a directory in the repository". This can probably be solved as in https://stackoverflow.com/questions/2675749/how-do-i-see-the-last-10-commits-in-reverse-chronoligical-order-with-svn using svn log --limit 1 -r1:HEAD which should limit you to the earliest single log message for the directory. This uses "--limit 1" to show only a single message, and "-r1:HEAD" to order the displayed messages from first to last instead of the usual last to first.

The second problem, is "how do I get my working copy to point to a specific revision, once I know the revision?"

As you know, svn co -r123 will get you a NEW working copy at revision 123. If you already have a working copy, you just use svn update -r123 instead, to update your working copy to that revision.

Note that you can also use dates in your revision specifier, as detailed at http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html#svn.tour.revs.dates . Also a few keywords are supported like HEAD.

2
  • I still have to parse the output of svn log in order to get the revision number, and then run svn update or svn co with it. I was wondering if there was a simpler way to directly get the revision number without having to parse anything, because it seems like something that could be common. Sep 5, 2013 at 14:58
  • 1
    I don't think so. But you can use a date without knowing a revision number, if you know a date which would correspond to the revision you want.
    – Ben
    Sep 5, 2013 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .