Show More
@@ -12,6 +12,7 b' import struct' | |||||
12 |
|
12 | |||
13 | from mercurial import ( |
|
13 | from mercurial import ( | |
14 | extensions, |
|
14 | extensions, | |
|
15 | node, | |||
15 | revlog, |
|
16 | revlog, | |
16 | ) |
|
17 | ) | |
17 |
|
18 | |||
@@ -32,5 +33,18 b' def wrapaddrevision(orig, self, text, tr' | |||||
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) |
General Comments 0
You need to be logged in to leave comments.
Login now