checkcopies: move 'movewithdir' initialisation right before its usage
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 11 Oct 2016 02:15:23 +0200
changeset 30183 0106f93ca1d5
parent 30182 144d8fe266d9
child 30184 7321c6b0c9fd
checkcopies: move 'movewithdir' initialisation right before its usage The 'movewithdir' had a lot of related logic all around the 'mergecopies'. However it is actually never containing anything until the very last loop in that function. We move the (simplified) variable definition there for clarity
mercurial/copies.py
--- a/mercurial/copies.py	Fri Oct 14 01:53:15 2016 +0200
+++ b/mercurial/copies.py	Tue Oct 11 02:15:23 2016 +0200
@@ -333,7 +333,6 @@
 
     # see _checkcopies documentation below for these dicts
     copy1, copy2 = {}, {}
-    movewithdir1, movewithdir2 = {}, {}
     fullcopy1, fullcopy2 = {}, {}
     diverge = {}
 
@@ -351,7 +350,6 @@
         _checkcopies(c2, f, m2, m1, ca, limit, diverge, copy2, fullcopy2)
 
     copy = dict(copy1.items() + copy2.items())
-    movewithdir = dict(movewithdir1.items() + movewithdir2.items())
     fullcopy = dict(fullcopy1.items() + fullcopy2.items())
 
     renamedelete = {}
@@ -395,7 +393,7 @@
     del divergeset
 
     if not fullcopy:
-        return copy, movewithdir, diverge, renamedelete
+        return copy, {}, diverge, renamedelete
 
     repo.ui.debug("  checking for directory renames\n")
 
@@ -433,12 +431,13 @@
     del d1, d2, invalid
 
     if not dirmove:
-        return copy, movewithdir, diverge, renamedelete
+        return copy, {}, diverge, renamedelete
 
     for d in dirmove:
         repo.ui.debug("   discovered dir src: '%s' -> dst: '%s'\n" %
                       (d, dirmove[d]))
 
+    movewithdir = {}
     # check unaccounted nonoverlapping files against directory moves
     for f in u1r + u2r:
         if f not in fullcopy: