Show More
@@ -88,12 +88,13 b' if stable_docket_file:' | |||
|
88 | 88 | # * 4 bytes: revlog version |
|
89 | 89 | # | This is mandatory as docket must be compatible with the previous |
|
90 | 90 | # | revlog index header. |
|
91 | # * 1 bytes: size of index uuid | |
|
91 | 92 | # * 8 bytes: size of index-data |
|
92 | 93 | # * 8 bytes: pending size of index-data |
|
93 | 94 | # * 8 bytes: size of data |
|
94 | 95 | # * 8 bytes: pending size of data |
|
95 | 96 | # * 1 bytes: default compression header |
|
96 | S_HEADER = struct.Struct(constants.INDEX_HEADER.format + 'LLLLc') | |
|
97 | S_HEADER = struct.Struct(constants.INDEX_HEADER.format + 'BLLLLc') | |
|
97 | 98 | |
|
98 | 99 | |
|
99 | 100 | class RevlogDocket(object): |
@@ -104,6 +105,7 b' class RevlogDocket(object):' | |||
|
104 | 105 | revlog, |
|
105 | 106 | use_pending=False, |
|
106 | 107 | version_header=None, |
|
108 | index_uuid=None, | |
|
107 | 109 | index_end=0, |
|
108 | 110 | pending_index_end=0, |
|
109 | 111 | data_end=0, |
@@ -116,6 +118,7 b' class RevlogDocket(object):' | |||
|
116 | 118 | self._radix = revlog.radix |
|
117 | 119 | self._path = revlog._docket_file |
|
118 | 120 | self._opener = revlog.opener |
|
121 | self._index_uuid = index_uuid | |
|
119 | 122 | # thes asserts should be True as long as we have a single index filename |
|
120 | 123 | assert index_end <= pending_index_end |
|
121 | 124 | assert data_end <= pending_data_end |
@@ -134,7 +137,9 b' class RevlogDocket(object):' | |||
|
134 | 137 | def index_filepath(self): |
|
135 | 138 | """file path to the current index file associated to this docket""" |
|
136 | 139 | # very simplistic version at first |
|
137 | return b"%s.idx" % self._radix | |
|
140 | if self._index_uuid is None: | |
|
141 | self._index_uuid = make_uid() | |
|
142 | return b"%s-%s.idx" % (self._radix, self._index_uuid) | |
|
138 | 143 | |
|
139 | 144 | @property |
|
140 | 145 | def index_end(self): |
@@ -189,13 +194,17 b' class RevlogDocket(object):' | |||
|
189 | 194 | assert official_data_end <= self._data_end |
|
190 | 195 | data = ( |
|
191 | 196 | self._version_header, |
|
197 | len(self._index_uuid), | |
|
192 | 198 | official_index_end, |
|
193 | 199 | self._index_end, |
|
194 | 200 | official_data_end, |
|
195 | 201 | self._data_end, |
|
196 | 202 | self.default_compression_header, |
|
197 | 203 | ) |
|
198 | return S_HEADER.pack(*data) | |
|
204 | s = [] | |
|
205 | s.append(S_HEADER.pack(*data)) | |
|
206 | s.append(self._index_uuid) | |
|
207 | return b''.join(s) | |
|
199 | 208 | |
|
200 | 209 | |
|
201 | 210 | def default_docket(revlog, version_header): |
@@ -216,16 +225,21 b' def default_docket(revlog, version_heade' | |||
|
216 | 225 | def parse_docket(revlog, data, use_pending=False): |
|
217 | 226 | """given some docket data return a docket object for the given revlog""" |
|
218 | 227 | header = S_HEADER.unpack(data[: S_HEADER.size]) |
|
228 | offset = S_HEADER.size | |
|
219 | 229 | version_header = header[0] |
|
220 | index_size = header[1] | |
|
221 | pending_index_size = header[2] | |
|
222 | data_size = header[3] | |
|
223 |
|
|
|
224 | default_compression_header = header[5] | |
|
230 | index_uuid_size = header[1] | |
|
231 | index_uuid = data[offset : offset + index_uuid_size] | |
|
232 | offset += index_uuid_size | |
|
233 | index_size = header[2] | |
|
234 | pending_index_size = header[3] | |
|
235 | data_size = header[4] | |
|
236 | pending_data_size = header[5] | |
|
237 | default_compression_header = header[6] | |
|
225 | 238 | docket = RevlogDocket( |
|
226 | 239 | revlog, |
|
227 | 240 | use_pending=use_pending, |
|
228 | 241 | version_header=version_header, |
|
242 | index_uuid=index_uuid, | |
|
229 | 243 | index_end=index_size, |
|
230 | 244 | pending_index_end=pending_index_size, |
|
231 | 245 | data_end=data_size, |
@@ -67,3 +67,19 b' Header written as expected' | |||
|
67 | 67 | $ f --hexdump --bytes 4 .hg/store/data/foo.i |
|
68 | 68 | .hg/store/data/foo.i: |
|
69 | 69 | 0000: 00 00 de ad |....| |
|
70 | ||
|
71 | The expected files are generated | |
|
72 | -------------------------------- | |
|
73 | ||
|
74 | We should have have: | |
|
75 | - a docket | |
|
76 | - a index file with a unique name | |
|
77 | - a data file | |
|
78 | ||
|
79 | $ ls .hg/store/00changelog* .hg/store/00manifest* | |
|
80 | .hg/store/00changelog-b870a51b.idx | |
|
81 | .hg/store/00changelog.d | |
|
82 | .hg/store/00changelog.i | |
|
83 | .hg/store/00manifest-88698448.idx | |
|
84 | .hg/store/00manifest.d | |
|
85 | .hg/store/00manifest.i |
General Comments 0
You need to be logged in to leave comments.
Login now