mercurial/util.py
changeset 13400 14f3795a5ed7
parent 13392 777cef34a890
child 13439 d724a69309e0
--- a/mercurial/util.py	Fri Feb 11 22:24:10 2011 +0800
+++ b/mercurial/util.py	Fri Dec 24 15:23:01 2010 +0100
@@ -198,7 +198,10 @@
         if code:
             raise Abort(_("command '%s' failed: %s") %
                         (cmd, explain_exit(code)))
-        return open(outname, 'rb').read()
+        fp = open(outname, 'rb')
+        r = fp.read()
+        fp.close()
+        return r
     finally:
         try:
             if inname:
@@ -591,7 +594,10 @@
             raise
     except AttributeError: # no symlink in os
         pass
-    return posixfile(pathname).read()
+    fp = posixfile(pathname)
+    r = fp.read()
+    fp.close()
+    return r
 
 def fstat(fp):
     '''stat file object that may not have fileno method.'''