[PATCH 1 of 2] - Add template keyword of 'children'

Jason Harris jason at jasonfharris.com
Sat Jul 3 01:48:10 CDT 2010


# HG changeset patch
# User jfh <jason at jasonfharris.com>
# Date 1278127456 -7200
# Node ID fd099575be1833727adb48029d6f10fb1f35e11c
# Parent  48e549d7c6ae471e53806c75f3ed16f4f706234a
- Add template keyword of 'children'.
- This allows things like
    'hg log --rev ... --template "{children} "'
 to work correctly.
- The template argument 'parents' is already present and this just provides the
 complimentary template keyword.

diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt
--- a/mercurial/help/templates.txt
+++ b/mercurial/help/templates.txt
@@ -28,6 +28,8 @@
:branches: String. The name of the branch on which the changeset was
    committed. Will be empty if the branch name was default.

+:children: List of strings. The children of the changeset.
+
:date: Date information. The date when the changeset was committed.

:desc: String. The text of the changeset description.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -151,6 +151,13 @@
        branch = encoding.tolocal(branch)
        return showlist('branch', [branch], plural='branches', **args)

+def showchildren(**args):
+    def revhex(ctx):
+        return '%d:%s' % (cctx.rev(), cctx.hex()[:12])
+    ctx = args['ctx']
+    childrevs = [revhex(ctx) for cctx in ctx.children()]
+    return showlist('children', childrevs, **args)
+
def showdate(repo, ctx, templ, **args):
    return ctx.date()

@@ -245,6 +252,7 @@
keywords = {
    'author': showauthor,
    'branches': showbranches,
+    'children': showchildren,
    'date': showdate,
    'desc': showdescription,
    'diffstat': showdiffstat,




More information about the Mercurial-devel mailing list