changeset 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
files mercurial/revlog.py
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Mon Feb 05 17:34:57 2018 +0100
+++ b/mercurial/revlog.py	Mon Feb 05 17:35:14 2018 +0100
@@ -2335,10 +2335,9 @@
             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: