D10034: narrow: fix flaky behavior described in issue6150

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Fri Feb 19 18:38:38 UTC 2021


Alphare created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D10034

AFFECTED FILES
  mercurial/filelog.py
  tests/test-narrow-shallow.t

CHANGE DETAILS

diff --git a/tests/test-narrow-shallow.t b/tests/test-narrow-shallow.t
--- a/tests/test-narrow-shallow.t
+++ b/tests/test-narrow-shallow.t
@@ -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
diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -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



To: Alphare, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list