Show More
@@ -31,6 +31,7 b' from .utils import compression' | |||||
31 | RECLONES_REQUIREMENTS = { |
|
31 | RECLONES_REQUIREMENTS = { | |
32 | b'generaldelta', |
|
32 | b'generaldelta', | |
33 | localrepo.SPARSEREVLOG_REQUIREMENT, |
|
33 | localrepo.SPARSEREVLOG_REQUIREMENT, | |
|
34 | localrepo.SIDEDATA_REQUIREMENT, | |||
34 | } |
|
35 | } | |
35 |
|
36 | |||
36 |
|
37 | |||
@@ -100,6 +101,7 b' def supporteddestrequirements(repo):' | |||||
100 | b'revlogv1', |
|
101 | b'revlogv1', | |
101 | b'store', |
|
102 | b'store', | |
102 | localrepo.SPARSEREVLOG_REQUIREMENT, |
|
103 | localrepo.SPARSEREVLOG_REQUIREMENT, | |
|
104 | localrepo.SIDEDATA_REQUIREMENT, | |||
103 | } |
|
105 | } | |
104 | for name in compression.compengines: |
|
106 | for name in compression.compengines: | |
105 | engine = compression.compengines[name] |
|
107 | engine = compression.compengines[name] | |
@@ -125,6 +127,7 b' def allowednewrequirements(repo):' | |||||
125 | b'fncache', |
|
127 | b'fncache', | |
126 | b'generaldelta', |
|
128 | b'generaldelta', | |
127 | localrepo.SPARSEREVLOG_REQUIREMENT, |
|
129 | localrepo.SPARSEREVLOG_REQUIREMENT, | |
|
130 | localrepo.SIDEDATA_REQUIREMENT, | |||
128 | } |
|
131 | } | |
129 | for name in compression.compengines: |
|
132 | for name in compression.compengines: | |
130 | engine = compression.compengines[name] |
|
133 | engine = compression.compengines[name] | |
@@ -676,6 +679,10 b' UPGRADE_ALL_REVLOGS = frozenset(' | |||||
676 | ) |
|
679 | ) | |
677 |
|
680 | |||
678 |
|
681 | |||
|
682 | def getsidedatacompanion(srcrepo, destrepo): | |||
|
683 | return None | |||
|
684 | ||||
|
685 | ||||
679 | def matchrevlog(revlogfilter, entry): |
|
686 | def matchrevlog(revlogfilter, entry): | |
680 | """check is a revlog is selected for cloning |
|
687 | """check is a revlog is selected for cloning | |
681 |
|
688 | |||
@@ -779,6 +786,8 b' def _clonerevlogs(' | |||||
779 | def oncopiedrevision(rl, rev, node): |
|
786 | def oncopiedrevision(rl, rev, node): | |
780 | progress.increment() |
|
787 | progress.increment() | |
781 |
|
788 | |||
|
789 | sidedatacompanion = getsidedatacompanion(srcrepo, dstrepo) | |||
|
790 | ||||
782 | # Do the actual copying. |
|
791 | # Do the actual copying. | |
783 | # FUTURE this operation can be farmed off to worker processes. |
|
792 | # FUTURE this operation can be farmed off to worker processes. | |
784 | seen = set() |
|
793 | seen = set() | |
@@ -870,6 +879,7 b' def _clonerevlogs(' | |||||
870 | addrevisioncb=oncopiedrevision, |
|
879 | addrevisioncb=oncopiedrevision, | |
871 | deltareuse=deltareuse, |
|
880 | deltareuse=deltareuse, | |
872 | forcedeltabothparents=forcedeltabothparents, |
|
881 | forcedeltabothparents=forcedeltabothparents, | |
|
882 | sidedatacompanion=sidedatacompanion, | |||
873 | ) |
|
883 | ) | |
874 | else: |
|
884 | else: | |
875 | msg = _(b'blindly copying %s containing %i revisions\n') |
|
885 | msg = _(b'blindly copying %s containing %i revisions\n') |
@@ -45,8 +45,8 b' Check upgrade behavior' | |||||
45 |
|
45 | |||
46 | Right now, sidedata has not upgrade support |
|
46 | Right now, sidedata has not upgrade support | |
47 |
|
47 | |||
48 |
Check that we can |
|
48 | Check that we can upgrade to sidedata | |
49 |
------------------------------------- |
|
49 | ------------------------------------- | |
50 |
|
50 | |||
51 | $ hg init up-no-side-data --config format.use-side-data=no |
|
51 | $ hg init up-no-side-data --config format.use-side-data=no | |
52 | $ hg debugformat -v -R up-no-side-data |
|
52 | $ hg debugformat -v -R up-no-side-data | |
@@ -69,9 +69,7 b' Check that we cannot upgrade to sidedata' | |||||
69 | plain-cl-delta: yes yes yes |
|
69 | plain-cl-delta: yes yes yes | |
70 | compression: zlib zlib zlib |
|
70 | compression: zlib zlib zlib | |
71 | compression-level: default default default |
|
71 | compression-level: default default default | |
72 | $ hg debugupgraderepo -R up-no-side-data --config format.use-side-data=yes |
|
72 | $ hg debugupgraderepo -R up-no-side-data --config format.use-side-data=yes > /dev/null | |
73 | abort: cannot upgrade repository; do not support adding requirement: exp-sidedata-flag |
|
|||
74 | [255] |
|
|||
75 |
|
73 | |||
76 | Check that we cannot upgrade to sidedata |
|
74 | Check that we cannot upgrade to sidedata | |
77 | ---------------------------------------- |
|
75 | ---------------------------------------- |
@@ -1329,6 +1329,35 b' upgrade from hgrc' | |||||
1329 | sparserevlog |
|
1329 | sparserevlog | |
1330 | store |
|
1330 | store | |
1331 |
|
1331 | |||
1332 | $ cd .. |
|
1332 | #endif | |
|
1333 | ||||
|
1334 | Check upgrading to a side-data revlog | |||
|
1335 | ------------------------------------- | |||
|
1336 | ||||
|
1337 | upgrade | |||
1333 |
|
1338 | |||
1334 | #endif |
|
1339 | $ hg --config format.use-side-data=yes debugupgraderepo --run --no-backup --config "extensions.sidedata=$TESTDIR/testlib/ext-sidedata.py" >/dev/null | |
|
1340 | $ hg debugformat -v | |||
|
1341 | format-variant repo config default | |||
|
1342 | fncache: yes yes yes | |||
|
1343 | dotencode: yes yes yes | |||
|
1344 | generaldelta: yes yes yes | |||
|
1345 | sparserevlog: yes yes yes | |||
|
1346 | sidedata: yes no no | |||
|
1347 | plain-cl-delta: yes yes yes | |||
|
1348 | compression: zstd zstd zlib | |||
|
1349 | compression-level: default default default | |||
|
1350 | $ cat .hg/requires | |||
|
1351 | dotencode | |||
|
1352 | exp-sidedata-flag | |||
|
1353 | fncache | |||
|
1354 | generaldelta | |||
|
1355 | revlog-compression-zstd | |||
|
1356 | revlogv1 | |||
|
1357 | sparserevlog | |||
|
1358 | store | |||
|
1359 | $ hg debugsidedata -c 0 | |||
|
1360 | 2 sidedata entries | |||
|
1361 | entry-0001 size 4 | |||
|
1362 | entry-0002 size 32 | |||
|
1363 |
@@ -12,8 +12,10 b' import struct' | |||||
12 |
|
12 | |||
13 | from mercurial import ( |
|
13 | from mercurial import ( | |
14 | extensions, |
|
14 | extensions, | |
|
15 | localrepo, | |||
15 | node, |
|
16 | node, | |
16 | revlog, |
|
17 | revlog, | |
|
18 | upgrade, | |||
17 | ) |
|
19 | ) | |
18 |
|
20 | |||
19 | from mercurial.revlogutils import sidedata |
|
21 | from mercurial.revlogutils import sidedata | |
@@ -36,6 +38,8 b' def wrapaddrevision(' | |||||
36 |
|
38 | |||
37 | def wraprevision(orig, self, nodeorrev, *args, **kwargs): |
|
39 | def wraprevision(orig, self, nodeorrev, *args, **kwargs): | |
38 | text = orig(self, nodeorrev, *args, **kwargs) |
|
40 | text = orig(self, nodeorrev, *args, **kwargs) | |
|
41 | if getattr(self, 'sidedatanocheck', False): | |||
|
42 | return text | |||
39 | if nodeorrev != node.nullrev and nodeorrev != node.nullid: |
|
43 | if nodeorrev != node.nullrev and nodeorrev != node.nullid: | |
40 | sd = self.sidedata(nodeorrev) |
|
44 | sd = self.sidedata(nodeorrev) | |
41 | if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]: |
|
45 | if len(text) != struct.unpack('>I', sd[sidedata.SD_TEST1])[0]: | |
@@ -47,6 +51,33 b' def wraprevision(orig, self, nodeorrev, ' | |||||
47 | return text |
|
51 | return text | |
48 |
|
52 | |||
49 |
|
53 | |||
|
54 | def wrapgetsidedatacompanion(orig, srcrepo, dstrepo): | |||
|
55 | sidedatacompanion = orig(srcrepo, dstrepo) | |||
|
56 | addedreqs = dstrepo.requirements - srcrepo.requirements | |||
|
57 | if localrepo.SIDEDATA_REQUIREMENT in addedreqs: | |||
|
58 | assert sidedatacompanion is None # deal with composition later | |||
|
59 | ||||
|
60 | def sidedatacompanion(revlog, rev): | |||
|
61 | update = {} | |||
|
62 | revlog.sidedatanocheck = True | |||
|
63 | try: | |||
|
64 | text = revlog.revision(rev) | |||
|
65 | finally: | |||
|
66 | del revlog.sidedatanocheck | |||
|
67 | ## let's store some arbitrary data just for testing | |||
|
68 | # text length | |||
|
69 | update[sidedata.SD_TEST1] = struct.pack('>I', len(text)) | |||
|
70 | # and sha2 hashes | |||
|
71 | sha256 = hashlib.sha256(text).digest() | |||
|
72 | update[sidedata.SD_TEST2] = struct.pack('>32s', sha256) | |||
|
73 | return False, (), update | |||
|
74 | ||||
|
75 | return sidedatacompanion | |||
|
76 | ||||
|
77 | ||||
50 | def extsetup(ui): |
|
78 | def extsetup(ui): | |
51 | extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision) |
|
79 | extensions.wrapfunction(revlog.revlog, 'addrevision', wrapaddrevision) | |
52 | extensions.wrapfunction(revlog.revlog, 'revision', wraprevision) |
|
80 | extensions.wrapfunction(revlog.revlog, 'revision', wraprevision) | |
|
81 | extensions.wrapfunction( | |||
|
82 | upgrade, 'getsidedatacompanion', wrapgetsidedatacompanion | |||
|
83 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now