]> thyrsus.com Git - src.git/commitdiff
Change editing logic so it works more nicely on multi-argument commmits.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 10 Nov 2014 17:02:02 +0000 (12:02 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 10 Nov 2014 17:02:37 +0000 (12:02 -0500)
Regression tesy passes.

src

diff --git a/src b/src
index cafc073b172858cf51c416cb825425d87132e12e..b38159691687cb21d51c208a12be1afb423265eb 100755 (executable)
--- a/src
+++ b/src
@@ -12,7 +12,7 @@
 # the workfile read-only except when it's explicitly checked out, SRC wants to
 # leave it writeable all the time.  Thus, the checkin sequence is "release
 # lock; check in; assert lock". If this seems confusing, it's because in
-# RCS rerminology, locked is writeable and unlocked is read-only.
+# RCS terminology, locked is writeable and unlocked is read-only.
 #
 # The "src status" command needs to be fast so that Emacs VC won't be sluggish.
 # It's written to only have to access the inodes of each master and workfile,
@@ -140,7 +140,6 @@ class History:
         self.revlist = []
         self.symbols = {}
         self.branch = "trunk"
-        self.delimiter = None
         if not os.path.exists(backend.master(self.name)):
             croak("%s is not registered" % self.name)
         backend.parse(self)
@@ -407,16 +406,17 @@ class CommentContext:
                     croak("%s -f requires a following filename argument" % legend)
                 except OSError:
                     croak("couldn't open %s." % args[1])
-    def edit(self, metadata):
+    def edit(self):
         "Interactively edit a comment if required, then prepare for handoff."
         if self.comment is None or self.force_edit:
             editor = os.getenv("EDITOR") or "emacsclient"
             commentfile = "/tmp/src%dtmp" % os.getpid()
             do_or_die(editor + " " + commentfile, loud=True)
             self.comment = open(commentfile).read()
-        # Delimiter won't be set just after add
-        if metadata.delimiter and metadata.delimiter in self.comment:
-            croak("malformed comment")
+        # Can be removed if we every parse RC files directly
+        for badnews in backend.delimiters:
+            if badnews in self.comment:
+                croak("malformed comment")
         if not self.comment.endswith("\n"):
             self.comment += "\n"
         # Because it's going to be handed back as a shell argument
@@ -437,13 +437,12 @@ def commit_method(*args):
            croak("I see no '%s' here." % arg)
        elif not os.path.exists(backend.master(arg)):
            croak("%s is not registered." % arg)
-       else:
-           metadata = History(arg)
-           comment.edit(metadata)    
-           with backend.lifter(arg):
-               backend.checkin(arg, comment.content())
-           if not quiet and len(args) > 1:
-               announce("%s -> %d" % (arg, len(metadata))) 
+    comment.edit() 
+    for arg in ctx.args:
+        with backend.lifter(arg):
+            backend.checkin(arg, comment.content())
+        if not quiet and len(args) > 1:
+            announce("%s -> %d" % (arg, len(History(arg)))) 
 
 def amend_method(*args):
     "Amend coments in stored revisions."
@@ -459,18 +458,18 @@ def amend_method(*args):
            croak("I see no '%s' here." % arg)
        elif not os.path.exists(backend.master(arg)):
            croak("%s is not registered." % arg)
-       else:
-           metadata = History(arg)
-           ctx.resolve(metadata)
-           if ctx.is_empty():
-               ctx.start = metadata.tip().revno
-           comment.edit(metadata)
-           with backend.lifter(arg):
-               backend.amend(arg,
-                             metadata.revno_to_rcs(ctx.start),
-                             comment.content())
-           if not quiet and len(args) > 1:
-               announce("%s : %d" % (arg, len(metadata))) 
+    comment.edit()
+    for arg in ctx.args:
+       metadata = History(arg)
+       ctx.resolve(metadata)
+       if ctx.is_empty():
+           ctx.start = metadata.tip().revno
+       with backend.lifter(arg):
+           backend.amend(arg,
+                         metadata.revno_to_rcs(ctx.start),
+                         comment.content())
+       if not quiet and len(args) > 1:
+           announce("%s : %d" % (arg, len(metadata))) 
 
 def list_method(*args):
     "Generate a summary listing of commits, one line per commit."
@@ -853,6 +852,8 @@ dispatch = {
 
 class RCS:
     "Encapsulate RCS back end methods."
+    delimiters = ('----------------------------'
+                  '=============================================================================')
     class RCSLifter:
         "Temporarily lift a master to the working directory."
         def __init__(self, name):
@@ -974,7 +975,6 @@ class RCS:
                             sys.stderr.write("\t-> logheader\n")
                         state = "logheader"
                         metadata.revlist.append(RCSRevisionItem(metadata, maxrevno))
-                        metadata.delimiter = line
                         maxrevno += 1
                 elif state == "locks":
                     if not line[0].isspace():