Patchwork [01,of,16] checkcopies: move 'movewithdir' initialisation right before its usage

login
register
mail settings
Submitter Gábor Stefanik
Date Oct. 16, 2016, 2:32 p.m.
Message ID <c2b7ab2954aecc3030a4.1476628355@GSTEFANIK.NavnGo.local>
Download mbox | patch
Permalink /patch/17110/
State Not Applicable
Headers show

Comments

Gábor Stefanik - Oct. 16, 2016, 2:32 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1476144923 -7200
#      Tue Oct 11 02:15:23 2016 +0200
# Node ID c2b7ab2954aecc3030a4c401390031513712d360
# Parent  5cb830801855dbb63e98b948e355bc995d295bf3
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

Patch

diff -r 5cb830801855 -r c2b7ab2954ae mercurial/copies.py
--- a/mercurial/copies.py	Wed Oct 12 12:22:18 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: