30 # and sha2 hashes |
31 # and sha2 hashes |
31 sha256 = hashlib.sha256(text).digest() |
32 sha256 = hashlib.sha256(text).digest() |
32 sd[sidedata.SD_TEST2] = struct.pack('>32s', sha256) |
33 sd[sidedata.SD_TEST2] = struct.pack('>32s', sha256) |
33 return orig(self, text, transaction, link, p1, p2, *args, **kwargs) |
34 return orig(self, text, transaction, link, p1, p2, *args, **kwargs) |
34 |
35 |
|
36 def wraprevision(orig, self, nodeorrev, *args, **kwargs): |
|
37 text = orig(self, nodeorrev, *args, **kwargs) |
|
38 if nodeorrev != node.nullrev and nodeorrev != node.nullid: |
|
39 sd = self.sidedata(nodeorrev) |
|
40 if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]: |
|
41 raise RuntimeError('text size mismatch') |
|
42 expected = sd[sidedata.SD_TEST2] |
|
43 got = hashlib.sha256(text).digest() |
|
44 if got != expected: |
|
45 raise RuntimeError('sha256 mismatch') |
|
46 return text |
|
47 |
35 def extsetup(ui): |
48 def extsetup(ui): |
36 extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision) |
49 extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision) |
|
50 extensions.wrapfunction(revlog.revlog, 'revision', wraprevision) |