Patchwork [4,of,7] copies: make _checkcopies handle divergences in rotated DAG

login
register
mail settings
Submitter Gábor Stefanik
Date Oct. 7, 2016, 12:31 p.m.
Message ID <76b744060475aa207513.1475843497@waste.org>
Download mbox | patch
Permalink /patch/16879/
State Changes Requested
Delegated to: Matt Mackall
Headers show

Comments

Gábor Stefanik - Oct. 7, 2016, 12:31 p.m.
# HG changeset patch
# User Gábor Stefanik <gabor.stefanik@nng.com>
# Date 1475588323 -7200
#      Tue Oct 04 15:38:43 2016 +0200
# Node ID 76b744060475aa20751310e9e2eab76ab78b9cc6
# Parent  887cbdaad15d5cc1b86c7dc419a83640d467ec5a
copies: make _checkcopies handle divergences in rotated DAG

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -347,11 +347,11 @@ 
 
     for f in u1u:
         _checkcopies(c1, f, m1, m2, ca, ca, False, limit, diverge, copy1,
-                     fullcopy1)
+                     fullcopy1, incomplete1, incompletediverge)
 
     for f in u2u:
         _checkcopies(c2, f, m2, m1, ca, ca, False, limit, diverge, copy2,
-                     fullcopy2)
+                     fullcopy2, incomplete2, incompletediverge)
 
     copy = dict(copy1.items() + copy2.items())
     movewithdir = dict(movewithdir1.items() + movewithdir2.items())
@@ -380,9 +380,9 @@ 
     incomplete1, incomplete2, incompletediverge = {}, {}, {}
     for f in bothnew:
         _checkcopies(c1, f, m1, m2, ca, ca, False, limit, bothdiverge, _copy,
-                     _fullcopy)
+                     _fullcopy, incomplete1, incompletediverge)
         _checkcopies(c2, f, m2, m1, ca, ca, False, limit, bothdiverge, _copy,
-                     _fullcopy)
+                     _fullcopy, incomplete2, incompletediverge)
     for of, fl in bothdiverge.items():
         if len(fl) == 2 and fl[0] == fl[1]:
             copy[fl[0]] = of # not actually divergent, just matching renames
@@ -463,7 +463,7 @@ 
     return copy, movewithdir, diverge, renamedelete
 
 def _checkcopies(ctx, f, m1, m2, ca, tca, remoteca, limit, diverge, copy,
-                 fullcopy):
+                 fullcopy, incomplete, incompletediverge):
     """
     check possible copies of f from m1 to m2
 
@@ -478,6 +478,8 @@ 
     diverge = record all diverges in this dict
     copy = record all non-divergent copies in this dict
     fullcopy = record all copies in this dict
+    incomplete = record non-divergent partial copies here
+    incompletediverge = record divergent partial copies here
 
     note: limit is only an optimization, and there is no guarantee that
     irrelevant revisions will not be limited
@@ -553,10 +555,25 @@ 
                 copy[of] = f
                 del fullcopy[f]
                 fullcopy[of] = f
+            else: # divergence w.r.t. graft CA on one side of topological CA
+                for sf in seen:
+                    if sf in ma:
+                        assert sf not in diverge
+                        diverge[sf] = [f, of]
+                        break
             return
 
-    if of in ma:
-        diverge.setdefault(of, []).append(f)
+    if of in mta:
+        if backwards or remoteca:
+            incomplete[of] = f
+        else:
+            for sf in seen:
+                if sf in ma:
+                    if tca == ca:
+                        diverge.setdefault(sf, []).append(f)
+                    else:
+                        incompletediverge[sf] = [of, f]
+                    return
 
 def duplicatecopies(repo, rev, fromrev, skiprev=None):
     '''reproduce copies from fromrev to rev in the dirstate