revlog: use context manager for data file lifetime in checkinlinesize
authorBoris Feld <boris.feld@octobus.net>
Mon, 05 Feb 2018 17:34:47 +0100
changeset 35970 69cf2e422490
parent 35969 1f2b8a644dd4
child 35971 0f2c51afafb2
revlog: use context manager for data file lifetime in checkinlinesize This is clearer, safer and more modern.
mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Feb 05 17:34:19 2018 +0100
+++ b/mercurial/revlog.py	Mon Feb 05 17:34:47 2018 +0100
@@ -1859,12 +1859,9 @@
             fp.flush()
             fp.close()
 
-        df = self._datafp('w')
-        try:
+        with self._datafp('w') as df:
             for r in self:
                 df.write(self._getsegmentforrevs(r, r)[1])
-        finally:
-            df.close()
 
         fp = self._indexfp('w')
         self.version &= ~FLAG_INLINE_DATA