D12604: censor: fix [hg update] away from a revision with censored files

aalekseyev (Arseniy Alekseyev) phabricator at mercurial-scm.org
Wed May 4 16:45:00 UTC 2022


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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/filelog.py
  tests/test-censor2.t

CHANGE DETAILS

diff --git a/tests/test-censor2.t b/tests/test-censor2.t
--- a/tests/test-censor2.t
+++ b/tests/test-censor2.t
@@ -19,5 +19,4 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat target
   $ hg update tip
-  abort: file censored data/target:b1c12cf98dc8 (known-bad-output !)
-  [255]
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -202,10 +202,10 @@
 
         # for revisions with renames, we have to go the slow way
         node = self.node(rev)
+        if self.iscensored(rev):
+            return 0
         if self.renamed(node):
             return len(self.read(node))
-        if self.iscensored(rev):
-            return 0
 
         # XXX if self.read(node).startswith("\1\n"), this returns (size+4)
         # XXX See also basefilectx.cmp.



To: aalekseyev, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list