38 sha256 = hashlib.sha256(text).digest() |
38 sha256 = hashlib.sha256(text).digest() |
39 sd[sidedata.SD_TEST2] = struct.pack('>32s', sha256) |
39 sd[sidedata.SD_TEST2] = struct.pack('>32s', sha256) |
40 return orig(self, text, transaction, link, p1, p2, *args, **kwargs) |
40 return orig(self, text, transaction, link, p1, p2, *args, **kwargs) |
41 |
41 |
42 |
42 |
43 def wraprevision(orig, self, nodeorrev, *args, **kwargs): |
43 def wrap_revisiondata(orig, self, nodeorrev, *args, **kwargs): |
44 text = orig(self, nodeorrev, *args, **kwargs) |
44 text, sd = orig(self, nodeorrev, *args, **kwargs) |
45 if getattr(self, 'sidedatanocheck', False): |
45 if getattr(self, 'sidedatanocheck', False): |
46 return text |
46 return text, sd |
|
47 if self.version & 0xFFFF != 2: |
|
48 return text, sd |
47 if nodeorrev != nullrev and nodeorrev != nullid: |
49 if nodeorrev != nullrev and nodeorrev != nullid: |
48 sd = self.sidedata(nodeorrev) |
|
49 if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]: |
50 if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]: |
50 raise RuntimeError('text size mismatch') |
51 raise RuntimeError('text size mismatch') |
51 expected = sd[sidedata.SD_TEST2] |
52 expected = sd[sidedata.SD_TEST2] |
52 got = hashlib.sha256(text).digest() |
53 got = hashlib.sha256(text).digest() |
53 if got != expected: |
54 if got != expected: |
54 raise RuntimeError('sha256 mismatch') |
55 raise RuntimeError('sha256 mismatch') |
55 return text |
56 return text, sd |
56 |
57 |
57 |
58 |
58 def wrapgetsidedatacompanion(orig, srcrepo, dstrepo): |
59 def wrapgetsidedatacompanion(orig, srcrepo, dstrepo): |
59 sidedatacompanion = orig(srcrepo, dstrepo) |
60 sidedatacompanion = orig(srcrepo, dstrepo) |
60 addedreqs = dstrepo.requirements - srcrepo.requirements |
61 addedreqs = dstrepo.requirements - srcrepo.requirements |
79 return sidedatacompanion |
80 return sidedatacompanion |
80 |
81 |
81 |
82 |
82 def extsetup(ui): |
83 def extsetup(ui): |
83 extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision) |
84 extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision) |
84 extensions.wrapfunction(revlog.revlog, 'revision', wraprevision) |
85 extensions.wrapfunction(revlog.revlog, '_revisiondata', wrap_revisiondata) |
85 extensions.wrapfunction( |
86 extensions.wrapfunction( |
86 upgrade_engine, 'getsidedatacompanion', wrapgetsidedatacompanion |
87 upgrade_engine, 'getsidedatacompanion', wrapgetsidedatacompanion |
87 ) |
88 ) |