[PATCH 2 of 3] revset: implement copies and renames for checkstatus

Martin von Zweigbergk martinvonz at google.com
Fri Apr 5 21:34:52 EDT 2019


On Fri, Apr 5, 2019, 12:30 Jordi GutiƩrrez Hermoso <jordigh at octave.org>
wrote:

> # HG changeset patch
> # User Jordi GutiƩrrez Hermoso <jordigh at octave.org>
> # Date 1554489104 14400
> #      Fri Apr 05 14:31:44 2019 -0400
> # Node ID 4baa10f1f44a8e427f49fa4f4d8d29552c2a1a65
> # Parent  9fcb915a73b83547921aaa13584c88cb99c6aee7
> revset: implement copies and renames for checkstatus
>
> Determining when a file is a copy is tricky and isn't handled by the
> normal status functions, so thankfully we can offload that work to
> the copies module, just like the status command itself does.
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -11,6 +11,7 @@ import re
>
>  from .i18n import _
>  from . import (
> +    copies as copiesmod,
>      dagop,
>      destutil,
>      diffutil,
> @@ -603,6 +604,8 @@ def checkstatus(repo, subset, pat, field
>      0: modified
>      1: added
>      2: removed
> +    3: copied (not renamed, i.e. source not removed)
> +    4: renamed (not copied, i..e source removed)
>

Misplaced '.' (and/or 'e' :) ) in "i.e."

     """
>      hasset = matchmod.patkind(pat) == 'set'
>
> @@ -624,7 +627,18 @@ def checkstatus(repo, subset, pat, field
>                      break
>              else:
>                  return False
> -        files = repo.status(c.p1().node(), c.node())[field]
> +        p1 = c.p1()
> +        status = repo.status(p1.node(), c.node())
> +        if field == 3:
> +            copymap = copiesmod.pathcopies(p1, c, m)
> +            removed = status[2]
>

"status.removed" is easier to read

+            files = [dest for (dest, src) in copymap.items() if src not in
> removed]
> +        elif field == 4:
> +            copymap = copiesmod.pathcopies(p1, c, m)
> +            removed = status[2]
> +            files = [dest for (dest, src) in copymap.items() if src in
> removed]
> +        else:
> +            files = status[field]
>          if fname is not None:
>              if fname in files:
>                  return True
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20190405/beca8246/attachment.html>


More information about the Mercurial-devel mailing list