[PATCH 2 of 3] revset: implement copies and renames for checkstatus
Yuya Nishihara
yuya at tcha.org
Sat Apr 6 20:55:23 EDT 2019
On Fri, 05 Apr 2019 14:42:38 -0400, Jordi GutiƩrrez Hermoso 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)
> """
> 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]
> + 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]
Maybe we can turn the field argument into a lambda function. It doesn't make
sense to introduce pseudo indices for copies and renames.
More information about the Mercurial-devel
mailing list