[PATCH 4 of 5] check-code: switch to opener

timeless timeless at fmr.im
Wed May 11 00:12:49 EDT 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1462931079 0
#      Wed May 11 01:44:39 2016 +0000
# Node ID ed2dbfec165a0de79c93d7fa1ea9cb5f36b10c29
# Parent  5a3db5d3f5259541fbf4d5e2aaf7d055e35b5d9a
# EXP-Topic runtests
# Available At bb://timeless/mercurial-crew
#              hg pull bb://timeless/mercurial-crew -r ed2dbfec165a
check-code: switch to opener

diff -r 5a3db5d3f525 -r ed2dbfec165a contrib/check-code.py
--- a/contrib/check-code.py	Wed May 11 01:39:07 2016 +0000
+++ b/contrib/check-code.py	Wed May 11 01:44:39 2016 +0000
@@ -493,12 +493,11 @@
     result = True
 
     try:
-        fp = open(f)
+        with open(f) as fp:
+            pre = post = fp.read()
     except IOError as e:
         print("Skipping %s, %s" % (f, str(e).split(':', 1)[0]))
         return result
-    pre = post = fp.read()
-    fp.close()
 
     for name, match, magic, filters, pats in checks:
         if debug:


More information about the Mercurial-devel mailing list