Patchwork copies: improve assertions during copy recombination

login
register
mail settings
Submitter Gábor Stefanik
Date Oct. 18, 2016, 12:09 a.m.
Message ID <87a7c0d403ff29dcae2a.1476749374@GSTEFANIK.NavnGo.local>
Download mbox | patch
Permalink /patch/17165/
State Accepted
Headers show

Comments

Gábor Stefanik - Oct. 18, 2016, 12:09 a.m.
# HG changeset patch
# User Gábor Stefanik <gabor.stefanik@nng.com>
# Date 1476749348 -7200
#      Tue Oct 18 02:09:08 2016 +0200
# Node ID 87a7c0d403ff29dcae2a41e0516c75bbd9f6a5a8
# Parent  abe7230025099bbeb9eaa0d3ca29c8f700ddb1e2
copies: improve assertions during copy recombination

- Make sure there is nothing to recombine in non-graftlike scenarios
- More pythonic assert syntax
Pierre-Yves David - Oct. 18, 2016, 12:27 a.m.
On 10/18/2016 02:09 AM, Gábor Stefanik wrote:
> # HG changeset patch
> # User Gábor Stefanik <gabor.stefanik@nng.com>
> # Date 1476749348 -7200
> #      Tue Oct 18 02:09:08 2016 +0200
> # Node ID 87a7c0d403ff29dcae2a41e0516c75bbd9f6a5a8
> # Parent  abe7230025099bbeb9eaa0d3ca29c8f700ddb1e2
> copies: improve assertions during copy recombination

I've pushed this one, thanks.

Cheers,

Patch

diff -r abe723002509 -r 87a7c0d403ff mercurial/copies.py
--- a/mercurial/copies.py	Mon Oct 17 16:12:12 2016 -0700
+++ b/mercurial/copies.py	Tue Oct 18 02:09:08 2016 +0200
@@ -447,6 +447,7 @@ 
                       % "\n   ".join(bothnew))
     bothdiverge = {}
     bothincompletediverge = {}
+    remainder = {}
     both1 = {'copy': {},
              'fullcopy': {},
              'incomplete': {},
@@ -463,13 +464,19 @@ 
         _checkcopies(c1, f, m1, m2, base, tca, dirtyc1, limit, both1)
         _checkcopies(c2, f, m2, m1, base, tca, dirtyc2, limit, both2)
     if dirtyc1:
-        assert both2['incomplete'] == {}
+        # incomplete copies may only be found on the "dirty" side for bothnew
+        assert not both2['incomplete']
         remainder = _combinecopies({}, both1['incomplete'], copy, bothdiverge,
                                    bothincompletediverge)
-    else:
-        assert both1['incomplete'] == {}
+    elif dirtyc2:
+        assert not both1['incomplete']
         remainder = _combinecopies({}, both2['incomplete'], copy, bothdiverge,
                                    bothincompletediverge)
+    else:
+        # incomplete copies and divergences can't happen outside grafts
+        assert not both1['incomplete']
+        assert not both2['incomplete']
+        assert not bothincompletediverge
     for f in remainder:
         assert f not in bothdiverge
         ic = remainder[f]