equal
deleted
inserted
replaced
32 wdirrev, |
32 wdirrev, |
33 ) |
33 ) |
34 from .i18n import _ |
34 from .i18n import _ |
35 from .pycompat import getattr |
35 from .pycompat import getattr |
36 from .revlogutils.constants import ( |
36 from .revlogutils.constants import ( |
|
37 ALL_KINDS, |
37 FLAG_GENERALDELTA, |
38 FLAG_GENERALDELTA, |
38 FLAG_INLINE_DATA, |
39 FLAG_INLINE_DATA, |
39 INDEX_HEADER, |
40 INDEX_HEADER, |
40 REVLOGV0, |
41 REVLOGV0, |
41 REVLOGV1, |
42 REVLOGV1, |
285 _flagserrorclass = error.RevlogError |
286 _flagserrorclass = error.RevlogError |
286 |
287 |
287 def __init__( |
288 def __init__( |
288 self, |
289 self, |
289 opener, |
290 opener, |
290 indexfile, |
291 target, |
|
292 indexfile=None, |
291 datafile=None, |
293 datafile=None, |
292 checkambig=False, |
294 checkambig=False, |
293 mmaplargeindex=False, |
295 mmaplargeindex=False, |
294 censorable=False, |
296 censorable=False, |
295 upperboundcomp=None, |
297 upperboundcomp=None, |
300 create a revlog object |
302 create a revlog object |
301 |
303 |
302 opener is a function that abstracts the file opening operation |
304 opener is a function that abstracts the file opening operation |
303 and can be used to implement COW semantics or the like. |
305 and can be used to implement COW semantics or the like. |
304 |
306 |
|
307 `target`: a (KIND, ID) tuple that identify the content stored in |
|
308 this revlog. It help the rest of the code to understand what the revlog |
|
309 is about without having to resort to heuristic and index filename |
|
310 analysis. Note: that this must be reliably be set by normal code, but |
|
311 that test, debug, or performance measurement code might not set this to |
|
312 accurate value. |
305 """ |
313 """ |
306 self.upperboundcomp = upperboundcomp |
314 self.upperboundcomp = upperboundcomp |
307 self.indexfile = indexfile |
315 self.indexfile = indexfile |
308 self.datafile = datafile or (indexfile[:-2] + b".d") |
316 self.datafile = datafile or (indexfile[:-2] + b".d") |
309 self.nodemap_file = None |
317 self.nodemap_file = None |
311 self.nodemap_file = nodemaputil.get_nodemap_file( |
319 self.nodemap_file = nodemaputil.get_nodemap_file( |
312 opener, self.indexfile |
320 opener, self.indexfile |
313 ) |
321 ) |
314 |
322 |
315 self.opener = opener |
323 self.opener = opener |
|
324 assert target[0] in ALL_KINDS |
|
325 assert len(target) == 2 |
|
326 self.target = target |
316 # When True, indexfile is opened with checkambig=True at writing, to |
327 # When True, indexfile is opened with checkambig=True at writing, to |
317 # avoid file stat ambiguity. |
328 # avoid file stat ambiguity. |
318 self._checkambig = checkambig |
329 self._checkambig = checkambig |
319 self._mmaplargeindex = mmaplargeindex |
330 self._mmaplargeindex = mmaplargeindex |
320 self._censorable = censorable |
331 self._censorable = censorable |
2867 |
2878 |
2868 newindexfile = self.indexfile + b'.tmpcensored' |
2879 newindexfile = self.indexfile + b'.tmpcensored' |
2869 newdatafile = self.datafile + b'.tmpcensored' |
2880 newdatafile = self.datafile + b'.tmpcensored' |
2870 |
2881 |
2871 # This is a bit dangerous. We could easily have a mismatch of state. |
2882 # This is a bit dangerous. We could easily have a mismatch of state. |
2872 newrl = revlog(self.opener, newindexfile, newdatafile, censorable=True) |
2883 newrl = revlog( |
|
2884 self.opener, |
|
2885 target=self.target, |
|
2886 indexfile=newindexfile, |
|
2887 datafile=newdatafile, |
|
2888 censorable=True, |
|
2889 ) |
2873 newrl.version = self.version |
2890 newrl.version = self.version |
2874 newrl._generaldelta = self._generaldelta |
2891 newrl._generaldelta = self._generaldelta |
2875 newrl._parse_index = self._parse_index |
2892 newrl._parse_index = self._parse_index |
2876 |
2893 |
2877 for rev in self.revs(): |
2894 for rev in self.revs(): |