Mercurial > public > mercurial-scm > hg
comparison mercurial/httprepo.py @ 1376:524ca4a06f70
Fix same performance bug as c3654cfaa77 but for httprepo.py instead.
author | Eric Hopper <hopper@omnifarious.org> |
---|---|
date | Mon, 03 Oct 2005 15:06:46 -0700 |
parents | 51ac9a79f3e5 |
children | 854775b27d1a |
comparison
equal
deleted
inserted
replaced
1375:f2b00be33e2c | 1376:524ca4a06f70 |
---|---|
121 def changegroup(self, nodes): | 121 def changegroup(self, nodes): |
122 n = " ".join(map(hex, nodes)) | 122 n = " ".join(map(hex, nodes)) |
123 f = self.do_cmd("changegroup", roots=n) | 123 f = self.do_cmd("changegroup", roots=n) |
124 bytes = 0 | 124 bytes = 0 |
125 | 125 |
126 class zread: | 126 def zgenerator(f): |
127 def __init__(self, f): | 127 zd = zlib.decompressobj() |
128 self.zd = zlib.decompressobj() | 128 for chnk in f: |
129 self.f = f | 129 yield zd.decompress(chnk) |
130 self.buf = "" | 130 yield zd.flush() |
131 def read(self, l): | |
132 while l > len(self.buf): | |
133 r = self.f.read(4096) | |
134 if r: | |
135 self.buf += self.zd.decompress(r) | |
136 else: | |
137 self.buf += self.zd.flush() | |
138 break | |
139 d, self.buf = self.buf[:l], self.buf[l:] | |
140 return d | |
141 | 131 |
142 return zread(f) | 132 return util.chunkbuffer(zgenerator(util.filechunkiter(f))) |
143 | 133 |
144 class httpsrepository(httprepository): | 134 class httpsrepository(httprepository): |
145 pass | 135 pass |