# HG changeset patch # User Alexis S. L. Carvalho # Date 1151897038 10800 # Node ID 1727ff712a4e57416c3f6af326395ed12734af86 # Parent f1ebc4311f4738da7efa1b073065c78a9f2cb20f Fix push over https. Without this patch, python gives me a TypeError: write() argument 1 must be string or read-only buffer, not file diff -r f1ebc4311f47 -r 1727ff712a4e mercurial/httprepo.py --- a/mercurial/httprepo.py Mon Jul 03 00:23:56 2006 -0300 +++ b/mercurial/httprepo.py Mon Jul 03 00:23:58 2006 -0300 @@ -91,6 +91,22 @@ def http_open(self, req): return self.do_open(httpconnection, req) +class httpsconnection(httplib.HTTPSConnection): + # must be able to send big bundle as stream. + + def send(self, data): + if isinstance(data, str): + httplib.HTTPSConnection.send(self, data) + else: + # if auth required, some data sent twice, so rewind here + data.seek(0) + for chunk in util.filechunkiter(data): + httplib.HTTPSConnection.send(self, chunk) + +class httpshandler(urllib2.HTTPSHandler): + def https_open(self, req): + return self.do_open(httpsconnection, req) + class httprepository(remoterepository): def __init__(self, ui, path): self.caps = None @@ -160,6 +176,7 @@ opener = urllib2.build_opener( handler, + httpshandler(), urllib2.HTTPBasicAuthHandler(passmgr), urllib2.HTTPDigestAuthHandler(passmgr))