##// END OF EJS Templates
revlog: use context manager for index file life time in __init__...
Boris Feld -
r35987:1f2b8a64 default
parent child Browse files
Show More
@@ -621,13 +621,12 class revlog(object):
621 indexdata = ''
621 indexdata = ''
622 self._initempty = True
622 self._initempty = True
623 try:
623 try:
624 f = self._indexfp()
624 with self._indexfp() as f:
625 if (mmapindexthreshold is not None and
625 if (mmapindexthreshold is not None and
626 self.opener.fstat(f).st_size >= mmapindexthreshold):
626 self.opener.fstat(f).st_size >= mmapindexthreshold):
627 indexdata = util.buffer(util.mmapread(f))
627 indexdata = util.buffer(util.mmapread(f))
628 else:
628 else:
629 indexdata = f.read()
629 indexdata = f.read()
630 f.close()
631 if len(indexdata) > 0:
630 if len(indexdata) > 0:
632 v = versionformat_unpack(indexdata[:4])[0]
631 v = versionformat_unpack(indexdata[:4])[0]
633 self._initempty = False
632 self._initempty = False
General Comments 0
You need to be logged in to leave comments. Login now