if not quiet and len(args) > 1:
announce("%s -> 0" % arg)
-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)
+def getcomment(legend, args):
+ "Attempt to collect a comment from command line args."
comment = None
if args:
if args[0] == '--':
comment = args[0]
args.pop(0)
except IndexError:
- croak("commit -m requires a following string.")
+ croak("%s -m requires a following string" % legend)
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.")
+ croak("%s -f requires a following filename argument" % legend)
except OSError:
croak("couldn't open %s." % args[1])
+ return comment
+
+def edit_comment():
+ "Interactively edit a coment."
+ editor = os.getenv("EDITOR") or "emacsclient"
+ commentfile = "/tmp/src%dtmp" % os.getpid()
+ do_or_die(editor + " " + commentfile, loud=True)
+ comment = open(commentfile).read()
+
+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)
(revspec, args) = preamble("commit", args)
if revspec is not None:
croak("commit doesn't take a revision spec")
else:
metadata = History(arg)
if not comment:
- editor = os.getenv("EDITOR") or "emacsclient"
- commentfile = "/tmp/src%dtmp" % os.getpid()
- do_or_die(editor + " " + commentfile, loud=True)
- comment = open(commentfile).read()
+ comment = edit_comment()
# Delimiter won't be set just after add
if metadata.delimiter and metadata.delimiter in comment:
croak("malformed comment")