[PATCH 1 of 2] templates: add whyunstable template keyword

Yuya Nishihara yuya at tcha.org
Sat Apr 14 08:03:23 EDT 2018


On Sat, 14 Apr 2018 19:43:15 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6 at dwimlabs.net>
> # Date 1522054812 -28800
> #      Mon Mar 26 17:00:12 2018 +0800
> # Node ID 987c05eac1801d0b919c874280d03f9e8cccb411
> # Parent  8bacc09814ba5500d15fb40c472e84cb95ae2f99
> templates: add whyunstable template keyword

Queued, thanks.

> + at templatekeyword('whyunstable', requires={'repo', 'ctx'})
> +def showwhyunstable(context, mapping):
> +    """List of dicts explaining all instabilities of a changeset.
> +    (EXPERIMENTAL)
> +    """
> +    repo = context.resource(mapping, 'repo')
> +    ctx = context.resource(mapping, 'ctx')
> +
> +    def formatnode(ctx):
> +        return ' %s (%s)' % (scmutil.formatchangeid(ctx), ctx.phasestr())

Nit: leading ' ' isn't nice when you join() the list.

> +    for entry in entries:
> +        if entry.get('divergentnodes'):
> +            dnodes = entry['divergentnodes']
> +            entry['divergentnodes'] = ''.join(formatnode(dnode)
> +                                              for dnode in dnodes)

Perhaps this can be a hybrid list. Can you send a follow up?

    _hybrid(None, [c.hex() for c in dnodes],
            lambda x: {'ctx': repo[x]},
            lambda x: formatnode(repo[c]))

(We don't have a wrapper for a list of ctx objects yet.)


More information about the Mercurial-devel mailing list