changeset 23086:cde6904f1992 stable

httppeer: close the temporary bundle file after two-way streaming it This fixes several push tests in test-bundle2-exchange.t that were failing on Windows with messages like the following: $ hg -R main push http://localhost:$HGPORT2/ -r 32af7686d403 \ --bookmark book_32af pushing to http://localhost:$HGPORT2/ searching for changes remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files remote: 1 new obsolescence markers updating bookmark book_32af abort: The process cannot access the file because it is being used by another process: 'C:\path\to\tmp\bundle.hg' [255]
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 25 Oct 2014 21:34:49 -0400
parents e9165c18f8df
children 42342f9afe01
files mercurial/httppeer.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Fri Oct 24 14:24:28 2014 -0700
+++ b/mercurial/httppeer.py	Sat Oct 25 21:34:49 2014 -0400
@@ -214,6 +214,7 @@
 
     def _calltwowaystream(self, cmd, fp, **args):
         fh = None
+        fp_ = None
         filename = None
         try:
             # dump bundle to disk
@@ -225,10 +226,12 @@
                 d = fp.read(4096)
             fh.close()
             # start http push
-            fp = httpconnection.httpsendfile(self.ui, filename, "rb")
+            fp_ = httpconnection.httpsendfile(self.ui, filename, "rb")
             headers = {'Content-Type': 'application/mercurial-0.1'}
-            return self._callstream(cmd, data=fp, headers=headers, **args)
+            return self._callstream(cmd, data=fp_, headers=headers, **args)
         finally:
+            if fp_ is not None:
+                fp_.close()
             if fh is not None:
                 fh.close()
                 os.unlink(filename)