comparison mercurial/httprepo.py @ 3668:e99ba8726bda

remove duplicate zgenerator in httprepo
author Matt Mackall <mpm@selenic.com>
date Wed, 15 Nov 2006 15:51:58 -0600
parents fd7a018b7db7
children f4dc02d7fb71
comparison
equal deleted inserted replaced
3667:8500a13ec44b 3668:e99ba8726bda
111 def https_open(self, req): 111 def https_open(self, req):
112 return self.do_open(httpsconnection, req) 112 return self.do_open(httpsconnection, req)
113 else: 113 else:
114 class httphandler(basehttphandler): 114 class httphandler(basehttphandler):
115 pass 115 pass
116
117 def zgenerator(f):
118 zd = zlib.decompressobj()
119 try:
120 for chunk in util.filechunkiter(f):
121 yield zd.decompress(chunk)
122 except httplib.HTTPException, inst:
123 raise IOError(None, _('connection ended unexpectedly'))
124 yield zd.flush()
116 125
117 class httprepository(remoterepository): 126 class httprepository(remoterepository):
118 def __init__(self, ui, path): 127 def __init__(self, ui, path):
119 self.path = path 128 self.path = path
120 self.caps = None 129 self.caps = None
303 raise util.UnexpectedOutput(_("unexpected response:"), d) 312 raise util.UnexpectedOutput(_("unexpected response:"), d)
304 313
305 def changegroup(self, nodes, kind): 314 def changegroup(self, nodes, kind):
306 n = " ".join(map(hex, nodes)) 315 n = " ".join(map(hex, nodes))
307 f = self.do_cmd("changegroup", roots=n) 316 f = self.do_cmd("changegroup", roots=n)
308 317 return util.chunkbuffer(zgenerator(f))
309 def zgenerator(f):
310 zd = zlib.decompressobj()
311 try:
312 for chnk in f:
313 yield zd.decompress(chnk)
314 except httplib.HTTPException, inst:
315 raise IOError(None, _('connection ended unexpectedly'))
316 yield zd.flush()
317
318 return util.chunkbuffer(zgenerator(util.filechunkiter(f)))
319 318
320 def changegroupsubset(self, bases, heads, source): 319 def changegroupsubset(self, bases, heads, source):
321 baselst = " ".join([hex(n) for n in bases]) 320 baselst = " ".join([hex(n) for n in bases])
322 headlst = " ".join([hex(n) for n in heads]) 321 headlst = " ".join([hex(n) for n in heads])
323 f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst) 322 f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst)
324 323 return util.chunkbuffer(zgenerator(f))
325 def zgenerator(f):
326 zd = zlib.decompressobj()
327 try:
328 for chnk in f:
329 yield zd.decompress(chnk)
330 except httplib.HTTPException:
331 raise IOError(None, _('connection ended unexpectedly'))
332 yield zd.flush()
333
334 return util.chunkbuffer(zgenerator(util.filechunkiter(f)))
335 324
336 def unbundle(self, cg, heads, source): 325 def unbundle(self, cg, heads, source):
337 # have to stream bundle to a temp file because we do not have 326 # have to stream bundle to a temp file because we do not have
338 # http 1.1 chunked transfer. 327 # http 1.1 chunked transfer.
339 328