Mercurial > hg
comparison mercurial/filelog.py @ 24118:76f6ae06ddf5
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
author | Mike Edgar <adgar@google.com> |
---|---|
date | Fri, 23 Jan 2015 17:01:39 -0500 |
parents | 9cfd7c4f22f5 |
children | 903c7e8c97ad |
comparison
equal
deleted
inserted
replaced
24117:9cfd7c4f22f5 | 24118:76f6ae06ddf5 |
---|---|
62 | 62 |
63 # for revisions with renames, we have to go the slow way | 63 # for revisions with renames, we have to go the slow way |
64 node = self.node(rev) | 64 node = self.node(rev) |
65 if self.renamed(node): | 65 if self.renamed(node): |
66 return len(self.read(node)) | 66 return len(self.read(node)) |
67 if self._iscensored(rev): | 67 if self.iscensored(rev): |
68 return 0 | 68 return 0 |
69 | 69 |
70 # XXX if self.read(node).startswith("\1\n"), this returns (size+4) | 70 # XXX if self.read(node).startswith("\1\n"), this returns (size+4) |
71 return super(filelog, self).size(rev) | 71 return super(filelog, self).size(rev) |
72 | 72 |
83 samehashes = not super(filelog, self).cmp(node, t) | 83 samehashes = not super(filelog, self).cmp(node, t) |
84 if samehashes: | 84 if samehashes: |
85 return False | 85 return False |
86 | 86 |
87 # censored files compare against the empty file | 87 # censored files compare against the empty file |
88 if self._iscensored(self.rev(node)): | 88 if self.iscensored(self.rev(node)): |
89 return text != '' | 89 return text != '' |
90 | 90 |
91 # renaming a file produces a different hash, even if the data | 91 # renaming a file produces a different hash, even if the data |
92 # remains unchanged. Check if it's the case (slow): | 92 # remains unchanged. Check if it's the case (slow): |
93 if self.renamed(node): | 93 if self.renamed(node): |
102 except error.RevlogError: | 102 except error.RevlogError: |
103 if _censoredtext(text): | 103 if _censoredtext(text): |
104 raise error.CensoredNodeError(self.indexfile, node) | 104 raise error.CensoredNodeError(self.indexfile, node) |
105 raise | 105 raise |
106 | 106 |
107 def _iscensored(self, rev): | 107 def iscensored(self, rev): |
108 """Check if a file revision is censored.""" | 108 """Check if a file revision is censored.""" |
109 return self.flags(rev) & revlog.REVIDX_ISCENSORED | 109 return self.flags(rev) & revlog.REVIDX_ISCENSORED |