changeset 46376:b994db7c4d1e stable

narrow: fix flaky behavior described in issue6150 This has been plaguing the CI for a good while, and it doesn't appear to have an easy fix proposed yet. The solution in this change is to always do an unambiguous (but expensive) lookup in case of comparison. This should always be correct, albeit suboptimal. Differential Revision: https://phab.mercurial-scm.org/D10034
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 19 Feb 2021 17:52:04 +0100
parents 33350debb480
children 0492002560f3
files mercurial/filelog.py tests/test-narrow-shallow.t
diffstat 2 files changed, 8 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filelog.py	Tue Feb 16 15:44:51 2021 +0530
+++ b/mercurial/filelog.py	Fri Feb 19 17:52:04 2021 +0100
@@ -279,14 +279,12 @@
             return super(narrowfilelog, self).size(rev)
 
     def cmp(self, node, text):
-        different = super(narrowfilelog, self).cmp(node, text)
+        # We don't call `super` because narrow parents can be buggy in case of a
+        # ambiguous dirstate. Always take the slow path until there is a better
+        # fix, see issue6150.
 
-        # Because renamed() may lie, we may get false positives for
-        # different content. Check for this by comparing against the original
-        # renamed() implementation.
-        if different:
-            if super(narrowfilelog, self).renamed(node):
-                t2 = self.read(node)
-                return t2 != text
+        # Censored files compare against the empty file.
+        if self.iscensored(self.rev(node)):
+            return text != b''
 
-        return different
+        return self.read(node) != text
--- a/tests/test-narrow-shallow.t	Tue Feb 16 15:44:51 2021 +0530
+++ b/tests/test-narrow-shallow.t	Fri Feb 19 17:52:04 2021 +0100
@@ -92,28 +92,8 @@
   1: Commit rev2 of f8, d1/f8, d2/f8
   0...: Commit rev2 of f7, d1/f7, d2/f7
 
-XXX flaky output (see issue6150)
-XXX
-XXX The filectx implementation is buggy and return wrong data during status.
-XXX Leading to more file being "merged". The right output is the one with just
-XXX 10 files updated.
-
   $ hg update 4
-  merging d2/f1 (?)
-  merging d2/f2 (?)
-  merging d2/f3 (?)
-  merging d2/f4 (?)
-  merging d2/f5 (?)
-  merging d2/f6 (?)
-  merging d2/f7 (?)
-  3 files updated, 7 files merged, 0 files removed, 0 files unresolved (?)
-  4 files updated, 6 files merged, 0 files removed, 0 files unresolved (?)
-  5 files updated, 5 files merged, 0 files removed, 0 files unresolved (?)
-  6 files updated, 4 files merged, 0 files removed, 0 files unresolved (?)
-  7 files updated, 3 files merged, 0 files removed, 0 files unresolved (?)
-  8 files updated, 2 files merged, 0 files removed, 0 files unresolved (?)
-  9 files updated, 1 files merged, 0 files removed, 0 files unresolved (?)
-  10 files updated, 0 files merged, 0 files removed, 0 files unresolved (?)
+  10 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat d2/f7 d2/f8
   d2/f7 rev3
   d2/f8 rev2