comparison mercurial/obsolete.py @ 26310:61efe9ef6ad4

obsstore: fast path to check if obsstore is empty
author Yuya Nishihara <yuya@tcha.org>
date Sun, 13 Sep 2015 18:01:01 +0900
parents 44918682093f
children 56b2bcea2529
comparison
equal deleted inserted replaced
26309:44918682093f 26310:61efe9ef6ad4
65 65
66 The header is followed by the markers. Marker format depend of the version. See 66 The header is followed by the markers. Marker format depend of the version. See
67 comment associated with each format for details. 67 comment associated with each format for details.
68 68
69 """ 69 """
70 import struct 70 import errno, struct
71 import util, base85, node, parsers 71 import util, base85, node, parsers
72 import phases 72 import phases
73 from i18n import _ 73 from i18n import _
74 74
75 _pack = struct.pack 75 _pack = struct.pack
529 529
530 def __len__(self): 530 def __len__(self):
531 return len(self._all) 531 return len(self._all)
532 532
533 def __nonzero__(self): 533 def __nonzero__(self):
534 if not self._cached('_all'):
535 try:
536 return self.svfs.stat('obsstore').st_size > 1
537 except OSError as inst:
538 if inst.errno != errno.ENOENT:
539 raise
540 # just build an empty _all list if no obsstore exists, which
541 # avoids further stat() syscalls
542 pass
534 return bool(self._all) 543 return bool(self._all)
535 544
536 def create(self, transaction, prec, succs=(), flag=0, parents=None, 545 def create(self, transaction, prec, succs=(), flag=0, parents=None,
537 date=None, metadata=None): 546 date=None, metadata=None):
538 """obsolete: add a new obsolete marker 547 """obsolete: add a new obsolete marker