[PATCH 8 of 8] fileset: add a 'status(...)' predicate to control evaluation context

Yuya Nishihara yuya at tcha.org
Sun Mar 5 06:49:32 EST 2017


On Fri, 03 Mar 2017 14:40:45 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1488546500 -3600
> #      Fri Mar 03 14:08:20 2017 +0100
> # Node ID 3e95bf7ed38189f6f56de89571fffc667280bb56
> # Parent  9d6e733046b9aa7e2ded8c4207625fedcc2a8c04
> # EXP-Topic filesetrev-func
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 3e95bf7ed381
> fileset: add a 'status(...)' predicate to control evaluation context

The series looks generally good, but I don't queue as the first half was
originally written by me. Thanks for bringing my hack into production.

> --- a/mercurial/fileset.py
> +++ b/mercurial/fileset.py
> @@ -463,6 +463,25 @@ def revs(mctx, x):
>                  result.append(f)
>      return result
>  
> + at predicate('status(base, rev, pattern)')
> +def status(mctx, x):
> +    """``status(base, rev, revspec)``
> +
> +    Evaluate predicate using status change between ``base`` and
> +    ``rev``. Examples:
> +
> +    - ``status(3, 7, added())`` - matches files added from "3" to "7"
> +    """
> +    repo = mctx.ctx.repo()
> +    # i18n: "status" is a keyword
> +    b, r, x = getargs(x, 3, 3, _("status takes three arguments"))
> +    # i18n: "status" is a keyword
> +    baserevspec = getstring(b, _("first argument to revs must be a revision"))
> +    revspec = getstring(r, _("second argument to revs must be a revision"))

s/revs/status/

> +    basectx = scmutil.revsingle(repo, baserevspec)
> +    ctx = scmutil.revsingle(repo, revspec)

Perhaps it's better to reject an empty revspec string.

And I slightly prefer picking the first rev for basectx just like
revset.rangeset() would do.


More information about the Mercurial-devel mailing list