mercurial/templatekw.py
changeset 17355 c25531ed58b0
parent 17187 293dd81e4601
child 17358 2917f82f6040
--- a/mercurial/templatekw.py	Mon Aug 13 11:49:55 2012 -0700
+++ b/mercurial/templatekw.py	Tue Jul 10 08:43:32 2012 -0700
@@ -275,6 +275,36 @@
     """
     return ctx.hex()
 
+def showparent1(repo, ctx, templ, **args):
+    """:parent1: Integer. The repository-local revision number of the
+    changeset's first parent, or -1 if the changeset has no parents."""
+    return ctx.parents()[0].rev()
+
+def showparent2(repo, ctx, templ, **args):
+    """:parent2: Integer. The repository-local revision number of the
+    changeset's second parent, or -1 if the changeset has no second parent."""
+    parents = ctx.parents()
+    if len(parents) > 1:
+        return parents[1].rev()
+    else:
+        return repo['null'].rev()
+
+def showparent1node(repo, ctx, templ, **args):
+    """:parent1node: String. The identification hash of the changeset's
+    first parent, as a 40 digit hexadecimal string. If the changeset has no
+    parents, all digits are 0."""
+    return ctx.parents()[0].hex()
+
+def showparent2node(repo, ctx, templ, **args):
+    """:parent2node: String. The identification hash of the changeset's
+    second parent, as a 40 digit hexadecimal string. If the changeset has no
+    second parent, all digits are 0."""
+    parents = ctx.parents()
+    if len(parents) > 1:
+        return parents[1].hex()
+    else:
+        return repo['null'].hex()
+
 def showphase(repo, ctx, templ, **args):
     """:phase: String. The changeset phase name."""
     return ctx.phasestr()
@@ -320,6 +350,10 @@
     'latesttagdistance': showlatesttagdistance,
     'manifest': showmanifest,
     'node': shownode,
+    'parent1': showparent1,
+    'parent1node': showparent1node,
+    'parent2': showparent2,
+    'parent2node': showparent2node,
     'phase': showphase,
     'phaseidx': showphaseidx,
     'rev': showrev,