[PATCH 2 of 4] revset: add a 'descend' argument to followlines to return descendants

Yuya Nishihara yuya at tcha.org
Thu Apr 13 11:55:24 EDT 2017


On Tue, 11 Apr 2017 15:09:09 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1484555087 -3600
> #      Mon Jan 16 09:24:47 2017 +0100
> # Node ID 182fa6fb647dcfac8ebcc6a3a6646be43122b2b9
> # Parent  ce5fd23baea30c83d668a8680d2b6ed0ef7baa14
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> #              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 182fa6fb647d
> revset: add a 'descend' argument to followlines to return descendants

> - at predicate('followlines(file, fromline:toline[, startrev=.])', safe=True)
> + at predicate('followlines(file, fromline:toline[, startrev=., descend=False])',
> +           safe=True)
>  def followlines(repo, subset, x):
>      """Changesets modifying `file` in line range ('fromline', 'toline').
>  
>      Line range corresponds to 'file' content at 'startrev' and should hence be
>      consistent with file size. If startrev is not specified, working directory's
>      parent is used.
> +
> +    By default, ancestors of 'startrev' are returned. If 'descend' is True,
> +    descendants of 'startrev' are returned though renames are (currently) not
> +    followed in this direction.
>      """
>      from . import context  # avoid circular import issues
>  
> -    args = getargsdict(x, 'followlines', 'file *lines startrev')
> +    args = getargsdict(x, 'followlines', 'file *lines startrev descend')
>      if len(args['lines']) != 1:
>          raise error.ParseError(_("followlines requires a line range"))
>  
> @@ -939,9 +944,17 @@ def followlines(repo, subset, x):
>      fromline, toline = util.processlinerange(fromline, toline)
>  
>      fctx = repo[rev].filectx(fname)
> -    revs = (c.rev() for c, _linerange
> -            in context.blockancestors(fctx, fromline, toline))
> -    return subset & generatorset(revs, iterasc=False)
> +    if args.get('descend', False):

args['descend'] isn't a boolean but a parsed tree. I'll send a follow up this
weekend.


More information about the Mercurial-devel mailing list