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

login
register
mail settings
Submitter phabricator
Date June 20, 2019, 11:15 p.m.
Message ID <differential-rev-PHID-DREV-hettwd7feihhofymr6qb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40636/
State Superseded
Headers show

Comments

phabricator - June 20, 2019, 11:15 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  "childcopies" is initally the copies the current changeset to one of
  its children and then we reassign it with the copies from the start of
  the chain to the child. Let's use different names for these two
  things.

REPOSITORY
  rHG Mercurial

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

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
@@ -302,15 +302,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):