Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 36011:82afb1a5ed94
revlog: use context manager for data file lifetime in checksize
This is clearer, safer and more modern.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 05 Feb 2018 17:35:14 +0100 |
parents | 0f2c51afafb2 |
children | 4d66993bdcff |
comparison
equal
deleted
inserted
replaced
36010:0f2c51afafb2 | 36011:82afb1a5ed94 |
---|---|
2333 expected = 0 | 2333 expected = 0 |
2334 if len(self): | 2334 if len(self): |
2335 expected = max(0, self.end(len(self) - 1)) | 2335 expected = max(0, self.end(len(self) - 1)) |
2336 | 2336 |
2337 try: | 2337 try: |
2338 f = self._datafp() | 2338 with self._datafp() as f: |
2339 f.seek(0, 2) | 2339 f.seek(0, 2) |
2340 actual = f.tell() | 2340 actual = f.tell() |
2341 f.close() | |
2342 dd = actual - expected | 2341 dd = actual - expected |
2343 except IOError as inst: | 2342 except IOError as inst: |
2344 if inst.errno != errno.ENOENT: | 2343 if inst.errno != errno.ENOENT: |
2345 raise | 2344 raise |
2346 dd = 0 | 2345 dd = 0 |