##// 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 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 399 revlog.revlog.__init__(
405 400 self,
406 401 opener,
407 402 target=(revlog_constants.KIND_CHANGELOG, None),
408 403 radix=b'00changelog',
409 postfix=postfix,
410 404 checkambig=True,
411 405 mmaplargeindex=True,
412 406 persistentnodemap=opener.options.get(b'persistent-nodemap', False),
413 407 concurrencychecker=concurrencychecker,
408 trypending=trypending,
414 409 )
415 410
416 411 if self._initempty and (self._format_version == revlog.REVLOGV1):
@@ -293,13 +293,14 class revlog(object):
293 293 opener,
294 294 target,
295 295 radix,
296 postfix=None,
296 postfix=None, # only exist for `tmpcensored` now
297 297 checkambig=False,
298 298 mmaplargeindex=False,
299 299 censorable=False,
300 300 upperboundcomp=None,
301 301 persistentnodemap=False,
302 302 concurrencychecker=None,
303 trypending=False,
303 304 ):
304 305 """
305 306 create a revlog object
@@ -323,6 +324,7 class revlog(object):
323 324 self._datafile = None
324 325 self._nodemap_file = None
325 326 self.postfix = postfix
327 self._trypending = trypending
326 328 self.opener = opener
327 329 if persistentnodemap:
328 330 self._nodemap_file = nodemaputil.get_nodemap_file(self)
@@ -484,10 +486,12 class revlog(object):
484 486
485 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 494 entry_point = b'%s.i' % self.radix
489 else:
490 entry_point = b'%s.i.%s' % (self.radix, self.postfix)
491 495
492 496 entry_data = b''
493 497 self._initempty = True
@@ -545,7 +549,7 class revlog(object):
545 549 # main docket, so disable it for now.
546 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 553 self._datafile = b'%s.d' % self.radix
550 554 else:
551 555 self._datafile = b'%s.d.%s' % (self.radix, self.postfix)
@@ -2067,6 +2071,10 class revlog(object):
2067 2071
2068 2072 @contextlib.contextmanager
2069 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 2078 if self._writinghandles is not None:
2071 2079 yield
2072 2080 else:
@@ -649,7 +649,7 def _find_node(block, node):
649 649
650 650
651 651 def get_nodemap_file(revlog):
652 if revlog.postfix == b'a':
652 if revlog._trypending:
653 653 pending_path = revlog.radix + b".n.a"
654 654 if revlog.opener.exists(pending_path):
655 655 return pending_path
General Comments 0
You need to be logged in to leave comments. Login now