changeset 2528:8ac4ceac5d96

template: fix successors and precursors templates In mercurial 4.1-, the gen argument is expected to be an iterator and not an iterable, fix successors and precursors templates.
author Boris Feld <boris.feld@octobus.net>
date Tue, 30 May 2017 22:09:28 +0200
parents 7f280af7a89b
children 537058b433ef
files hgext3rd/evolve/templatekw.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/templatekw.py	Tue May 30 19:59:57 2017 +0200
+++ b/hgext3rd/evolve/templatekw.py	Tue May 30 22:09:28 2017 +0200
@@ -69,10 +69,13 @@
     displayed
     """
     precursors = sorted(closestprecursors(repo, ctx.node()))
+
     # <= hg-4.1 requires an explicite gen.
     # we can use None once the support is dropped
-    gen = " ".join(map(node.short, precursors))
-    return templatekw._hybrid(gen, precursors, lambda x: {'precursor': x},
+    #
+    # They also requires an iterator instead of an iterable.
+    gen = iter(" ".join(map(node.short, precursors)))
+    return templatekw._hybrid(gen.__iter__(), precursors, lambda x: {'precursor': x},
                               lambda d: "%s" % node.short(d['precursor']))
 
 def closestsuccessors(repo, nodeid):
@@ -95,12 +98,12 @@
     for ss in ssets:
         subgen = '[%s]' % ', '.join(map(node.short, ss))
         gen.append(subgen)
-        h = templatekw._hybrid(subgen, ss, lambda x: {'successor': x},
+        h = templatekw._hybrid(iter(subgen), ss, lambda x: {'successor': x},
                                lambda d: "%s" % d["successor"])
         data.append(h)
 
     gen = ', '.join(gen)
-    return templatekw._hybrid(gen, data, lambda x: {'successorset': x},
+    return templatekw._hybrid(iter(gen), data, lambda x: {'successorset': x},
                               lambda d: d["successorset"])
 
 @eh.templatekw("obsfate_quiet")