[PATCH 3 of 3] revset: two new revsets, copies and renames

Yuya Nishihara yuya at tcha.org
Sat Apr 6 20:48:52 EDT 2019


On Fri, 05 Apr 2019 14:42:39 -0400, Jordi GutiƩrrez Hermoso wrote:
> # HG changeset patch
> # User Jordi GutiƩrrez Hermoso <jordigh at octave.org>
> # Date 1554489566 14400
> #      Fri Apr 05 14:39:26 2019 -0400
> # Node ID cf6a3da4082569df7b5dd83ab61fcbedc70839f1
> # Parent  4baa10f1f44a8e427f49fa4f4d8d29552c2a1a65
> revset: two new revsets, copies and renames
> 
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -757,6 +757,21 @@ def converted(repo, subset, x):
>      return subset.filter(lambda r: _matchvalue(r),
>                           condrepr=('<converted %r>', rev))
>  
> + at predicate('copies(pattern)', safe=True, weight=30)
> +def copies(repo, subset, x):
> +    """Changesets which added files matching pattern via copying. This
> +    excludes renames, which are copies where the original file was
> +    removed.
> +
> +    The pattern without explicit kind like ``glob:`` is expected to be
> +    relative to the current directory and match against a file or a
> +    directory.
> +
> +    """
> +    # i18n: "removes" is a keyword
> +    pat = getstring(x, _("copies requires a pattern"))
> +    return checkstatus(repo, subset, pat, 3)
> +
>  @predicate('date(interval)', safe=True, weight=10)
>  def date(repo, subset, x):
>      """Changesets within the interval, see :hg:`help dates`.
> @@ -1802,6 +1817,18 @@ def public(repo, subset, x):
>      getargs(x, 0, 0, _("public takes no arguments"))
>      return _phase(repo, subset, phases.public)
>  
> + at predicate('renames(pattern)', safe=True, weight=30)
> +def renames(repo, subset, x):
> +    """Changesets which added files matching pattern via a rename.
> +
> +    The pattern without explicit kind like ``glob:`` is expected to be
> +    relative to the current directory and match against a file or a
> +    directory.
> +    """
> +    # i18n: "removes" is a keyword
> +    pat = getstring(x, _("renames requires a pattern"))
> +    return checkstatus(repo, subset, pat, 4)

So they are quite similar to -r 'file("set:copied()")', and we do include
renames in copies in general.

I think these predicates are useful, but it's confusing to handle copies
and renames separately only in revset.


More information about the Mercurial-devel mailing list