On Sat, 14 Apr 2018 21:49:17 +0900
Yuya Nishihara <y...@tcha.org> wrote:

> -class _siblings(object):
> -    def __init__(self, siblings=None, hiderev=None):
> -        if siblings is None:
> -            siblings = []
> -        self.siblings = [s for s in siblings if s.node() != nullid]
> -        if len(self.siblings) == 1 and self.siblings[0].rev() == hiderev:
> -            self.siblings = []
> -
> -    def __iter__(self):
> -        return _ctxsgen(self.siblings)
> -
> -    def __len__(self):
> -        return len(self.siblings)
> +def _siblings(siblings=None, hiderev=None):
> +    if siblings is None:
> +        siblings = []
> +    siblings = [s for s in siblings if s.node() != nullid]
> +    if len(siblings) == 1 and siblings[0].rev() == hiderev:
> +        siblings = []
> +    return templateutil.mappinggenerator(_ctxsgen, args=(siblings,))

One thing that this patch makes difficult to understand is how you can't
now say len(parents):

  TypeError: object of type 'mappinggenerator' has no len()

... but "{count(parents)}" in the templates works as expected, even
though count template filter simply does len(i).
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to