##// END OF EJS Templates
filelog: raise CensoredNodeError when hash checks fail with censor metadata...
Mike Edgar -
r22596:27e2317e default
parent child Browse files
Show More
@@ -5,7 +5,7 b''
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 import revlog
8 import error, revlog
9 9 import re
10 10
11 11 _mdre = re.compile('\1\n')
@@ -27,6 +27,10 b' def packmeta(meta, text):'
27 27 metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys)
28 28 return "\1\n%s\1\n%s" % (metatext, text)
29 29
30 def _censoredtext(text):
31 m, offs = parsemeta(text)
32 return m and "censored" in m and not text[offs:]
33
30 34 class filelog(revlog.revlog):
31 35 def __init__(self, opener, path):
32 36 super(filelog, self).__init__(opener,
@@ -86,5 +90,13 b' class filelog(revlog.revlog):'
86 90
87 91 return True
88 92
93 def checkhash(self, text, p1, p2, node, rev=None):
94 try:
95 super(filelog, self).checkhash(text, p1, p2, node, rev=rev)
96 except error.RevlogError:
97 if _censoredtext(text):
98 raise error.CensoredNodeError(self.indexfile, node)
99 raise
100
89 101 def _file(self, f):
90 102 return filelog(self.opener, f)
General Comments 0
You need to be logged in to leave comments. Login now