]> thyrsus.com Git - src.git/commitdiff
Fix a minor bug in argument processing
authorEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 15:57:33 +0000 (10:57 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 15:57:33 +0000 (10:57 -0500)
Send parse debug messages to stderr

src

diff --git a/src b/src
index 4c8127e38d14ee9163d14dc957cb69c158f834e4..808cd1ebd899ec779cd3ba77a8e2f5fffc76f5e2 100755 (executable)
--- 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")