[PATCH 6 of 8] fileset: add revs(revs, fileset) to evaluate set in working directory

Yuya Nishihara yuya at tcha.org
Sun Mar 5 06:33:36 EST 2017


On Fri, 03 Mar 2017 14:40:43 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1488541496 -3600
> #      Fri Mar 03 12:44:56 2017 +0100
> # Node ID 2d0e9bb0f121ebbd041abf2ad121a18f200f6206
> # Parent  a9e4ff8cb089e0c761c2cf2f87367fd5759306bd
> # 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 2d0e9bb0f121
> fileset: add revs(revs, fileset) to evaluate set in working directory
> 
> Unlike other functions, "revs()" does not select files but switches the
> evaluation context. This allow to match file with property in another revision
> that the one currently evaluated.
> 
> This changeset is based on work from Yuya Nishihara.

Thanks for adding extended tests I didn't write at all.

> diff --git a/mercurial/fileset.py b/mercurial/fileset.py
> --- a/mercurial/fileset.py
> +++ b/mercurial/fileset.py
> @@ -15,6 +15,7 @@ from . import (
>      merge,
>      parser,
>      registrar,
> +    scmutil,
>      util,
>  )
>  
> @@ -438,6 +439,30 @@ def copied(mctx, x):
>              s.append(f)
>      return s
>  
> + at predicate('revs(revs, pattern)')
> +def revs(mctx, x):
> +    """``revs(set, revspec)``
> +
> +    Evaluate set in the specified revisions. If the revset match multiple revs,
> +    this will return file matching pattern in any of the revision.
> +    """
> +    # i18n: "revs" is a keyword
> +    r, x = getargs(x, 2, 2, _("revs takes two arguments"))
> +    # i18n: "revs" is a keyword
> +    revspec = getstring(r, _("first argument to revs must be a revision"))
> +    repo = mctx.ctx.repo()
> +    revs = scmutil.revrange(repo, [revspec])

Nit: the dependency on scmutil can be avoided by using repo.anyrevs(), but that
wouldn't make sense as the last patch includes the call of scmutil.revsingle().


More information about the Mercurial-devel mailing list