diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -156,6 +156,15 @@ configuration file:: [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:: @@ -248,6 +257,8 @@ configitem('histedit', 'singletransactio 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 +491,11 @@ class histeditaction(object): """ 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/tests/test-histedit-commute.t b/tests/test-histedit-commute.t --- a/tests/test-histedit-commute.t +++ b/tests/test-histedit-commute.t @@ -52,6 +52,7 @@ log before edit summary: a + show the edit commands offered $ HGEDITOR=cat hg histedit 177f92b77385 pick 177f92b77385 2 c @@ -76,6 +77,33 @@ show the edit commands offered # 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 + # + # 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 + # + + edit the history (use a hacky editor to check histedit-last-edit.txt backup) @@ -142,6 +170,7 @@ log after edit summary: a + put things back $ hg histedit 177f92b77385 --commands - 2>&1 << EOF | fixbundle @@ -184,6 +213,7 @@ put things back summary: a + slightly different this time $ hg histedit 177f92b77385 --commands - << EOF 2>&1 | fixbundle @@ -225,6 +255,7 @@ slightly different this time summary: a + keep prevents stripping dead revs $ hg histedit 799205341b6b --keep --commands - 2>&1 << EOF | fixbundle > pick 799205341b6b d @@ -276,6 +307,7 @@ keep prevents stripping dead revs summary: a + try with --rev $ hg histedit --commands - --rev -2 2>&1 < pick de71b079d9ce e @@ -326,6 +358,7 @@ try with --rev date: Thu Jan 01 00:00:00 1970 +0000 summary: a + Verify that revsetalias entries work with histedit: $ cat >> $HGRCPATH < [revsetalias] @@ -355,6 +388,7 @@ Verify that revsetalias entries work wit # r, roll = like fold, but discard this commit's description and date # + should also work if a commit message is missing $ BUNDLE="$TESTDIR/missing-comment.hg" $ hg init missing @@ -384,6 +418,7 @@ should also work if a commit message is date: Mon Nov 28 16:35:28 2011 +0000 summary: Checked in text file + $ hg histedit 0 $ cd .. @@ -440,6 +475,7 @@ Now, let's try to fold the second commit @@ -0,0 +1,1 @@ +changed + $ hg --config diff.git=yes export 1 # HG changeset patch # User test @@ -453,6 +489,7 @@ Now, let's try to fold the second commit rename from another-dir/initial-file rename to another-dir/renamed-file + $ cd .. Test that branches are preserved and stays active