diff mercurial/templatekw.py @ 40526:539efc88513b

templatekw: add p1/p2 keywords which switches the current ctx This is just an example of mappingdict. I have no idea what should be displayed as {p1|json}. Currently it is an empty dict since {'ctx'} isn't displayable, which is clearly useless and should be changed later.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 26 Oct 2018 21:43:20 +0900
parents 2891ee3fcb86
children 592feb3f88b1
line wrap: on
line diff
--- a/mercurial/templatekw.py	Fri Oct 19 21:11:30 2018 +0900
+++ b/mercurial/templatekw.py	Fri Oct 26 21:43:20 2018 +0900
@@ -691,6 +691,20 @@
 
     return templateutil.mappinglist(data)
 
+@templatekeyword('p1', requires={'ctx'})
+def showp1(context, mapping):
+    """Changeset. The changeset's first parent. ``{p1.rev}`` for the revision
+    number, and ``{p1.node}`` for the identification hash."""
+    ctx = context.resource(mapping, 'ctx')
+    return templateutil.mappingdict({'ctx': ctx.p1()}, tmpl=_changeidtmpl)
+
+@templatekeyword('p2', requires={'ctx'})
+def showp2(context, mapping):
+    """Changeset. The changeset's second parent. ``{p2.rev}`` for the revision
+    number, and ``{p2.node}`` for the identification hash."""
+    ctx = context.resource(mapping, 'ctx')
+    return templateutil.mappingdict({'ctx': ctx.p2()}, tmpl=_changeidtmpl)
+
 @templatekeyword('p1rev', requires={'ctx'})
 def showp1rev(context, mapping):
     """Integer. The repository-local revision number of the changeset's