[Updated] D9314: templates: define a {onelinesummary} keyword
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Nov 18 23:07:23 UTC 2020
Closed by commit rHGdbc574726ea4: templates: define a {onelinesummary} keyword (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9314?vs=23484&id=23552
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9314/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9314
AFFECTED FILES
mercurial/templatekw.py
tests/test-template-keywords.t
CHANGE DETAILS
diff --git a/tests/test-template-keywords.t b/tests/test-template-keywords.t
--- a/tests/test-template-keywords.t
+++ b/tests/test-template-keywords.t
@@ -114,6 +114,30 @@
|
o 0 (public): -1 (public) -1 (public)
+Test {onelinesummary}
+
+ $ hg log -G -T '{onelinesummary}'
+ @ 8:95c24699272e tip "third"
+ |
+ o 7:29114dbae42b "second"
+
+ o 6:d41e714fe50d "merge"
+ |\
+ | o 5:13207e5a10d9 "new head"
+ | |
+ o | 4:bbe44766e73d "new branch"
+ |/
+ o 3:10e46f2dcbf4 "no user, no domain"
+ |
+ o 2:97054abb4ab8 "no person"
+ |
+ o 1:b608e9d1a3f0 "other 1"
+ |
+ o 0:1e4e1b8f71e0 "line 1"
+
+ $ hg log -T '{onelinesummary}' -r 0 \
+ > --config command-templates.oneline-summary='{rev} - {desc}'
+ 0 - line 1 (no-eol)
Keys work:
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -634,6 +634,19 @@
return b''
+ at templatekeyword(b'onelinesummary', requires={b'ui', b'ctx'})
+def showonelinesummary(context, mapping):
+ """String. A one-line summary for the ctx (not including trailing newline).
+ The default template be overridden in command-templates.oneline-summary."""
+ # Avoid cycle:
+ # mercurial.cmdutil -> mercurial.templatekw -> mercurial.cmdutil
+ from . import cmdutil
+
+ ui = context.resource(mapping, b'ui')
+ ctx = context.resource(mapping, b'ctx')
+ return cmdutil.format_changeset_summary(ui, ctx)
+
+
@templatekeyword(b'path', requires={b'fctx'})
def showpath(context, mapping):
"""String. Repository-absolute path of the current file. (EXPERIMENTAL)"""
To: martinvonz, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20201118/7e95f13a/attachment-0002.html>
More information about the Mercurial-patches
mailing list