# HG changeset patch # User Matt Mackall # Date 1163627518 21600 # Node ID e99ba8726bda548247ca5f9187d18b7ae15fe190 # Parent 8500a13ec44b49993c06f97f9f772f34d065f350 remove duplicate zgenerator in httprepo diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -114,6 +114,15 @@ else: class httphandler(basehttphandler): pass +def zgenerator(f): + zd = zlib.decompressobj() + try: + for chunk in util.filechunkiter(f): + yield zd.decompress(chunk) + except httplib.HTTPException, inst: + raise IOError(None, _('connection ended unexpectedly')) + yield zd.flush() + class httprepository(remoterepository): def __init__(self, ui, path): self.path = path @@ -305,33 +314,13 @@ class httprepository(remoterepository): def changegroup(self, nodes, kind): n = " ".join(map(hex, nodes)) f = self.do_cmd("changegroup", roots=n) - - def zgenerator(f): - zd = zlib.decompressobj() - try: - for chnk in f: - yield zd.decompress(chnk) - except httplib.HTTPException, inst: - raise IOError(None, _('connection ended unexpectedly')) - yield zd.flush() - - return util.chunkbuffer(zgenerator(util.filechunkiter(f))) + return util.chunkbuffer(zgenerator(f)) def changegroupsubset(self, bases, heads, source): baselst = " ".join([hex(n) for n in bases]) headlst = " ".join([hex(n) for n in heads]) f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst) - - def zgenerator(f): - zd = zlib.decompressobj() - try: - for chnk in f: - yield zd.decompress(chnk) - except httplib.HTTPException: - raise IOError(None, _('connection ended unexpectedly')) - yield zd.flush() - - return util.chunkbuffer(zgenerator(util.filechunkiter(f))) + return util.chunkbuffer(zgenerator(f)) def unbundle(self, cg, heads, source): # have to stream bundle to a temp file because we do not have