mercurial/filelog.py
changeset 22597 58ec36686f0e
parent 22596 27e2317efe89
child 23858 22a979d1ae56
--- 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