mercurial/httppeer.py
branchstable
changeset 23086 cde6904f1992
parent 21188 d36440d84328
child 23895 cda18ded2c48
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):