Patchwork [2,of,6,censor,RFC] revlog: add "iscensored()" to revlog public API

login
register
mail settings
Submitter adgar@google.com
Date Jan. 23, 2015, 11:53 p.m.
Message ID <64ceb83e160e6d7ed6df.1422057202@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/7550/
State Superseded
Commit eaf7b9adaeacbb757abc0b73f6d91e2c95cf75b4
Headers show

Comments

adgar@google.com - Jan. 23, 2015, 11:53 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1422050499 18000
#      Fri Jan 23 17:01:39 2015 -0500
# Node ID 64ceb83e160e6d7ed6df9f59829ac4bf2eb605d6
# Parent  c918140288f12c3b5fb408da89512baff72ffd17
revlog: add "iscensored()" to revlog public API

The iscensored method will be used by the exchange layer to reject
nonconforming deltas involving censored revisions (and to produce
conforming deltas).

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan

Patch

diff -r c918140288f1 -r 64ceb83e160e mercurial/filelog.py
--- a/mercurial/filelog.py	Wed Jan 21 16:35:09 2015 -0500
+++ b/mercurial/filelog.py	Fri Jan 23 17:01:39 2015 -0500
@@ -64,7 +64,7 @@ 
         node = self.node(rev)
         if self.renamed(node):
             return len(self.read(node))
-        if self._iscensored(rev):
+        if self.iscensored(rev):
             return 0
 
         # XXX if self.read(node).startswith("\1\n"), this returns (size+4)
@@ -85,7 +85,7 @@ 
             return False
 
         # censored files compare against the empty file
-        if self._iscensored(self.rev(node)):
+        if self.iscensored(self.rev(node)):
             return text != ''
 
         # renaming a file produces a different hash, even if the data
@@ -104,9 +104,9 @@ 
                 raise error.CensoredNodeError(self.indexfile, node)
             raise
 
+    def iscensored(self, rev):
+        """Check if a file revision is censored."""
+        return self.flags(rev) & revlog.REVIDX_ISCENSORED
+
     def _file(self, f):
         return filelog(self.opener, f)
-
-    def _iscensored(self, rev):
-        """Check if a file revision is censored."""
-        return self.flags(rev) & revlog.REVIDX_ISCENSORED
diff -r c918140288f1 -r 64ceb83e160e mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Jan 21 16:35:09 2015 -0500
+++ b/mercurial/revlog.py	Fri Jan 23 17:01:39 2015 -0500
@@ -1417,6 +1417,10 @@ 
 
         return content
 
+    def iscensored(self, rev):
+        """Check if a file revision is censored."""
+        return False
+
     def getstrippoint(self, minlink):
         """find the minimum rev that must be stripped to strip the linkrev
 
diff -r c918140288f1 -r 64ceb83e160e mercurial/unionrepo.py
--- a/mercurial/unionrepo.py	Wed Jan 21 16:35:09 2015 -0500
+++ b/mercurial/unionrepo.py	Fri Jan 23 17:01:39 2015 -0500
@@ -163,6 +163,12 @@ 
     def _file(self, f):
         self._repo.file(f)
 
+    def iscensored(self, rev):
+        """Check if a revision is censored."""
+        if rev <= self.repotiprev:
+            return filelog.filelog.iscensored(self, rev)
+        return self.revlog2.iscensored(rev)
+
 class unionpeer(localrepo.localpeer):
     def canpush(self):
         return False