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

login
register
mail settings
Submitter phabricator
Date May 4, 2022, 4:45 p.m.
Message ID <differential-rev-PHID-DREV-hxxqpcrfd56rd3vogapa-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50954/
State New
Headers show

Comments

phabricator - May 4, 2022, 4:45 p.m.
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




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

Patch

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.