##// END OF EJS Templates
httppeer: use context manager when writing temporary bundle to send...
Martin von Zweigbergk -
r43118:58f73e9c default
parent child Browse files
Show More
@@ -490,18 +490,16 b' class httppeer(wireprotov1peer.wirepeer)'
490 490 os.unlink(tempname)
491 491
492 492 def _calltwowaystream(self, cmd, fp, **args):
493 fh = None
494 493 fp_ = None
495 494 filename = None
496 495 try:
497 496 # dump bundle to disk
498 497 fd, filename = pycompat.mkstemp(prefix="hg-bundle-", suffix=".hg")
499 fh = os.fdopen(fd, r"wb")
500 d = fp.read(4096)
501 while d:
502 fh.write(d)
498 with os.fdopen(fd, r"wb") as fh:
503 499 d = fp.read(4096)
504 fh.close()
500 while d:
501 fh.write(d)
502 d = fp.read(4096)
505 503 # start http push
506 504 fp_ = httpconnection.httpsendfile(self.ui, filename, "rb")
507 505 headers = {r'Content-Type': r'application/mercurial-0.1'}
@@ -509,8 +507,7 b' class httppeer(wireprotov1peer.wirepeer)'
509 507 finally:
510 508 if fp_ is not None:
511 509 fp_.close()
512 if fh is not None:
513 fh.close()
510 if filename is not None:
514 511 os.unlink(filename)
515 512
516 513 def _callcompressable(self, cmd, **args):
General Comments 0
You need to be logged in to leave comments. Login now