diff mercurial/context.py @ 31991:55987fc8aba1

context: add an assertion checking linerange consistency in blockdescendants() If this assertion fails, this indicates a flaw in the algorithm. So fail fast instead of possibly producing wrong results. Also extend the target line range in test to catch a merge changeset with all its parents.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Fri, 14 Apr 2017 14:09:26 +0200
parents 4c2c30bc38b4
children 3e47a40d7a7a
line wrap: on
line diff
--- a/mercurial/context.py	Fri Apr 14 12:34:26 2017 -0700
+++ b/mercurial/context.py	Fri Apr 14 14:09:26 2017 +0200
@@ -1226,6 +1226,12 @@
                 continue
             inrangep, linerange1 = _changesrange(c, p, linerange2, diffopts)
             inrange = inrange or inrangep
+            # If revision 'i' has been seen (it's a merge), we assume that its
+            # line range is the same independently of which parents was used
+            # to compute it.
+            assert i not in seen or seen[i][1] == linerange1, (
+                'computed line range for %s is not consistent between '
+                'ancestor branches' % c)
             seen[i] = c, linerange1
         if inrange:
             yield c, linerange1