[PATCH 4 of 8] templatekw: fix scope of peerpath url bound to generator

Yuya Nishihara yuya at tcha.org
Fri Oct 6 12:05:54 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1505746145 -32400
#      Mon Sep 18 23:49:05 2017 +0900
# Node ID 3a85ee1cfabde421202ea11c482c15bc0c986e5d
# Parent  bedf989f7037ebdd007121a534ba92c91e25e574
templatekw: fix scope of peerpath url bound to generator

I had to explicitly bind 'd' to the generator. Otherwise, the last 'd' would
be used.

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -663,9 +663,9 @@ def showpeerpaths(repo, **args):
         d = util.sortdict()
         d['url'] = p.rawloc
         d.update((o, v) for o, v in sorted(p.suboptions.iteritems()))
-        def f():
+        def f(d):
             yield d['url']
-        paths[k] = hybriddict(d, gen=f())
+        paths[k] = hybriddict(d, gen=f(d))
 
     # no hybriddict() since d['path'] can't be formatted as a string. perhaps
     # hybriddict() should call templatefilters.stringify(d[value]).
diff --git a/tests/test-paths.t b/tests/test-paths.t
--- a/tests/test-paths.t
+++ b/tests/test-paths.t
@@ -94,10 +94,10 @@ log template:
   dupe=$TESTTMP/b#tip (glob)
   expand=$TESTTMP/a/$SOMETHING/bar (glob)
   $ hg log -rnull -T '{peerpaths % "{name}: {path}\n"}'
-  dupe: $TESTTMP/a/$SOMETHING/bar (glob)
+  dupe: $TESTTMP/b#tip (glob)
   expand: $TESTTMP/a/$SOMETHING/bar (glob)
   $ hg log -rnull -T '{get(peerpaths, "dupe")}\n'
-  $TESTTMP/a/$SOMETHING/bar (glob)
+  $TESTTMP/b#tip (glob)
 
  (but a path is actually a dict of url and sub-options)
 


More information about the Mercurial-devel mailing list