diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -156,6 +156,15 @@ [histedit] linelen = 120 # truncate rule lines at 120 characters +The summary of a change can be customized as well:: + + [histedit] + summary-template = '{rev} {bookmarks} {desc|firstline}' + +The customized summary should be kept short enough that rule lines +will fit in the configured line length. See above if that requires +customization. + ``hg histedit`` attempts to automatically choose an appropriate base revision to use. To change which base revision is used, define a revset in your configuration file:: @@ -217,6 +226,7 @@ repair, scmutil, state as statemod, + templatekw, util, ) from mercurial.utils import ( @@ -248,6 +258,8 @@ configitem('ui', 'interface.histedit', default=None, ) +configitem('histedit', 'summary-template', + default='{rev} {desc|firstline}') # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should @@ -480,8 +492,11 @@ """ ctx = self.repo[self.node] - summary = _getsummary(ctx) - line = '%s %s %d %s' % (self.verb, ctx, ctx.rev(), summary) + ui = self.repo.ui + summary = cmdutil.rendertemplate( + ctx, ui.config('histedit', 'summary-template')) or '' + summary = summary.splitlines()[0] + line = '%s %s %s' % (self.verb, ctx, summary) # trim to 75 columns by default so it's not stupidly wide in my editor # (the 5 more are left for verb) maxlen = self.repo.ui.configint('histedit', 'linelen') diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -394,7 +394,17 @@ def addtopichook(topic, rewriter): helphooks.setdefault(topic, []).append(rewriter) -def makeitemsdoc(ui, topic, doc, marker, items, dedent=False): +def _templateextsyms(ui, topic, doc): + for name, ext in extensions.extensions(ui): + kw = getattr(ext, 'templatekeyword', None) + if kw is not None: + doc = addtopicsymbols( + 'templates', 'Filters\n=======', kw, keepmarker=True) + return doc + +addtopichook('templating', _templateextsyms) + +def makeitemsdoc(ui, topic, doc, marker, items, dedent=False, keepmarker=False): """Extract docstring from the items key to function mapping, build a single documentation block and use it to overwrite the marker in doc. """ @@ -420,11 +430,14 @@ doclines.append(' ' + l.strip()) entries.append('\n'.join(doclines)) entries = '\n\n'.join(entries) + if keepmarker: + entries = entries + '\n\n' + marker return doc.replace(marker, entries) -def addtopicsymbols(topic, marker, symbols, dedent=False): +def addtopicsymbols(topic, marker, symbols, dedent=False, keepmarker=False): def add(ui, topic, doc): - return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent) + return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent, + keepmarker=keepmarker) addtopichook(topic, add) addtopicsymbols('bundlespec', '.. bundlecompressionmarker', diff --git a/tests/test-histedit-commute.t b/tests/test-histedit-commute.t --- a/tests/test-histedit-commute.t +++ b/tests/test-histedit-commute.t @@ -50,7 +50,7 @@ user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a - + show the edit commands offered $ HGEDITOR=cat hg histedit 177f92b77385 @@ -58,7 +58,32 @@ pick 055a42cdd887 3 d pick e860deea161a 4 e pick 652413bf663e 5 f - + + # Edit history between 177f92b77385 and 652413bf663e + # + # Commits are listed from least to most recent + # + # You can reorder changesets by reordering the lines + # + # Commands: + # + # e, edit = use commit, but stop for amending + # m, mess = edit commit message without changing commit content + # p, pick = use commit + # b, base = checkout changeset and apply further changesets from there + # d, drop = remove commit from history + # f, fold = use commit, but combine it with the one above + # r, roll = like fold, but discard this commit's description and date + # + +test customization of revision summary + $ HGEDITOR=cat hg histedit 177f92b77385 \ + > --config histedit.summary-template='I am rev {rev} desc {desc} tags {tags}' + pick 177f92b77385 I am rev 2 desc c tags + pick 055a42cdd887 I am rev 3 desc d tags + pick e860deea161a I am rev 4 desc e tags + pick 652413bf663e I am rev 5 desc f tags tip + # Edit history between 177f92b77385 and 652413bf663e # # Commits are listed from least to most recent @@ -140,7 +165,7 @@ user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a - + put things back @@ -182,7 +207,7 @@ user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a - + slightly different this time @@ -223,7 +248,7 @@ user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a - + keep prevents stripping dead revs $ hg histedit 799205341b6b --keep --commands - 2>&1 << EOF | fixbundle @@ -274,7 +299,7 @@ user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a - + try with --rev $ hg histedit --commands - --rev -2 2>&1 <> $HGRCPATH < [revsetalias] @@ -337,7 +362,7 @@ pick ece0b8d93dda 6 c pick 803ef1c6fcfd 7 e pick 9c863c565126 8 extra commit to c - + # Edit history between ece0b8d93dda and 9c863c565126 # # Commits are listed from least to most recent @@ -383,7 +408,7 @@ user: Robert Altman date: Mon Nov 28 16:35:28 2011 +0000 summary: Checked in text file - + $ hg histedit 0 $ cd .. @@ -432,7 +457,7 @@ pick b0f4233702ca 0 initial commit fold 5e8704a8f2d2 1 moved and changed pick 40e7299e8fa7 2 renamed - + diff --git a/another-dir/initial-file b/another-dir/initial-file new file mode 100644 --- /dev/null @@ -448,7 +473,7 @@ # Node ID 9b730d82b00af8a2766facebfa47cc124405a118 # Parent fffadc26f8f85623ce60b028a3f1ccc3730f8530 renamed - + diff --git a/another-dir/initial-file b/another-dir/renamed-file rename from another-dir/initial-file rename to another-dir/renamed-file