From: Eric S. Raymond Date: Sat, 29 Nov 2014 10:30:07 +0000 (-0500) Subject: Check that we're not confused by files with numeric names. X-Git-Tag: 0.14~3 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=8f46268b8dcbf707cee9daf9525b749526f88800;p=src.git Check that we're not confused by files with numeric names. Regression test passes. --- diff --git a/src b/src index 2195caf..f87b2a6 100755 --- 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 094a278..fa8f66a 100755 --- 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 <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 <tryit +diff -u randomcontent tryit +check "cat of file with numeric name" + echo "srctest: all tests succeeded" rm -fr $SANDBOX