Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templatekw.py @ 45676:f95b23283760
templatekw: make {successorssets} always return a list (issue6342)
Previously, {successorssets} returns an empty string instead of an empty list
for a non-obsolete changeset. The changing type of the JSON output makes it
hard to consume from statically-typed languages.
Differential Revision: https://phab.mercurial-scm.org/D9158
author | Aay Jay Chan <aayjaychan@itopia.com.hk> |
---|---|
date | Wed, 07 Oct 2020 00:45:41 +0800 |
parents | 85b03b1e4715 |
children | f67741e8264b |
line wrap: on
line diff
--- a/mercurial/templatekw.py Wed Oct 07 00:39:52 2020 +0800 +++ b/mercurial/templatekw.py Wed Oct 07 00:45:41 2020 +0800 @@ -712,21 +712,20 @@ while also diverged into ctx3. (EXPERIMENTAL)""" repo = context.resource(mapping, b'repo') ctx = context.resource(mapping, b'ctx') - if not ctx.obsolete(): - return b'' + data = [] - ssets = obsutil.successorssets(repo, ctx.node(), closest=True) - ssets = [[hex(n) for n in ss] for ss in ssets] + if ctx.obsolete(): + ssets = obsutil.successorssets(repo, ctx.node(), closest=True) + ssets = [[hex(n) for n in ss] for ss in ssets] - data = [] - for ss in ssets: - h = _hybrid( - None, - ss, - lambda x: {b'ctx': repo[x]}, - lambda x: scmutil.formatchangeid(repo[x]), - ) - data.append(h) + for ss in ssets: + h = _hybrid( + None, + ss, + lambda x: {b'ctx': repo[x]}, + lambda x: scmutil.formatchangeid(repo[x]), + ) + data.append(h) # Format the successorssets def render(d):