[PATCH 1 of 7] copies: don't record divergence for files needing no merge

Gábor Stefanik gabor.stefanik at nng.com
Fri Oct 7 12:31:34 UTC 2016


# HG changeset patch
# User Gábor Stefanik <gabor.stefanik at nng.com>
# Date 1475494199 -7200
#      Mon Oct 03 13:29:59 2016 +0200
# Node ID 5b7cd65a9be6c82b3ad14096b41db44c198a6769
# Parent  91a3c58ecf938ed675f5364b88f0d663f12b0047
copies: don't record divergence for files needing no merge

This is left over from when _checkcopies was factored out from mergecopies.

The 2nd break has "of = None" before it, so it's a functionally equivalent
change. The 1st one, however, causes a divergence to be recorded when
a file has been renamed, but there is nothing to be merged to it.

This is currently harmless, since the extra divergence is simply ignored
later. However, the new _checkcopies introduced in the rest of this series
does more than just record a divergence after completing the main loop,
and it's important that the "post-processing" stage is really skipped
for no-merge-needed renames.

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -524,13 +524,12 @@
         if of not in m2:
             continue # no match, keep looking
         if m2[of] == ma.get(of):
-            break # no merge needed, quit early
+            return # no merge needed, quit early
         c2 = getfctx(of, m2[of])
         cr = _related(oc, c2, ca.rev())
         if cr and (of == f or of == c2.path()): # non-divergent
             copy[f] = of
-            of = None
-            break
+            return
 
     if of in ma:
         diverge.setdefault(of, []).append(f)


More information about the Mercurial-devel mailing list