Mercurial > public > mercurial-scm > hg-stable
diff hgext/histedit.py @ 41523:11c076786d56
histedit: add templating support to histedit's rule file generation
This will allow users to customize the display of the rule list for the
free-form segment that we don't interpret. We've had users want to add things
like bookmark names or similar to the rule list as a convenience, which seems
reasonable.
Differential Revision: https://phab.mercurial-scm.org/D5742
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 29 Jan 2019 18:46:11 -0500 |
parents | 5cb8158a61f7 |
children | 5d63cb7d8f83 |
line wrap: on
line diff
--- a/hgext/histedit.py Fri Feb 01 17:03:51 2019 -0800 +++ b/hgext/histedit.py Tue Jan 29 18:46:11 2019 -0500 @@ -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:: @@ -248,6 +257,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 +491,11 @@ <hash> <rev> <summary> """ 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')