Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 47150:8d3c2f9d4af7
revlog: use a "radix" to address revlog
Instead of pointing to the index directly and to derive the other file from
that, we directly provide the radix and let the revlog determine the associated
file path internally. This is more robust and will give us more flexibility for
picking this file name in the future.
Differential Revision: https://phab.mercurial-scm.org/D10576
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 May 2021 12:22:36 +0200 |
parents | 396442cd7e6a |
children | 24be247a13b4 |
comparison
equal
deleted
inserted
replaced
47149:396442cd7e6a | 47150:8d3c2f9d4af7 |
---|---|
287 | 287 |
288 def __init__( | 288 def __init__( |
289 self, | 289 self, |
290 opener, | 290 opener, |
291 target, | 291 target, |
292 radix, | |
292 postfix=None, | 293 postfix=None, |
293 indexfile=None, | |
294 datafile=None, | |
295 checkambig=False, | 294 checkambig=False, |
296 mmaplargeindex=False, | 295 mmaplargeindex=False, |
297 censorable=False, | 296 censorable=False, |
298 upperboundcomp=None, | 297 upperboundcomp=None, |
299 persistentnodemap=False, | 298 persistentnodemap=False, |
311 analysis. Note: that this must be reliably be set by normal code, but | 310 analysis. Note: that this must be reliably be set by normal code, but |
312 that test, debug, or performance measurement code might not set this to | 311 that test, debug, or performance measurement code might not set this to |
313 accurate value. | 312 accurate value. |
314 """ | 313 """ |
315 self.upperboundcomp = upperboundcomp | 314 self.upperboundcomp = upperboundcomp |
316 if not indexfile.endswith(b'.i'): | 315 |
317 raise error.ProgrammingError( | 316 self.radix = radix |
318 b"revlog's indexfile should end with `.i`" | 317 |
319 ) | 318 if postfix is None: |
320 if datafile is None: | 319 indexfile = b'%s.i' % self.radix |
321 datafile = indexfile[:-2] + b".d" | 320 datafile = b'%s.d' % self.radix |
322 if postfix is not None: | 321 elif postfix == b'a': |
323 datafile = b'%s.%s' % (datafile, postfix) | 322 indexfile = b'%s.i.a' % self.radix |
324 if postfix is not None: | 323 datafile = b'%s.d' % self.radix |
325 indexfile = b'%s.%s' % (indexfile, postfix) | 324 else: |
325 indexfile = b'%s.i.%s' % (self.radix, postfix) | |
326 datafile = b'%s.d.%s' % (self.radix, postfix) | |
327 | |
326 self._indexfile = indexfile | 328 self._indexfile = indexfile |
327 self._datafile = datafile | 329 self._datafile = datafile |
328 self.nodemap_file = None | 330 self.nodemap_file = None |
329 self.postfix = postfix | 331 self.postfix = postfix |
330 if persistentnodemap: | 332 if persistentnodemap: |
2898 # | 2900 # |
2899 # This is a bit dangerous. We could easily have a mismatch of state. | 2901 # This is a bit dangerous. We could easily have a mismatch of state. |
2900 newrl = revlog( | 2902 newrl = revlog( |
2901 self.opener, | 2903 self.opener, |
2902 target=self.target, | 2904 target=self.target, |
2905 radix=self.radix, | |
2903 postfix=b'tmpcensored', | 2906 postfix=b'tmpcensored', |
2904 indexfile=self._indexfile, | |
2905 censorable=True, | 2907 censorable=True, |
2906 ) | 2908 ) |
2907 newrl._format_version = self._format_version | 2909 newrl._format_version = self._format_version |
2908 newrl._format_flags = self._format_flags | 2910 newrl._format_flags = self._format_flags |
2909 newrl._generaldelta = self._generaldelta | 2911 newrl._generaldelta = self._generaldelta |