[PATCH 1 of 3] templatekw: reference predecessor node id as {node} in map operation

Yuya Nishihara yuya at tcha.org
Tue Jun 20 08:13:18 EDT 2017


On Tue, 20 Jun 2017 01:37:26 +0200, Pierre-Yves David wrote:
> On 06/19/2017 11:24 PM, Martin von Zweigbergk via Mercurial-devel wrote:
> > On Fri, Jun 16, 2017 at 10:02 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> >> # HG changeset patch
> >> # User Yuya Nishihara <yuya at tcha.org>
> >> # Date 1497673083 -32400
> >> #      Sat Jun 17 13:18:03 2017 +0900
> >> # Node ID 89557eb72b36450b6833ee04673a131b063c77d5
> >> # Parent  9d472b219fb07e011c7a6255c5be47e6fc66229c
> >> templatekw: reference predecessor node id as {node} in map operation
> >
> > Queued this series, thanks.
> >
> >>
> >> More predecessor-depending values will be populated by the next patch.
> >>
> >> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
> >> --- a/mercurial/templatekw.py
> >> +++ b/mercurial/templatekw.py
> >> @@ -568,8 +568,8 @@ def showpredecessors(repo, ctx, **args):
> >>      predecessors = sorted(obsutil.closestpredecessors(repo, ctx.node()))
> >>      predecessors = map(hex, predecessors)
> >>
> >> -    return _hybrid(None, predecessors, lambda x: {'predecessor': x},
> >> -                   lambda d: d['predecessor'][:12])
> >> +    return _hybrid(None, predecessors, lambda x: {'node': x},
> >> +                   lambda d: d['node'][:12])
> >>
> >>  @templatekeyword('p1rev')
> >>  def showp1rev(repo, ctx, templ, **args):
> >> diff --git a/tests/test-obsmarker-template.t b/tests/test-obsmarker-template.t
> >> --- a/tests/test-obsmarker-template.t
> >> +++ b/tests/test-obsmarker-template.t
> >> @@ -15,7 +15,8 @@ Global setup
> >>    > tlog = log -G -T '{node|short}\
> >>    >     {if(predecessors, "\n  Predecessors: {predecessors}")}\
> >>    >     {if(predecessors, "\n  semi-colon: {join(predecessors, "; ")}")}\
> >
> > You know the templater much better than I do, but do the above still
> > add any value to the test after we have the newly added?
> 
> I think so, from what I understand:
> 
> The above test the default representation and the default representation 
> of the subitem.
> 
> The one below test mapping withing the subitem (instead of the default 
> output of the subitem)

They all go different paths, so yes. But do we need to test all of them for
all of predecessors conditions? Maybe no. I just followed the existing tests.


More information about the Mercurial-devel mailing list