##// END OF EJS Templates
revlogv2: use a unique filename for data...
marmoute -
r48105:5035d31e default draft
parent child Browse files
Show More
@@ -628,7 +628,9 b' class revlog(object):'
628 # main docket, so disable it for now.
628 # main docket, so disable it for now.
629 self._nodemap_file = None
629 self._nodemap_file = None
630
630
631 if self.postfix is None:
631 if self._docket is not None:
632 self._datafile = self._docket.data_filepath()
633 elif self.postfix is None:
632 self._datafile = b'%s.d' % self.radix
634 self._datafile = b'%s.d' % self.radix
633 else:
635 else:
634 self._datafile = b'%s.d.%s' % (self.radix, self.postfix)
636 self._datafile = b'%s.d.%s' % (self.radix, self.postfix)
@@ -89,12 +89,13 b' if stable_docket_file:'
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 # * 1 bytes: size of index uuid
92 # * 1 bytes: size of data uuid
92 # * 8 bytes: size of index-data
93 # * 8 bytes: size of index-data
93 # * 8 bytes: pending size of index-data
94 # * 8 bytes: pending size of index-data
94 # * 8 bytes: size of data
95 # * 8 bytes: size of data
95 # * 8 bytes: pending size of data
96 # * 8 bytes: pending size of data
96 # * 1 bytes: default compression header
97 # * 1 bytes: default compression header
97 S_HEADER = struct.Struct(constants.INDEX_HEADER.format + 'BLLLLc')
98 S_HEADER = struct.Struct(constants.INDEX_HEADER.format + 'BBLLLLc')
98
99
99
100
100 class RevlogDocket(object):
101 class RevlogDocket(object):
@@ -106,6 +107,7 b' class RevlogDocket(object):'
106 use_pending=False,
107 use_pending=False,
107 version_header=None,
108 version_header=None,
108 index_uuid=None,
109 index_uuid=None,
110 data_uuid=None,
109 index_end=0,
111 index_end=0,
110 pending_index_end=0,
112 pending_index_end=0,
111 data_end=0,
113 data_end=0,
@@ -119,6 +121,7 b' class RevlogDocket(object):'
119 self._path = revlog._docket_file
121 self._path = revlog._docket_file
120 self._opener = revlog.opener
122 self._opener = revlog.opener
121 self._index_uuid = index_uuid
123 self._index_uuid = index_uuid
124 self._data_uuid = data_uuid
122 # thes asserts should be True as long as we have a single index filename
125 # thes asserts should be True as long as we have a single index filename
123 assert index_end <= pending_index_end
126 assert index_end <= pending_index_end
124 assert data_end <= pending_data_end
127 assert data_end <= pending_data_end
@@ -141,6 +144,13 b' class RevlogDocket(object):'
141 self._index_uuid = make_uid()
144 self._index_uuid = make_uid()
142 return b"%s-%s.idx" % (self._radix, self._index_uuid)
145 return b"%s-%s.idx" % (self._radix, self._index_uuid)
143
146
147 def data_filepath(self):
148 """file path to the current index file associated to this docket"""
149 # very simplistic version at first
150 if self._data_uuid is None:
151 self._data_uuid = make_uid()
152 return b"%s-%s.dat" % (self._radix, self._data_uuid)
153
144 @property
154 @property
145 def index_end(self):
155 def index_end(self):
146 return self._index_end
156 return self._index_end
@@ -195,6 +205,7 b' class RevlogDocket(object):'
195 data = (
205 data = (
196 self._version_header,
206 self._version_header,
197 len(self._index_uuid),
207 len(self._index_uuid),
208 len(self._data_uuid),
198 official_index_end,
209 official_index_end,
199 self._index_end,
210 self._index_end,
200 official_data_end,
211 official_data_end,
@@ -204,6 +215,7 b' class RevlogDocket(object):'
204 s = []
215 s = []
205 s.append(S_HEADER.pack(*data))
216 s.append(S_HEADER.pack(*data))
206 s.append(self._index_uuid)
217 s.append(self._index_uuid)
218 s.append(self._data_uuid)
207 return b''.join(s)
219 return b''.join(s)
208
220
209
221
@@ -230,16 +242,20 b' def parse_docket(revlog, data, use_pendi'
230 index_uuid_size = header[1]
242 index_uuid_size = header[1]
231 index_uuid = data[offset : offset + index_uuid_size]
243 index_uuid = data[offset : offset + index_uuid_size]
232 offset += index_uuid_size
244 offset += index_uuid_size
233 index_size = header[2]
245 data_uuid_size = header[2]
234 pending_index_size = header[3]
246 data_uuid = data[offset : offset + data_uuid_size]
235 data_size = header[4]
247 offset += data_uuid_size
236 pending_data_size = header[5]
248 index_size = header[3]
237 default_compression_header = header[6]
249 pending_index_size = header[4]
250 data_size = header[5]
251 pending_data_size = header[6]
252 default_compression_header = header[7]
238 docket = RevlogDocket(
253 docket = RevlogDocket(
239 revlog,
254 revlog,
240 use_pending=use_pending,
255 use_pending=use_pending,
241 version_header=version_header,
256 version_header=version_header,
242 index_uuid=index_uuid,
257 index_uuid=index_uuid,
258 data_uuid=data_uuid,
243 index_end=index_size,
259 index_end=index_size,
244 pending_index_end=pending_index_size,
260 pending_index_end=pending_index_size,
245 data_end=data_size,
261 data_end=data_size,
@@ -389,7 +389,14 b' def _calcmode(vfs):'
389 ]
389 ]
390
390
391 REVLOG_FILES_MAIN_EXT = (b'.i', b'i.tmpcensored')
391 REVLOG_FILES_MAIN_EXT = (b'.i', b'i.tmpcensored')
392 REVLOG_FILES_OTHER_EXT = (b'.idx', b'.d', b'.n', b'.nd', b'd.tmpcensored')
392 REVLOG_FILES_OTHER_EXT = (
393 b'.idx',
394 b'.d',
395 b'.dat',
396 b'.n',
397 b'.nd',
398 b'd.tmpcensored',
399 )
393 # files that are "volatile" and might change between listing and streaming
400 # files that are "volatile" and might change between listing and streaming
394 #
401 #
395 # note: the ".nd" file are nodemap data and won't "change" but they might be
402 # note: the ".nd" file are nodemap data and won't "change" but they might be
@@ -414,6 +421,7 b' def revlog_type(f):'
414 if f.endswith(REVLOG_FILES_VOLATILE_EXT):
421 if f.endswith(REVLOG_FILES_VOLATILE_EXT):
415 t |= FILEFLAGS_VOLATILE
422 t |= FILEFLAGS_VOLATILE
416 return t
423 return t
424 return None
417
425
418
426
419 # the file is part of changelog data
427 # the file is part of changelog data
@@ -753,6 +761,7 b' class fncachestore(basicstore):'
753 ef = self.encode(f)
761 ef = self.encode(f)
754 try:
762 try:
755 t = revlog_type(f)
763 t = revlog_type(f)
764 assert t is not None, f
756 t |= FILEFLAGS_FILELOG
765 t |= FILEFLAGS_FILELOG
757 yield t, f, ef, self.getsize(ef)
766 yield t, f, ef, self.getsize(ef)
758 except OSError as err:
767 except OSError as err:
@@ -58,6 +58,7 b' Writing a simple revlog v2 works'
58 date: Thu Jan 01 00:00:00 1970 +0000
58 date: Thu Jan 01 00:00:00 1970 +0000
59 summary: initial
59 summary: initial
60
60
61
61 Header written as expected
62 Header written as expected
62
63
63 $ f --hexdump --bytes 4 .hg/store/00changelog.i
64 $ f --hexdump --bytes 4 .hg/store/00changelog.i
@@ -77,9 +78,9 b' We should have have:'
77 - a data file
78 - a data file
78
79
79 $ ls .hg/store/00changelog* .hg/store/00manifest*
80 $ ls .hg/store/00changelog* .hg/store/00manifest*
80 .hg/store/00changelog-b870a51b.idx
81 .hg/store/00changelog-6b8ab34b.dat
81 .hg/store/00changelog.d
82 .hg/store/00changelog-88698448.idx
82 .hg/store/00changelog.i
83 .hg/store/00changelog.i
83 .hg/store/00manifest-88698448.idx
84 .hg/store/00manifest-1335303a.dat
84 .hg/store/00manifest.d
85 .hg/store/00manifest-b875dfc5.idx
85 .hg/store/00manifest.i
86 .hg/store/00manifest.i
General Comments 0
You need to be logged in to leave comments. Login now