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.
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG11c076786d56: histedit: add templating support to histedit's rule file generation
rHG8d0c14d3420f: histedit: add templating support to histedit's rule file generation
rHG2b11fb23a1fe: histedit: add templating support to histedit's rule file generation
rHG43a40d6fd56c: histedit: add templating support to histedit's rule file generation
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
+ [histedit]
+ summary-format = '{rev} {bookmarks} {desc|firstline}'
Perhaps, "summary-template" is more consistent with the other config keys.
ctx = self.repo[self.node]
- summary = _getsummary(ctx)
- line = '%s %s %d %s' % (self.verb, ctx, ctx.rev(), summary)
+ ui = self.repo.ui
+ tres = formatter.templateresources(ui, self.repo)
+ t = formatter.maketemplater(ui, ui.config('histedit', 'summary-format'),
+ defaults=templatekw.keywords,
+ resources=tres)
cmdutil.rendertemplate() can be used.
And it's probably better to do templater.unquotestring(ui.config(...)) for
consistency, even though we won't need any syntax to preserve leading/trailing
spaces here.
+ summary = t.renderdefault({'ctx': ctx}).splitlines()[0]
Nit: splitlines()[0] would fail if template was empty.
Queued, thanks.
+++ 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' + markerreturn 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)
Looks like unrelated change. Dropped.
+ summary = cmdutil.rendertemplate(
+ ctx, ui.config('histedit', 'summary-template')) or ''
+ summary = summary.splitlines()[0]
Still crash. ''.splitlines() == []