##// END OF EJS Templates
revlog: extract 'checkhash' method...
Wojciech Lopata -
r19624:55749cb1 default
parent child Browse files
Show More
@@ -14,7 +14,7 b' and O(changes) merge between branches.'
14 # import stuff from node for others to import from revlog
14 # import stuff from node for others to import from revlog
15 from node import bin, hex, nullid, nullrev
15 from node import bin, hex, nullid, nullrev
16 from i18n import _
16 from i18n import _
17 import ancestor, mdiff, parsers, error, util
17 import ancestor, mdiff, parsers, error, util, templatefilters
18 import struct, zlib, errno
18 import struct, zlib, errno
19
19
20 _pack = struct.pack
20 _pack = struct.pack
@@ -943,10 +943,16 b' class revlog(object):'
943
943
944 def _checkhash(self, text, node, rev):
944 def _checkhash(self, text, node, rev):
945 p1, p2 = self.parents(node)
945 p1, p2 = self.parents(node)
946 self.checkhash(text, p1, p2, node, rev)
947 return text
948
949 def checkhash(self, text, p1, p2, node, rev=None):
946 if node != hash(text, p1, p2):
950 if node != hash(text, p1, p2):
947 raise RevlogError(_("integrity check failed on %s:%d")
951 revornode = rev
948 % (self.indexfile, rev))
952 if revornode is None:
949 return text
953 revornode = templatefilters.short(hex(node))
954 raise RevlogError(_("integrity check failed on %s:%s")
955 % (self.indexfile, revornode))
950
956
951 def checkinlinesize(self, tr, fp=None):
957 def checkinlinesize(self, tr, fp=None):
952 if not self._inline or (self.start(-2) + self.length(-2)) < _maxinline:
958 if not self._inline or (self.start(-2) + self.length(-2)) < _maxinline:
@@ -1063,9 +1069,7 b' class revlog(object):'
1063 ifh.flush()
1069 ifh.flush()
1064 basetext = self.revision(self.node(cachedelta[0]))
1070 basetext = self.revision(self.node(cachedelta[0]))
1065 btext[0] = mdiff.patch(basetext, cachedelta[1])
1071 btext[0] = mdiff.patch(basetext, cachedelta[1])
1066 chk = hash(btext[0], p1, p2)
1072 self.checkhash(btext[0], p1, p2, node)
1067 if chk != node:
1068 raise RevlogError(_("consistency error in delta"))
1069 return btext[0]
1073 return btext[0]
1070
1074
1071 def builddelta(rev):
1075 def builddelta(rev):
General Comments 0
You need to be logged in to leave comments. Login now