[PATCH 5 of 6] templater: consistently join() string-like object per character (BC)
Yuya Nishihara
yuya at tcha.org
Mon Jun 4 09:10:12 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1524298511 -32400
# Sat Apr 21 17:15:11 2018 +0900
# Node ID 481042701ff874ba7b8c6af18e4ef71f87f35c65
# Parent 15bb4fc7c5d6190351bb891e29f612e749d1e2e5
templater: consistently join() string-like object per character (BC)
The old behavior was copied from join() of a lazy generator string, which
was unified to the behavior of join() of a byte string by the previous patch.
This patch fixes the mappable type to do the same.
diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py
--- a/mercurial/templateutil.py
+++ b/mercurial/templateutil.py
@@ -189,12 +189,8 @@ class mappable(wrapped):
yield self.tomap()
def join(self, context, mapping, sep):
- # TODO: just copies the old behavior where a value was a generator
- # yielding one item, but reconsider about it. join() over a string
- # has no consistent result because a string may be a bytes, or a
- # generator yielding an item, or a generator yielding multiple items.
- # Preserving all of the current behaviors wouldn't make any sense.
- return self.show(context, mapping)
+ w = makewrapped(context, mapping, self._value)
+ return w.join(context, mapping, sep)
def show(self, context, mapping):
# TODO: switch gen to (context, mapping) API?
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
@@ -3242,12 +3242,12 @@ Test new-style inline templating of non-
$ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}'
9:fbc7cd862e9c
-Test manifest/get() can be join()-ed as before, though it's silly:
-
- $ hg log -R latesttag -r tip -T '{join(manifest, "")}\n'
- 11:2bc6e9006ce2
- $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n'
- default
+Test manifest/get() can be join()-ed as string, though it's silly:
+
+ $ hg log -R latesttag -r tip -T '{join(manifest, ".")}\n'
+ 1.1.:.2.b.c.6.e.9.0.0.6.c.e.2
+ $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), ".")}\n'
+ d.e.f.a.u.l.t
Test join() over string
More information about the Mercurial-devel
mailing list