mercurial/copies.py
changeset 46061 e0313b0a6f7e
parent 46040 8d54944eaeb0
child 46110 2f357d053df2
--- a/mercurial/copies.py	Tue Dec 01 22:37:34 2020 +0100
+++ b/mercurial/copies.py	Thu Nov 12 15:54:10 2020 +0100
@@ -25,7 +25,10 @@
 
 from .utils import stringutil
 
-from .revlogutils import flagutil
+from .revlogutils import (
+    flagutil,
+    sidedata as sidedatamod,
+)
 
 rustmod = policy.importrust("copy_tracing")
 
@@ -175,7 +178,7 @@
     return cm
 
 
-def _revinfo_getter(repo):
+def _revinfo_getter(repo, match):
     """returns a function that returns the following data given a <rev>"
 
     * p1: revision number of first parent
@@ -215,20 +218,42 @@
     # time to save memory.
     merge_caches = {}
 
-    def revinfo(rev):
-        p1, p2 = parents(rev)
-        value = None
-        e = merge_caches.pop(rev, None)
-        if e is not None:
-            return e
-        changes = None
-        if flags(rev) & HASCOPIESINFO:
-            changes = changelogrevision(rev).changes
-        value = (p1, p2, changes)
-        if p1 != node.nullrev and p2 != node.nullrev:
-            # XXX some case we over cache, IGNORE
-            merge_caches[rev] = value
-        return value
+    alwaysmatch = match.always()
+
+    if rustmod is not None and alwaysmatch:
+
+        def revinfo(rev):
+            p1, p2 = parents(rev)
+            value = None
+            e = merge_caches.pop(rev, None)
+            if e is not None:
+                return e
+            if flags(rev) & HASCOPIESINFO:
+                raw = changelogrevision(rev)._sidedata.get(sidedatamod.SD_FILES)
+            else:
+                raw = None
+            value = (p1, p2, raw)
+            if p1 != node.nullrev and p2 != node.nullrev:
+                # XXX some case we over cache, IGNORE
+                merge_caches[rev] = value
+            return value
+
+    else:
+
+        def revinfo(rev):
+            p1, p2 = parents(rev)
+            value = None
+            e = merge_caches.pop(rev, None)
+            if e is not None:
+                return e
+            changes = None
+            if flags(rev) & HASCOPIESINFO:
+                changes = changelogrevision(rev).changes
+            value = (p1, p2, changes)
+            if p1 != node.nullrev and p2 != node.nullrev:
+                # XXX some case we over cache, IGNORE
+                merge_caches[rev] = value
+            return value
 
     return revinfo
 
@@ -289,7 +314,7 @@
     revs = sorted(iterrevs)
 
     if repo.filecopiesmode == b'changeset-sidedata':
-        revinfo = _revinfo_getter(repo)
+        revinfo = _revinfo_getter(repo, match)
         return _combine_changeset_copies(
             revs, children, b.rev(), revinfo, match, isancestor
         )