##// END OF EJS Templates
revlogv2: use a unique filename for index...
marmoute -
r48104:ce0e8971 default draft
parent child Browse files
Show More
@@ -88,12 +88,13 b' if stable_docket_file:'
88 # * 4 bytes: revlog version
88 # * 4 bytes: revlog version
89 # | This is mandatory as docket must be compatible with the previous
89 # | This is mandatory as docket must be compatible with the previous
90 # | revlog index header.
90 # | revlog index header.
91 # * 1 bytes: size of index uuid
91 # * 8 bytes: size of index-data
92 # * 8 bytes: size of index-data
92 # * 8 bytes: pending size of index-data
93 # * 8 bytes: pending size of index-data
93 # * 8 bytes: size of data
94 # * 8 bytes: size of data
94 # * 8 bytes: pending size of data
95 # * 8 bytes: pending size of data
95 # * 1 bytes: default compression header
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 class RevlogDocket(object):
100 class RevlogDocket(object):
@@ -104,6 +105,7 b' class RevlogDocket(object):'
104 revlog,
105 revlog,
105 use_pending=False,
106 use_pending=False,
106 version_header=None,
107 version_header=None,
108 index_uuid=None,
107 index_end=0,
109 index_end=0,
108 pending_index_end=0,
110 pending_index_end=0,
109 data_end=0,
111 data_end=0,
@@ -116,6 +118,7 b' class RevlogDocket(object):'
116 self._radix = revlog.radix
118 self._radix = revlog.radix
117 self._path = revlog._docket_file
119 self._path = revlog._docket_file
118 self._opener = revlog.opener
120 self._opener = revlog.opener
121 self._index_uuid = index_uuid
119 # thes asserts should be True as long as we have a single index filename
122 # thes asserts should be True as long as we have a single index filename
120 assert index_end <= pending_index_end
123 assert index_end <= pending_index_end
121 assert data_end <= pending_data_end
124 assert data_end <= pending_data_end
@@ -134,7 +137,9 b' class RevlogDocket(object):'
134 def index_filepath(self):
137 def index_filepath(self):
135 """file path to the current index file associated to this docket"""
138 """file path to the current index file associated to this docket"""
136 # very simplistic version at first
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 @property
144 @property
140 def index_end(self):
145 def index_end(self):
@@ -189,13 +194,17 b' class RevlogDocket(object):'
189 assert official_data_end <= self._data_end
194 assert official_data_end <= self._data_end
190 data = (
195 data = (
191 self._version_header,
196 self._version_header,
197 len(self._index_uuid),
192 official_index_end,
198 official_index_end,
193 self._index_end,
199 self._index_end,
194 official_data_end,
200 official_data_end,
195 self._data_end,
201 self._data_end,
196 self.default_compression_header,
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 def default_docket(revlog, version_header):
210 def default_docket(revlog, version_header):
@@ -216,16 +225,21 b' def default_docket(revlog, version_heade'
216 def parse_docket(revlog, data, use_pending=False):
225 def parse_docket(revlog, data, use_pending=False):
217 """given some docket data return a docket object for the given revlog"""
226 """given some docket data return a docket object for the given revlog"""
218 header = S_HEADER.unpack(data[: S_HEADER.size])
227 header = S_HEADER.unpack(data[: S_HEADER.size])
228 offset = S_HEADER.size
219 version_header = header[0]
229 version_header = header[0]
220 index_size = header[1]
230 index_uuid_size = header[1]
221 pending_index_size = header[2]
231 index_uuid = data[offset : offset + index_uuid_size]
222 data_size = header[3]
232 offset += index_uuid_size
223 pending_data_size = header[4]
233 index_size = header[2]
224 default_compression_header = header[5]
234 pending_index_size = header[3]
235 data_size = header[4]
236 pending_data_size = header[5]
237 default_compression_header = header[6]
225 docket = RevlogDocket(
238 docket = RevlogDocket(
226 revlog,
239 revlog,
227 use_pending=use_pending,
240 use_pending=use_pending,
228 version_header=version_header,
241 version_header=version_header,
242 index_uuid=index_uuid,
229 index_end=index_size,
243 index_end=index_size,
230 pending_index_end=pending_index_size,
244 pending_index_end=pending_index_size,
231 data_end=data_size,
245 data_end=data_size,
@@ -67,3 +67,19 b' Header written as expected'
67 $ f --hexdump --bytes 4 .hg/store/data/foo.i
67 $ f --hexdump --bytes 4 .hg/store/data/foo.i
68 .hg/store/data/foo.i:
68 .hg/store/data/foo.i:
69 0000: 00 00 de ad |....|
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