]> thyrsus.com Git - src.git/commitdiff
Checkout is working, but with reversed numbers.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 6 Nov 2014 23:37:17 +0000 (18:37 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 6 Nov 2014 23:37:17 +0000 (18:37 -0500)
src

diff --git a/src b/src
index 07b3caaaa63d07194dd84f29dd1ca24115cd0201..ddbe76d55a27a2ac9892bbc19a3b4cc43a3c1d63 100755 (executable)
--- a/src
+++ b/src
@@ -253,18 +253,20 @@ def log_method(*args):
 def checkout_method(*args):
     "Refresh the working copy from the history file."
     (revspec, args) = preamble("checkout", args)
-    if len(revspec) > 1:
+    if revspec and len(revspec) > 1:
         croak("checkout needs an empty or singleton revision spec")
     for arg in args:
         revlist = log_capture(arg)
         if revspec is None:
             revision = ""
-        elif len(revspec) == 1:
-            revision = "-r" + revlist[revspec[0]-1].revision
-        else:
+        elif len(revspec) != 1:
             croak("checkout cannot take a range")
-        do_or_die("mv .src/{0},v . && rm -f {0} && co -l {1} {0} && mv {0},v .src".format(arg, revision))
-        announce("%s <- %d" % (arg, len(revlist))) 
+        elif revspec[0] > len(revlist):
+            croak("%s has only %d revisions" % len(revlist))
+        else:
+            revision = revlist[revspec[0]-1].revision
+        do_or_die("mv .src/{0},v . && rm -f {0} && co -u{1} {0} ; mv {0},v .src".format(arg, revision))
+        announce("%s <- %d" % (arg, revspec[0])) 
 
 def cat_method(*args):
     "Dump revision content to srandard output."