Skip to content
Snippets Groups Projects
Commit cde6904f authored by Matt Harbison's avatar Matt Harbison
Browse files

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]
parent e9165c18
No related branches found
No related tags found
No related merge requests found
......@@ -214,6 +214,7 @@
def _calltwowaystream(self, cmd, fp, **args):
fh = None
fp_ = None
filename = None
try:
# dump bundle to disk
......@@ -225,5 +226,5 @@
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'}
......@@ -229,3 +230,3 @@
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:
......@@ -231,4 +232,6 @@
finally:
if fp_ is not None:
fp_.close()
if fh is not None:
fh.close()
os.unlink(filename)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment