]> thyrsus.com Git - src.git/commitdiff
Check that we're not confused by files with numeric names.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 29 Nov 2014 10:30:07 +0000 (05:30 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 29 Nov 2014 10:30:07 +0000 (05:30 -0500)
Regression test passes.

src
srctest

diff --git a/src b/src
index 2195cafd835136f925a959eaeec656c45ab6773a..f87b2a637293121b355a4621f9da2b4008da9430 100755 (executable)
--- a/src
+++ b/src
@@ -848,7 +848,8 @@ class CommandContext:
     "Consume a revision specification or range from an argument list"
     def __init__(self, cmd, args,
                  require_empty=False,
-                 default_to=None):
+                 default_to=None,
+                 parse_revspec=True):
         if not os.path.exists(repodir):
             croak("repository subdirectory %s does not exist" % repodir)
         self.start = self.end = None
@@ -862,7 +863,7 @@ class CommandContext:
         if self.args:
             if self.args[0] == "--":
                 self.args.pop(0)
-            elif parse_as_revspec(args[0]):
+            elif parse_revspec and parse_as_revspec(args[0]):
                 revspec = self.args.pop(0)
                 if revspec.startswith("@"):
                     revspec = revspec[1:]
@@ -992,8 +993,10 @@ The cut line and things below it will not become part of the comment text.
         self.leader = ""
         self.comment = None
         self.force_edit = False
+        self.parse_revspec = True
         if args:
             if args[0] == '--':
+                self.parse_revspec = False
                 args.pop(0)
             elif args[0] == "-":
                 self.leader = sys.stdin.read()
@@ -1063,7 +1066,9 @@ def commit_method(*args):
             croak(" %s creation failed, check directory permissions." % repodir)
     args = list(args)
     comment = CommentContext("commit", args)
-    ctx = CommandContext("commit", args, require_empty=True)
+    ctx = CommandContext("commit", args,
+                         require_empty=True,
+                         parse_revspec=comment.parse_revspec)
     for arg in ctx.args:
         if not os.path.exists(arg):
             croak("I see no '%s' here." % arg)
@@ -1094,7 +1099,7 @@ def amend_method(*args):
         croak("repository subdirectory %s does not exist" % repodir)
     args = list(args)
     comment = CommentContext("amend", args)
-    ctx = CommandContext("amend", args)
+    ctx = CommandContext("amend", args, parse_revspec=comment.parse_revspec)
     if ctx.is_range():
         croak("amend cannot take a range")
     for arg in ctx.args:
@@ -1141,8 +1146,10 @@ def list_method(*args):
     args = list(args)
     custom = None
     limit = None
+    parse_revspec = True
     if args:
         if args[0] == '--':
+            parse_revspec = False
             args.pop(0)
         elif args[0] == "-f":
             args.pop(0)
@@ -1164,7 +1171,9 @@ def list_method(*args):
                 croak("list -f requires a following string")
             except ValueError:
                 croak("%s is not an integer" % limit)
-    ctx = CommandContext("list", args, default_to="branch_reversed")
+    ctx = CommandContext("list", args,
+                         default_to="branch_reversed",
+                         parse_revspec=parse_revspec)
     for arg in ctx.args:
         if ignore(arg) or not registered(arg):
             continue
@@ -1192,8 +1201,10 @@ def log_method(*args):
     "Report revision logs"
     limit = None
     args = list(args)
+    parse_revspec = True
     if args:
         if args[0] == '--':
+            parse_revspec = False
             args.pop(0)
         elif args[0] == "-l":
             args.pop(0)
@@ -1205,7 +1216,9 @@ def log_method(*args):
                 croak("list -f requires a following string")
             except ValueError:
                 croak("%s is not an integer" % limit)
-    ctx = CommandContext("log", args, default_to="branch_reversed")
+    ctx = CommandContext("log", args,
+                         default_to="branch_reversed",
+                         parse_revspec=parse_revspec)
     for arg in ctx.args:
         if ignore(arg) or not registered(arg):
             continue
diff --git a/srctest b/srctest
index 094a278332d20b79db3c2b0d72c8fd826b83d52b..fa8f66a0b28d2d121f99429a41fe50a1f7699c69 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -589,7 +589,7 @@ EOF
 
 src $TESTOPTS branch -l sample >tryit
 diff -u newlist tryit
-check "branch list check after delete" delete
+check "branch list check after delete"
 
 cat >newlog <<EOF
 = sample ===============================================================
@@ -635,6 +635,18 @@ src $TESTOPTS log sample >tryit
 diff -u newlog tryit
 check "content after branch deletion"
 
+echo "Random content for numeric file" >23
+src $TESTOPTS commit -m "I don't know why you say goodbye" -- 23 >/dev/null
+check "commit of file with numeric name"
+
+cat >randomcontent <<EOF
+Random content for numeric file
+EOF
+
+src $TESTOPTS cat -- 23 >tryit
+diff -u randomcontent tryit
+check "cat of file with numeric name"
+
 echo "srctest: all tests succeeded"
 
 rm -fr $SANDBOX