Mercurial > public > mercurial-scm > hg
comparison mercurial/httppeer.py @ 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 | d36440d84328 |
children | cda18ded2c48 |
comparison
equal
deleted
inserted
replaced
23085:e9165c18f8df | 23086:cde6904f1992 |
---|---|
212 fp.close() | 212 fp.close() |
213 os.unlink(tempname) | 213 os.unlink(tempname) |
214 | 214 |
215 def _calltwowaystream(self, cmd, fp, **args): | 215 def _calltwowaystream(self, cmd, fp, **args): |
216 fh = None | 216 fh = None |
217 fp_ = None | |
217 filename = None | 218 filename = None |
218 try: | 219 try: |
219 # dump bundle to disk | 220 # dump bundle to disk |
220 fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg") | 221 fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg") |
221 fh = os.fdopen(fd, "wb") | 222 fh = os.fdopen(fd, "wb") |
223 while d: | 224 while d: |
224 fh.write(d) | 225 fh.write(d) |
225 d = fp.read(4096) | 226 d = fp.read(4096) |
226 fh.close() | 227 fh.close() |
227 # start http push | 228 # start http push |
228 fp = httpconnection.httpsendfile(self.ui, filename, "rb") | 229 fp_ = httpconnection.httpsendfile(self.ui, filename, "rb") |
229 headers = {'Content-Type': 'application/mercurial-0.1'} | 230 headers = {'Content-Type': 'application/mercurial-0.1'} |
230 return self._callstream(cmd, data=fp, headers=headers, **args) | 231 return self._callstream(cmd, data=fp_, headers=headers, **args) |
231 finally: | 232 finally: |
233 if fp_ is not None: | |
234 fp_.close() | |
232 if fh is not None: | 235 if fh is not None: |
233 fh.close() | 236 fh.close() |
234 os.unlink(filename) | 237 os.unlink(filename) |
235 | 238 |
236 def _callcompressable(self, cmd, **args): | 239 def _callcompressable(self, cmd, **args): |