Patchwork [1,of,5,v4] checkcopies: handle divergences contained entirely in tca::ctx

login
register
mail settings
Submitter Gábor Stefanik
Date Oct. 17, 2016, 6:42 p.m.
Message ID <d8379d11021b681a06cd.1476729725@GSTEFANIK.NavnGo.local>
Download mbox | patch
Permalink /patch/17157/
State Accepted
Headers show

Comments

Gábor Stefanik - Oct. 17, 2016, 6:42 p.m.
# HG changeset patch
# User Gábor Stefanik <gabor.stefanik@nng.com>
# Date 1476266043 -7200
#      Wed Oct 12 11:54:03 2016 +0200
# Node ID d8379d11021b681a06cda08a07da237eaca520b2
# Parent  475efa21684cbd7c7fffba34250267dc500a7e9e
checkcopies: handle divergences contained entirely in tca::ctx

During a graftlike merge, _checkcopies runs from ctx to tca, possibly
passing over the merge base. If there is a rename both before and after
the base, then we're actually dealing with divergent renames.
If there is no rename on the other side of tca, then the divergence is
contained entirely in the range of one _checkcopies invocation, and
should be detected "in the loop" without having to rely on the other
_checkcopies pass.

Patch

diff -r 475efa21684c -r d8379d11021b mercurial/copies.py
--- a/mercurial/copies.py	Mon Sep 26 10:47:37 2016 +0200
+++ b/mercurial/copies.py	Wed Oct 12 11:54:03 2016 +0200
@@ -564,9 +564,8 @@ 
     # traversed backwards.
     #
     # In the case there is both backward and forward renames (before and after
-    # the base) this is more complicated as we must detect a divergence. This
-    # is currently broken and hopefully some later code update will make that
-    # work (we use 'backwards = False' in that case)
+    # the base) this is more complicated as we must detect a divergence.
+    # We use 'backwards = False' in that case.
     backwards = base != tca and f in mb
     getfctx = _makegetfctx(ctx)
 
@@ -600,6 +599,12 @@ 
                 data['copy'][of] = f
             elif of in mb:
                 data['copy'][f] = of
+            else: # divergence w.r.t. graft CA on one side of topological CA
+                for sf in seen:
+                    if sf in mb:
+                        assert sf not in data['diverge']
+                        data['diverge'][sf] = [f, of]
+                        break
             return
 
     if of in mb:
diff -r 475efa21684c -r d8379d11021b tests/test-graft.t
--- a/tests/test-graft.t	Mon Sep 26 10:47:37 2016 +0200
+++ b/tests/test-graft.t	Wed Oct 12 11:54:03 2016 +0200
@@ -982,6 +982,9 @@ 
 
   $ HGEDITOR="echo D1 >" hg graft -r 'desc("D0")' --edit
   grafting 3:b69f5839d2d9 "D0"
+  note: possible conflict - f3b was renamed multiple times to:
+   f3d
+   f3a
   warning: can't find ancestor for 'f3d' copied from 'f3b'!
 
 Set up the repository for some further tests