##// 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 b' class revlog(object):'
621 621 indexdata = ''
622 622 self._initempty = True
623 623 try:
624 f = self._indexfp()
625 if (mmapindexthreshold is not None and
626 self.opener.fstat(f).st_size >= mmapindexthreshold):
627 indexdata = util.buffer(util.mmapread(f))
628 else:
629 indexdata = f.read()
630 f.close()
624 with self._indexfp() as f:
625 if (mmapindexthreshold is not None and
626 self.opener.fstat(f).st_size >= mmapindexthreshold):
627 indexdata = util.buffer(util.mmapread(f))
628 else:
629 indexdata = f.read()
631 630 if len(indexdata) > 0:
632 631 v = versionformat_unpack(indexdata[:4])[0]
633 632 self._initempty = False
General Comments 0
You need to be logged in to leave comments. Login now