D1695: copies: always respect matcher arg to _forwardcopies()

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Dec 15 01:02:03 UTC 2017


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The function would ignore the matcher if the dirstate copies were
  requested. It doesn't matter in practice because all callers used the
  returned map only for looking up specific files from and those files
  had already been filtered by the matcher (AFACT). Still, it's a little
  confusing, so let's make it clearer by respecting the matcher in this
  case too.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1695

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -139,11 +139,11 @@
         if limit >= 0 and f.linkrev() < limit and f.rev() < limit:
             return None
 
-def _dirstatecopies(d):
+def _dirstatecopies(d, match=None):
     ds = d._repo.dirstate
     c = ds.copies().copy()
     for k in list(c):
-        if ds[k] not in 'anm':
+        if ds[k] not in 'anm' or (match and not match(k)):
             del c[k]
     return c
 
@@ -166,7 +166,7 @@
         b = w.p1()
         if a == b:
             # short-circuit to avoid issues with merge states
-            return _dirstatecopies(w)
+            return _dirstatecopies(w, match)
 
     # files might have to be traced back to the fctx parent of the last
     # one-side-only changeset, but not further back than that
@@ -202,7 +202,7 @@
 
     # combine copies from dirstate if necessary
     if w is not None:
-        cm = _chain(a, w, cm, _dirstatecopies(w))
+        cm = _chain(a, w, cm, _dirstatecopies(w, match))
 
     return cm
 



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list