# HG changeset patch # User Matt Harbison # Date 2014-10-26 01:34:49 # Node ID cde6904f199216d9c077e3db04bea4359fd4488c # Parent e9165c18f8dfd8a065f6c847c20b52befe3b5957 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] diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -214,6 +214,7 @@ class httppeer(wireproto.wirepeer): def _calltwowaystream(self, cmd, fp, **args): fh = None + fp_ = None filename = None try: # dump bundle to disk @@ -225,10 +226,12 @@ class httppeer(wireproto.wirepeer): 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)