From d418fe89310aa535f469fb107494f6df32c894a9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 19 Nov 2014 20:32:40 -0500 Subject: [PATCH] Custom format option for src list (needed for VC mode). --- src | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src b/src index c67f345..b977f88 100755 --- a/src +++ b/src @@ -464,10 +464,11 @@ src rename ['tag'|'branch'] ['oldname'] ['newname'] ['file'...] Rename a tag or branch. Refuses to step on an existing symbol or rename a nonexistent one. 'rn' is a synonym for 'rename'. -src list ['revision-range'] ['file'...] +src list [-f fmt] ['revision-range'] ['file'...] Sends summary information about the specified commits to standard output. The summary line tagged with '*' is the state that the file would - return to on checkout without a revision-spec. + return to on checkout without a revision-spec. See 'help list' for + information about custom formats. src log ['revision-range'] ['file'...] Sends log information about the specified commits to standard output. @@ -663,7 +664,7 @@ number, the date, and the log comment. With no revision, dumps a log of the entire current branch. """, "list" : """ -src list ['revision-range'] ['file'...] +src list [-f fmt] ['revision-range'] ['file'...] Sends summary information about the specified commits of each file to standard output. The summary information includes the revision @@ -674,6 +675,15 @@ of beginning each commit with a self-contained summary line. With no revision, dumps a log of the entire current branch. +The -f option allows you to set a custom fomat string. Available +substitutions are: + +{0} The file name +{1} The revision number +{2} The mark - * is this is the currently checked out revision, else '-'. +{3} The date in RFC3339 format +{4} The summary line + 'li' is a synonym for 'list'. """, "diff" : """ @@ -1080,21 +1090,40 @@ def amend_method(*args): def list_method(*args): "Generate a summary listing of commits, one line per commit." + args = list(args) + custom = None + if args[0] == '--': + args.pop(0) + elif args[0] == "-f": + args.pop(0) + try: + custom = args[0] + args.pop(0) + except IndexError: + croak("list -f requires a following string") + elif args[0].startswith("-f"): + custom = args[0][2:] + args.pop(0) ctx = CommandContext("list", args, default_to="branch_reversed") width = screenwidth() for arg in ctx.args: if ignore(arg) or not registered(arg): continue - sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "="))) + if custom is None: + sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "="))) for item in ctx.resolve(History(arg), backwards=True): # Must allow enough room for revno and date - summary = item.log.strip()[:width - 34] if item.selected(): mark = "*" else: mark = "-" - sys.stdout.write("%-4d %s %s %s\n" \ + summary = item.log.split('\n')[0][:width - 34] + if custom is None: + summary = summary[:width - 34] + sys.stdout.write("%-4d %s %s %s\n" \ % (item.revno, mark, item.date, summary)) + else: + sys.stdout.write(custom.format(arg, item.revno, mark, item.date, summary)) def log_method(*args): "Report revision logs" -- 2.43.0