# HG changeset patch # User Mike Edgar # Date 2015-01-23 22:01:39 # Node ID 76f6ae06ddf578cbcafd94faaf69a31433a7282a # Parent 9cfd7c4f22f5da13ad202e9b9d1b39c4ff48ca93 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 diff --git a/mercurial/filelog.py b/mercurial/filelog.py --- a/mercurial/filelog.py +++ b/mercurial/filelog.py @@ -64,7 +64,7 @@ class filelog(revlog.revlog): 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 @@ class filelog(revlog.revlog): 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,6 +104,6 @@ class filelog(revlog.revlog): raise error.CensoredNodeError(self.indexfile, node) raise - def _iscensored(self, rev): + def iscensored(self, rev): """Check if a file revision is censored.""" return self.flags(rev) & revlog.REVIDX_ISCENSORED diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1419,6 +1419,10 @@ class revlog(object): 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 --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py --- a/mercurial/unionrepo.py +++ b/mercurial/unionrepo.py @@ -160,6 +160,12 @@ class unionfilelog(unionrevlog, filelog. def baserevdiff(self, rev1, rev2): return filelog.filelog.revdiff(self, rev1, rev2) + 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