From d977b03dbd8e9b56282fbe552581dc3b0b8fa5d3 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 19 Nov 2014 21:55:24 -0500 Subject: [PATCH] Added "src commit -a" mode to fit the Emacs model. Regression tests pass. --- src | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src b/src index b977f88..0b106b7 100755 --- a/src +++ b/src @@ -429,12 +429,13 @@ A good topic to read next would be 'commands'. src help [command] Displays help for commands. -src commit [- | -m 'string' | -f 'file' | -e] ['file'...] +src commit [-a] [- | -m 'string' | -f 'file' | -e] ['file'...] Enters a commit for specified files. Separately to each one. A history is created for the file if it does not already exist. With '-', take comment text from stdin; with '-m' use the following string as the comment; with '-f' take from a file. With '-e', edit even after '-f' or '-m'. 'ci' is a synonym for commit. + Find out more under 'help commit'. src amend [- | -m string | -f file | -e] ['revision'] ['file'...] Amends the stored comment for a specified revision, defaulting to the @@ -551,7 +552,7 @@ The -a option forces status listing of all files. This differs from the status of them. """, "commit":""" -src commit [- | -m 'string' | -f 'file' | -e] ['file'...] +src commit [-a] [- | -m 'string' | -f 'file' | -e] ['file'...] The commit command is how you add revisions to your file history. It always adds the contents of the workfile as a revision to the tip of @@ -586,6 +587,10 @@ forced editing with -e). This is a major difference from other VCSes, which are usually designed to create changesets common to multiple files. +The -a option is not for human use, but provided to fit Emacs +VC-mode's model of the editing/version-control cycle. With -a, the +file is registered but no first commit is performed. + 'ci' is a synonym for commit. """, "amend" : """ @@ -1033,6 +1038,13 @@ def commit_method(*args): except OSError: croak(" %s creation failed, check directory permissions." % repodir) args = list(args) + addflag = False + if args: + if args[0] == '--': + args.pop(0) + elif args[0] == '-a': + addflag = True + args.pop(0) comment = CommentContext("commit", args) ctx = CommandContext("commit", args, require_empty=True) for arg in ctx.args: @@ -1053,8 +1065,9 @@ def commit_method(*args): else: if not registered(arg): backend.add(arg) - with backend.lifter(arg): - backend.checkin(arg, comment.content()) + if not addflag: + with backend.lifter(arg): + backend.checkin(arg, comment.content()) if not quiet and len(args) > 1: announce("%s -> %d" % (arg, revcount)) @@ -1105,7 +1118,8 @@ def list_method(*args): custom = args[0][2:] args.pop(0) ctx = CommandContext("list", args, default_to="branch_reversed") - width = screenwidth() + if custom is None: + width = screenwidth() for arg in ctx.args: if ignore(arg) or not registered(arg): continue @@ -1117,7 +1131,7 @@ def list_method(*args): mark = "*" else: mark = "-" - summary = item.log.split('\n')[0][:width - 34] + summary = item.log.split('\n')[0] if custom is None: summary = summary[:width - 34] sys.stdout.write("%-4d %s %s %s\n" \ -- 2.43.0