comparison mercurial/httprepo.py @ 3444:3505fcd5a231

Adding changegroupsubset and lookup to web protocol so pull -r and clone -r can be supported.
author Eric Hopper <hopper@omnifarious.org>
date Sat, 09 Sep 2006 18:25:06 -0700
parents 5dbb3a991bbf
children 233c733e4af5
comparison
equal deleted inserted replaced
3443:e6045fc3cd50 3444:3505fcd5a231
259 return fp.read() 259 return fp.read()
260 finally: 260 finally:
261 # if using keepalive, allow connection to be reused 261 # if using keepalive, allow connection to be reused
262 fp.close() 262 fp.close()
263 263
264 def lookup(self, key):
265 try:
266 d = self.do_cmd("lookup", key = key).read()
267 return bin(d[:-1])
268 except:
269 self.ui.warn('Not able to look up revision named "%s"\n' % (key,))
270 raise
271
264 def heads(self): 272 def heads(self):
265 d = self.do_read("heads") 273 d = self.do_read("heads")
266 try: 274 try:
267 return map(bin, d[:-1].split(" ")) 275 return map(bin, d[:-1].split(" "))
268 except: 276 except:
290 raise 298 raise
291 299
292 def changegroup(self, nodes, kind): 300 def changegroup(self, nodes, kind):
293 n = " ".join(map(hex, nodes)) 301 n = " ".join(map(hex, nodes))
294 f = self.do_cmd("changegroup", roots=n) 302 f = self.do_cmd("changegroup", roots=n)
303
304 def zgenerator(f):
305 zd = zlib.decompressobj()
306 try:
307 for chnk in f:
308 yield zd.decompress(chnk)
309 except httplib.HTTPException, inst:
310 raise IOError(None, _('connection ended unexpectedly'))
311 yield zd.flush()
312
313 return util.chunkbuffer(zgenerator(util.filechunkiter(f)))
314
315 def changegroupsubset(self, bases, heads, source):
316 baselst = " ".join([hex(n) for n in bases])
317 headlst = " ".join([hex(n) for n in heads])
318 f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst)
295 319
296 def zgenerator(f): 320 def zgenerator(f):
297 zd = zlib.decompressobj() 321 zd = zlib.decompressobj()
298 try: 322 try:
299 for chnk in f: 323 for chnk in f: