changeset 3661:e99ba8726bda

remove duplicate zgenerator in httprepo
author Matt Mackall <mpm@selenic.com>
date Wed, 15 Nov 2006 15:51:58 -0600
parents 8500a13ec44b
children f4dc02d7fb71
files mercurial/httprepo.py
diffstat 1 files changed, 11 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httprepo.py	Wed Nov 15 15:51:58 2006 -0600
+++ b/mercurial/httprepo.py	Wed Nov 15 15:51:58 2006 -0600
@@ -114,6 +114,15 @@
     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 @@
     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