if not quiet and len(args) > 1:
announce("%s -> 0" % arg)
-def getcomment(legend, args):
+def get_comment(legend, args):
"Attempt to collect a comment from command line args."
comment = None
if args:
editor = os.getenv("EDITOR") or "emacsclient"
commentfile = "/tmp/src%dtmp" % os.getpid()
do_or_die(editor + " " + commentfile, loud=True)
- comment = open(commentfile).read()
+ return open(commentfile).read()
+
+def prepare_comment(comment, metadata):
+ "Validate comment text and preapare it to be passed to the back end."
+ # Delimiter won't be set just after add
+ if metadata.delimiter and metadata.delimiter in comment:
+ croak("malformed comment")
+ if not comment.endswith("\n"):
+ comment += "\n"
+ # Because it's going to be handed back in single quotes
+ return comment.replace("'", r"\'")
def commit_method(*args):
"Commit changes to files."
if not os.path.exists(repodir):
croak("repository subdirectory %s does not exist" % repodir)
args = list(args)
- comment = getcomment("commit", args)
+ comment = get_comment("commit", args)
(revspec, args) = preamble("commit", args)
if revspec is not None:
croak("commit doesn't take a revision spec")
metadata = History(arg)
if not comment:
comment = edit_comment()
- # Delimiter won't be set just after add
- if metadata.delimiter and metadata.delimiter in comment:
- croak("malformed comment")
- if not comment.endswith("\n"):
- comment += "\n"
- comment = comment.replace("'", r"\'")
+ comment = prepare_comment(comment, metadata)
with backend.lifter(arg):
backend.checkin(arg, comment)
if not quiet and len(args) > 1: