# HG changeset patch
# User Gábor Stefanik <gabor.stefa...@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

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]
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to