Patchwork D6421: copies: avoid unnecessary copying of copy dict

login
register
mail settings
Submitter phabricator
Date June 17, 2019, 5:33 p.m.
Message ID <ae4894831c75520010528690830a93f7@localhost.localdomain>
Download mbox | patch
Permalink /patch/40551/
State Not Applicable
Headers show

Comments

phabricator - June 17, 2019, 5:33 p.m.
Closed by commit rHG5ceb91136ebe: copies: avoid unnecessary copying of copy dict (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6421?vs=15219&id=15545

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6421/new/

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -297,7 +297,7 @@ 
         if r == b.rev():
             _filter(a, b, copies)
             return copies
-        for c in children[r]:
+        for i, c in enumerate(children[r]):
             childctx = repo[c]
             if r == childctx.p1().rev():
                 parent = 1
@@ -309,7 +309,13 @@ 
             if not match.always():
                 childcopies = {dst: src for dst, src in childcopies.items()
                                if match(dst)}
-            childcopies = _chain(copies, childcopies)
+            # Copy the dict only if later iterations will also need it
+            if i != len(children[r]) - 1:
+                copies = copies.copy()
+            if childcopies:
+                childcopies = _chain(copies, childcopies)
+            else:
+                childcopies = copies
             for f in childctx.filesremoved():
                 if f in childcopies:
                     del childcopies[f]