##// END OF EJS Templates
obsstore: fast path to check if obsstore is empty
Yuya Nishihara -
r26310:61efe9ef default
parent child Browse files
Show More
@@ -67,7 +67,7 b' The header is followed by the markers. M'
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 _
@@ -531,6 +531,15 b' class obsstore(object):'
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,
General Comments 0
You need to be logged in to leave comments. Login now