Patchwork [1,of,2,STABLE] templatekw: fix join format of revset() function

login
register
mail settings
Submitter Yuya Nishihara
Date July 22, 2016, 2:55 p.m.
Message ID <c95239e03e854d54ad00.1469199306@mimosa>
Download mbox | patch
Permalink /patch/15971/
State Accepted
Headers show

Comments

Yuya Nishihara - July 22, 2016, 2:55 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1469192446 -32400
#      Fri Jul 22 22:00:46 2016 +0900
# Branch stable
# Node ID c95239e03e854d54ad0035490392c4c39e28a742
# Parent  d3df009ab1175a6792549b51ae66486dd98f398b
templatekw: fix join format of revset() function

It's been broken since e4609ec959f8, which made makemap() return a dict of
multiple keywords. Because the default joinfmt() randomly picks one item
from a dict, we have to make revset() select d[name] explicitly.
Sean Farley - July 22, 2016, 7:21 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1469192446 -32400
> #      Fri Jul 22 22:00:46 2016 +0900
> # Branch stable
> # Node ID c95239e03e854d54ad0035490392c4c39e28a742
> # Parent  d3df009ab1175a6792549b51ae66486dd98f398b
> templatekw: fix join format of revset() function
>
> It's been broken since e4609ec959f8, which made makemap() return a dict of
> multiple keywords. Because the default joinfmt() randomly picks one item
> from a dict, we have to make revset() select d[name] explicitly.

Ah! This is why that didn't work for me. Patch looks good to me.
Augie Fackler - July 25, 2016, 12:51 p.m.
On Fri, Jul 22, 2016 at 12:21:38PM -0700, Sean Farley wrote:
> Yuya Nishihara <yuya@tcha.org> writes:
>
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1469192446 -32400
> > #      Fri Jul 22 22:00:46 2016 +0900
> > # Branch stable
> > # Node ID c95239e03e854d54ad0035490392c4c39e28a742
> > # Parent  d3df009ab1175a6792549b51ae66486dd98f398b
> > templatekw: fix join format of revset() function
> >
> > It's been broken since e4609ec959f8, which made makemap() return a dict of
> > multiple keywords. Because the default joinfmt() randomly picks one item
> > from a dict, we have to make revset() select d[name] explicitly.
>
> Ah! This is why that didn't work for me. Patch looks good to me.

Queued, thanks

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -547,7 +547,8 @@  def showrevslist(name, revs, **args):
     revs = [str(r) for r in revs]  # ifcontains() needs a list of str
     f = _showlist(name, revs, **args)
     return _hybrid(f, revs,
-                   lambda x: {name: x, 'ctx': repo[int(x)], 'revcache': {}})
+                   lambda x: {name: x, 'ctx': repo[int(x)], 'revcache': {}},
+                   lambda d: d[name])
 
 @templatekeyword('subrepos')
 def showsubrepos(**args):
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -3433,6 +3433,11 @@  a revset item must be evaluated as an in
   $ hg log -l 1 -T '{revset("%s", "null") % "{rev}:{node|short}"}\n'
   -1:000000000000
 
+join() should pick '{rev}' from revset items:
+
+  $ hg log -R ../a -T '{join(revset("parents(%d)", rev), ", ")}\n' -r6
+  4, 5
+
 Test active bookmark templating
 
   $ hg book foo