[PATCH 11 of 13] revlog: use context manager for data file lifetime in checksize
Boris Feld
boris.feld at octobus.net
Tue Feb 6 13:21:32 UTC 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1517848514 -3600
# Mon Feb 05 17:35:14 2018 +0100
# Node ID 9073bbc68cb1ccc5685c78dbe837f31406324028
# Parent 1a212682563740e031380befc949167e73b476bd
# EXP-Topic revlog-fp
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9073bbc68cb1
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:
More information about the Mercurial-devel
mailing list