On Wed, 2017-08-23 at 00:02 +0900, Yuya Nishihara wrote:
> On Mon, 21 Aug 2017 10:43:58 +0200, Boris Feld wrote:
> > # HG changeset patch
> > # User Boris Feld <boris.f...@octobus.net>
> > # Date 1499088840 -7200
> > #      Mon Jul 03 15:34:00 2017 +0200
> > # Node ID 2fee3b06f7b09f35dcfa312b645cf94090c11fb9
> > # Parent  66a2b0407c8cffedfae4897bd7a2f0e2d6a22363
> > # EXP-Topic obsfatetemplate
> > template: compute user in obsfateusers
> > +def _successorsetusers(successorset, markers):
> > +    """ Returns a sorted list of markers users without duplicates
> > +    """
> > +    if not markers:
> > +        return {}
> > +
> > +    # Check that user is present in meta
> > +    markersmeta = [dict(m[3]) for m in markers]
> > +    users = set(meta.get('user') for meta in markersmeta if
> > meta.get('user'))
> > +
> > +    return {'users': sorted(users)}
> 
> [...]
> 
> > +@templatefunc('obsfateusers(successors, markers)')
> > +def obsfateusers(context, mapping, args):
> > +    """ Compute obsfate related information based on successors
> > and markers
> > +    """
> > +    successors = evalfuncarg(context, mapping, args[0])
> > +    markers = evalfuncarg(context, mapping, args[1])
> > +    data = obsutil._successorsetusers(successors, markers)
> > +
> > +    _hybrid = templatekw._hybrid
> > +
> > +    def makemap(x):
> > +        return x
> > +
> > +    def joinfmt(d):
> > +        return d
> > +
> > +    return _hybrid(None, [data], makemap, joinfmt)
> 
> Why isn't this a list of users, but a list of dict of list of users?

It was a artifact from the previous version of the series. It was meant
to permit this notation:

obsfateusers(successors, markers) % "{if(users, " by {join(users, ",
")}")}"

I've tried cleaning it, code is cleaner and the template is slighty
less clean now:

{if(obsfateusers(markers), " by {join(obsfateusers(markers), ", ")}")}
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to