]> thyrsus.com Git - src.git/commitdiff
Tag lookup and @ are wirking.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 12 Nov 2014 21:16:38 +0000 (16:16 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 12 Nov 2014 21:16:38 +0000 (16:16 -0500)
NEWS
TODO
src
src.asc

diff --git a/NEWS b/NEWS
index ec2c5a15bcdfafb32b3661edf9eac9a47504a678..aab389f6e0c0e946df91a5bd592f9995f917065e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 `                      src project news
 
 Repository head:
+   Tag names for revisions work.
    Branch-sensitive traversal with .. is working.
    Fixed yet another fast-export bug.
 
diff --git a/TODO b/TODO
index f5abb7f764c8c3b624e66aea8d09b9d0017e9d40..d6b066c3edffd5e2019ff59fecac6daa17cf0f85 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,8 +1,6 @@
                        SRC TODO list
 
-* tag and branch names as revision-spec parts
-
-* revert?  reset?
+* branch names as revision-spec parts
 
 * src branch delete. Should branch_delete really obsolesce branched or just
   mark them dead?
diff --git a/src b/src
index 6a18d47c713aeacf0a3551a9e72a212d08caefc6..759fe0d0c9ca8f39c199d7dc623384db9d68beb6 100755 (executable)
--- a/src
+++ b/src
@@ -261,6 +261,8 @@ A 'revision' is a 1-origin integer, or a tag name designating an
 integer revision.  A revision range is a single revision, or a pair of
 revisions M-N (all revisions numerically from M to N) or M..N (all
 revisions that are branch ancestots of N and branch successors of M).
+If src complains that your revision spec looks like a nonexistent
+filename, you can prefix it with @ (this is always allowed).
 
 Unless otherwise noted under individual commands, the default revision
 is the tip revision on the current branch and the default range is all
@@ -354,6 +356,18 @@ src version
 The omission of 'src remove' is a deliberate speed bump.
 """)
 
+
+def parse_as_revspec(token):
+    "Does this look like something that should be parsed aas a revision spec?"
+    if "-" in token or ".." in token:
+        return True
+    elif token.isdigit():
+        return True
+    elif token.startswith("@"):        # Escape clause for tags that look like files
+        return True
+    else:
+        return False
+
 class CommandContext:
     "Consume a revision specification or range from an argument list"
     def __init__(self, cmd, args,
@@ -372,8 +386,10 @@ class CommandContext:
         if self.args:
             if self.args[0] == "--":
                 self.args.pop(0)
-            elif self.args[0][0].isdigit():
+            elif parse_as_revspec(args[0]):
                 revspec = self.args.pop(0)
+                if revspec.startswith("@"):
+                    revspec = revspec[1:]
                 try:
                     if "-" in revspec or ".." in revspec:
                         self.branchwise = ".." in revspec
@@ -394,10 +410,9 @@ class CommandContext:
                             pass
                     else:
                         try:
-                            self.start = int(revspec)
+                            self.end = self.start = int(revspec)
                         except ValueError:
-                            pass
-                        self.end = self.start
+                            self.end = self.start = revspec
                 except ValueError:
                     croak("malformed revision spec: %s" % revspec)
         if require_empty and not self.is_empty():
@@ -437,6 +452,8 @@ class CommandContext:
         return i in self.seq
     def resolve(self, metadata, reversed=True):
         "Resolve a revision spec that may contain tags into revnos."
+        if debug >= DEBUG_SEQUENCE:
+            sys.stderr.write("Entering do_resolve with start=%s, end=%s\n" % (self.start, self.end))
         if self.is_empty():
             if self.default_to == "branch":
                 self.seq = metadata.current_branch(reversed=False)
@@ -1231,7 +1248,7 @@ if __name__ == "__main__":
             try:
                 dispatch[commandline[0]](*commandline[1:])
             except KeyError:
-                sys.stderr.write("src: no such commandline as '%s'.  Try 'src help'\n" \
+                sys.stderr.write("src: no such command as '%s'.  Try 'src help'\n" \
                                % commandline[0])
     except KeyboardInterrupt:
         pass
diff --git a/src.asc b/src.asc
index 41dbec9556cd7ebd725ece89ac3cfb28d26b678c..7bcae0c0d073e242ba1aa65ba4257a8c84453eea 100644 (file)
--- a/src.asc
+++ b/src.asc
@@ -34,6 +34,8 @@ A 'revision' is a 1-origin integer, or a tag name designating an
 integer revision.  A revision range is a single revision, or a pair of
 revisions M-N (all revisions numerically from M to N) or M..N (all
 revisions that are branch ancestors of N and branch successors of M).
+If src complains that your revision spec looks like a nonexistent
+filename, you can prefix it with @ (this is always allowed).
 
 Unless otherwise noted under individual commands, the default revision
 is the tip revision on the current branch and the default range is all