From 457e2550787bbdfa3a48d61f0bee85eaa7a4d202 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 8 Nov 2014 10:57:33 -0500 Subject: [PATCH] Fix a minor bug in argument processing Send parse debug messages to stderr --- src | 56 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src b/src index 4c8127e..808cd1e 100755 --- a/src +++ b/src @@ -130,30 +130,31 @@ class RCSLog: self.lockrevs = [] maxrevno = 0 if debug >= DEBUG_PARSE: - sys.stdout.write("\t-> init\n") + sys.stderr.write("\t-> init\n") state = "init" for line in fp: if debug >= DEBUG_PARSE: - sys.stdout.write("in: %s\n" % repr(line)) + sys.stderr.write("in: %s\n" % repr(line)) if state == "init": if line.startswith("locks:"): if debug >= DEBUG_PARSE: - sys.stdout.write("\t-> locks\n") + sys.stderr.write("\t-> locks\n") state = "locks" elif line.startswith("symbolic names:"): if debug >= DEBUG_PARSE: - sys.stdout.write("\t-> symbols\n") + sys.stderr.write("\t-> symbols\n") state = "symbols" elif line.startswith("----------------------------"): if debug >= DEBUG_PARSE: - sys.stdout.write("\t-> logheader\n") + sys.stderr.write("\t-> logheader\n") state = "logheader" self.revlist.append(RCSRevisionItem(self, maxrevno)) + self.delimiter = line maxrevno += 1 elif state == "locks": if not line[0].isspace(): if debug >= DEBUG_PARSE: - sys.stdout.write("\t-> init\n") + sys.stderr.write("\t-> init\n") state = "init" else: fields = line.strip().split() @@ -161,7 +162,7 @@ class RCSLog: elif state == "symbols": if not line[0].isspace(): if debug >= DEBUG_PARSE: - sys.stdout.write("\t-> init\n") + sys.stderr.write("\t-> init\n") state = "init" else: fields = line.strip().split() @@ -194,7 +195,7 @@ class RCSLog: self.revlist[-1].log += "\n" break elif self.revlist: - self.revlist[-1].log += line[1:] + self.revlist[-1].log += line for item in self.revlist: item.revno = maxrevno - item.revno if debug >= DEBUG_PARSE: @@ -405,27 +406,28 @@ def commit_method(*args): croak("repository subdirectory %s does not exist" % repodir) args = list(args) comment = None - if args[0] == '--': - args.pop(0) - elif args[0] == "-": - comment = sys.stdin.read() - args.pop(0) - elif args[0] == "-m": - args.pop(0) - try: - comment = args[0] + if args: + if args[0] == '--': args.pop(0) - except IndexError: - croak("commit -m requires a following string.") - elif args[0] == "-f": - args.pop(0) - try: - comment = open(args[0]).read() + elif args[0] == "-": + comment = sys.stdin.read() args.pop(0) - except IndexError: - croak("commit -f requires a following filename argument.") - except OSError: - croak("couldn't open %s." % args[1]) + elif args[0] == "-m": + args.pop(0) + try: + comment = args[0] + args.pop(0) + except IndexError: + croak("commit -m requires a following string.") + elif args[0] == "-f": + args.pop(0) + try: + comment = open(args[0]).read() + args.pop(0) + except IndexError: + croak("commit -f requires a following filename argument.") + except OSError: + croak("couldn't open %s." % args[1]) (revspec, args) = preamble("commit", args) if revspec is not None: croak("commit doesn't take a revision spec") -- 2.43.0