# HG changeset patch # User Boris Feld # Date 2018-02-05 16:35:14 # Node ID 82afb1a5ed94a20f2cf8a4ff05e512654bb55dff # Parent 0f2c51afafb28952f4279de1fe442cb7f437b454 revlog: use context manager for data file lifetime in checksize This is clearer, safer and more modern. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -2335,10 +2335,9 @@ class revlog(object): expected = max(0, self.end(len(self) - 1)) try: - f = self._datafp() - f.seek(0, 2) - actual = f.tell() - f.close() + with self._datafp() as f: + f.seek(0, 2) + actual = f.tell() dd = actual - expected except IOError as inst: if inst.errno != errno.ENOENT: