changeset 22597:58ec36686f0e

filelog: censored files compare against empty data, have 0 size To support "status" operations against working directories that are the children of censored revisions, filelog must define "cmp" and "size" for censored content.
author Mike Edgar <adgar@google.com>
date Sun, 14 Sep 2014 20:32:34 -0400
parents 27e2317efe89
children 5e0d1478db8e
files mercurial/filelog.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filelog.py	Wed Sep 03 22:14:20 2014 -0400
+++ b/mercurial/filelog.py	Sun Sep 14 20:32:34 2014 -0400
@@ -64,6 +64,8 @@
         node = self.node(rev)
         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)
         return super(filelog, self).size(rev)
@@ -82,6 +84,10 @@
         if samehashes:
             return False
 
+        # censored files compare against the empty file
+        if self._iscensored(node):
+            return text != ''
+
         # renaming a file produces a different hash, even if the data
         # remains unchanged. Check if it's the case (slow):
         if self.renamed(node):
@@ -100,3 +106,11 @@
 
     def _file(self, f):
         return filelog(self.opener, f)
+
+    def _iscensored(self, revornode):
+        """Check if a file revision is censored."""
+        try:
+            self.revision(revornode)
+            return False
+        except error.CensoredNodeError:
+            return True