##// END OF EJS Templates
revlog: move the `trypending` logic from the `changelog` to the `revlog`...
marmoute -
r48014:4f38ada3 default
parent child Browse files
Show More
@@ -396,21 +396,16 class changelog(revlog.revlog):
396 the documentation there.
396 the documentation there.
397 """
397 """
398
398
399 if trypending and opener.exists(b'00changelog.i.a'):
400 postfix = b'a'
401 else:
402 postfix = None
403
404 revlog.revlog.__init__(
399 revlog.revlog.__init__(
405 self,
400 self,
406 opener,
401 opener,
407 target=(revlog_constants.KIND_CHANGELOG, None),
402 target=(revlog_constants.KIND_CHANGELOG, None),
408 radix=b'00changelog',
403 radix=b'00changelog',
409 postfix=postfix,
410 checkambig=True,
404 checkambig=True,
411 mmaplargeindex=True,
405 mmaplargeindex=True,
412 persistentnodemap=opener.options.get(b'persistent-nodemap', False),
406 persistentnodemap=opener.options.get(b'persistent-nodemap', False),
413 concurrencychecker=concurrencychecker,
407 concurrencychecker=concurrencychecker,
408 trypending=trypending,
414 )
409 )
415
410
416 if self._initempty and (self._format_version == revlog.REVLOGV1):
411 if self._initempty and (self._format_version == revlog.REVLOGV1):
@@ -293,13 +293,14 class revlog(object):
293 opener,
293 opener,
294 target,
294 target,
295 radix,
295 radix,
296 postfix=None,
296 postfix=None, # only exist for `tmpcensored` now
297 checkambig=False,
297 checkambig=False,
298 mmaplargeindex=False,
298 mmaplargeindex=False,
299 censorable=False,
299 censorable=False,
300 upperboundcomp=None,
300 upperboundcomp=None,
301 persistentnodemap=False,
301 persistentnodemap=False,
302 concurrencychecker=None,
302 concurrencychecker=None,
303 trypending=False,
303 ):
304 ):
304 """
305 """
305 create a revlog object
306 create a revlog object
@@ -323,6 +324,7 class revlog(object):
323 self._datafile = None
324 self._datafile = None
324 self._nodemap_file = None
325 self._nodemap_file = None
325 self.postfix = postfix
326 self.postfix = postfix
327 self._trypending = trypending
326 self.opener = opener
328 self.opener = opener
327 if persistentnodemap:
329 if persistentnodemap:
328 self._nodemap_file = nodemaputil.get_nodemap_file(self)
330 self._nodemap_file = nodemaputil.get_nodemap_file(self)
@@ -484,10 +486,12 class revlog(object):
484
486
485 new_header, mmapindexthreshold, force_nodemap = self._init_opts()
487 new_header, mmapindexthreshold, force_nodemap = self._init_opts()
486
488
487 if self.postfix is None:
489 if self.postfix is not None:
490 entry_point = b'%s.i.%s' % (self.radix, self.postfix)
491 elif self._trypending and self.opener.exists(b'%s.i.a' % self.radix):
492 entry_point = b'%s.i.a' % self.radix
493 else:
488 entry_point = b'%s.i' % self.radix
494 entry_point = b'%s.i' % self.radix
489 else:
490 entry_point = b'%s.i.%s' % (self.radix, self.postfix)
491
495
492 entry_data = b''
496 entry_data = b''
493 self._initempty = True
497 self._initempty = True
@@ -545,7 +549,7 class revlog(object):
545 # main docket, so disable it for now.
549 # main docket, so disable it for now.
546 self._nodemap_file = None
550 self._nodemap_file = None
547
551
548 if self.postfix is None or self.postfix == b'a':
552 if self.postfix is None:
549 self._datafile = b'%s.d' % self.radix
553 self._datafile = b'%s.d' % self.radix
550 else:
554 else:
551 self._datafile = b'%s.d.%s' % (self.radix, self.postfix)
555 self._datafile = b'%s.d.%s' % (self.radix, self.postfix)
@@ -2067,6 +2071,10 class revlog(object):
2067
2071
2068 @contextlib.contextmanager
2072 @contextlib.contextmanager
2069 def _writing(self, transaction):
2073 def _writing(self, transaction):
2074 if self._trypending:
2075 msg = b'try to write in a `trypending` revlog: %s'
2076 msg %= self.display_id
2077 raise error.ProgrammingError(msg)
2070 if self._writinghandles is not None:
2078 if self._writinghandles is not None:
2071 yield
2079 yield
2072 else:
2080 else:
@@ -649,7 +649,7 def _find_node(block, node):
649
649
650
650
651 def get_nodemap_file(revlog):
651 def get_nodemap_file(revlog):
652 if revlog.postfix == b'a':
652 if revlog._trypending:
653 pending_path = revlog.radix + b".n.a"
653 pending_path = revlog.radix + b".n.a"
654 if revlog.opener.exists(pending_path):
654 if revlog.opener.exists(pending_path):
655 return pending_path
655 return pending_path
General Comments 0
You need to be logged in to leave comments. Login now