Patchwork D6564: copies: avoid reusing the same variable for two different copy dicts

login
register
mail settings
Submitter phabricator
Date June 22, 2019, 2:26 p.m.
Message ID <a251b0b185164ebe9badb60f49a44eef@localhost.localdomain>
Download mbox | patch
Permalink /patch/40647/
State Not Applicable
Headers show

Comments

phabricator - June 22, 2019, 2:26 p.m.
Closed by commit rHGe7c55e24d6bf: copies: avoid reusing the same variable for two different copy dicts (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6564?vs=15628&id=15632

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

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -312,15 +312,15 @@ 
                                if match(dst)}
             # 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)
+                newcopies = copies.copy()
             else:
-                childcopies = copies
+                newcopies = copies
+            if childcopies:
+                newcopies = _chain(newcopies, childcopies)
             for f in childctx.filesremoved():
-                if f in childcopies:
-                    del childcopies[f]
-            heapq.heappush(work, (c, parent, childcopies))
+                if f in newcopies:
+                    del newcopies[f]
+            heapq.heappush(work, (c, parent, newcopies))
     assert False
 
 def _forwardcopies(a, b, match=None):