[PATCH] templatekw: add parent1, parent1node, parent2, parent2node keywords

Greg Ward greg at gerg.ca
Fri Aug 10 19:24:38 CDT 2012


On 09 August 2012, Evan Priestley said:
> # HG changeset patch
> # User epriestley <hg at yghe.net>
> # Date 1341935012 25200
> # Node ID 00ab172dc658f156ef0aef0c386c896691b68ab7
> # Parent  2e13c1bd34dc6afda8fc7cfa22a8cd658276724f
> templatekw: add p1rev, p1node, p2rev, p2node keywords

Getting very close -- don't give up now!

[...]
>      return ctx.hex()
>  
> +def showp1rev(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.p1().rev()
> +
> +def showp2rev(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."""
> +    return ctx.p2().rev()

The docstring needs to match the name in the keywords dict: p1rev,
p2rev, etc. not parent1, parent2.

> +def showp1node(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.p1().hex()
> +
> +def showp2node(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."""
> +    return ctx.p2().hex()

Same here.

> diff -r 2e13c1bd34dc -r 00ab172dc658 tests/test-template-engine.t
> --- a/tests/test-template-engine.t	Wed Jul 04 17:29:49 2012 +0200
> +++ b/tests/test-template-engine.t	Tue Jul 10 08:43:32 2012 -0700
> @@ -36,4 +36,12 @@
>    $ hg log --style=./mymap
>    0 97e5f848f0936960273bbf75be6388cd0350a32b test
>  
> +  $ cat > changeset.txt << EOF
> +  > {{p1rev}} {{p1node}} {{p2rev}} {{p2node}}
> +  > EOF
> +  $ hg ci -Ama
> +  $ hg log --style=./mymap
> +  0 97e5f848f0936960273bbf75be6388cd0350a32b -1 0000000000000000000000000000000000000000
> +  -1 0000000000000000000000000000000000000000 -1 0000000000000000000000000000000000000000
> +

I don't think this is the right place to test this feature. This test
appears to test that extensions can override Mercurial's template
syntax, which is a pretty obscure feature. Looks like most tests of
the templating system are in test-command-template.t. There should be
no need to commit anything new -- just exercise the new keywords in
the changesets already created in that test script.

       Greg
-- 
Greg Ward                                http://www.gerg.ca/
It takes a scary kind of illness / To design a place like this for pay
Downtown's an endless generic mall / Of video games and fast food chains
    -- Dead Kennedys


More information about the Mercurial-devel mailing list