Show More
@@ -883,6 +883,11 b' class hgweb(object):' | |||||
883 | def do_filelog(self, req): |
|
883 | def do_filelog(self, req): | |
884 | req.write(self.filelog(self.filectx(req))) |
|
884 | req.write(self.filelog(self.filectx(req))) | |
885 |
|
885 | |||
|
886 | def do_lookup(self, req): | |||
|
887 | resp = hex(self.repo.lookup(req.form['key'][0])) + "\n" | |||
|
888 | req.httphdr("application/mercurial-0.1", length=len(resp)) | |||
|
889 | req.write(resp) | |||
|
890 | ||||
886 | def do_heads(self, req): |
|
891 | def do_heads(self, req): | |
887 | resp = " ".join(map(hex, self.repo.heads())) + "\n" |
|
892 | resp = " ".join(map(hex, self.repo.heads())) + "\n" | |
888 | req.httphdr("application/mercurial-0.1", length=len(resp)) |
|
893 | req.httphdr("application/mercurial-0.1", length=len(resp)) | |
@@ -929,6 +934,28 b' class hgweb(object):' | |||||
929 |
|
934 | |||
930 | req.write(z.flush()) |
|
935 | req.write(z.flush()) | |
931 |
|
936 | |||
|
937 | def do_changegroupsubset(self, req): | |||
|
938 | req.httphdr("application/mercurial-0.1") | |||
|
939 | bases = [] | |||
|
940 | heads = [] | |||
|
941 | if not self.allowpull: | |||
|
942 | return | |||
|
943 | ||||
|
944 | if req.form.has_key('bases'): | |||
|
945 | bases = [bin(x) for x in req.form['bases'][0].split(' ')] | |||
|
946 | if req.form.has_key('heads'): | |||
|
947 | heads = [bin(x) for x in req.form['heads'][0].split(' ')] | |||
|
948 | ||||
|
949 | z = zlib.compressobj() | |||
|
950 | f = self.repo.changegroupsubset(bases, heads, 'serve') | |||
|
951 | while 1: | |||
|
952 | chunk = f.read(4096) | |||
|
953 | if not chunk: | |||
|
954 | break | |||
|
955 | req.write(z.compress(chunk)) | |||
|
956 | ||||
|
957 | req.write(z.flush()) | |||
|
958 | ||||
932 | def do_archive(self, req): |
|
959 | def do_archive(self, req): | |
933 | changeset = self.repo.lookup(req.form['node'][0]) |
|
960 | changeset = self.repo.lookup(req.form['node'][0]) | |
934 | type_ = req.form['type'][0] |
|
961 | type_ = req.form['type'][0] | |
@@ -949,7 +976,7 b' class hgweb(object):' | |||||
949 | or self.t("error", error="%r not found" % fname)) |
|
976 | or self.t("error", error="%r not found" % fname)) | |
950 |
|
977 | |||
951 | def do_capabilities(self, req): |
|
978 | def do_capabilities(self, req): | |
952 | caps = ['unbundle'] |
|
979 | caps = ['unbundle', 'lookup', 'changegroupsubset'] | |
953 | if self.repo.ui.configbool('server', 'uncompressed'): |
|
980 | if self.repo.ui.configbool('server', 'uncompressed'): | |
954 | caps.append('stream=%d' % self.repo.revlogversion) |
|
981 | caps.append('stream=%d' % self.repo.revlogversion) | |
955 | resp = ' '.join(caps) |
|
982 | resp = ' '.join(caps) |
@@ -261,6 +261,14 b' class httprepository(remoterepository):' | |||||
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: | |
@@ -298,6 +306,22 b' class httprepository(remoterepository):' | |||||
298 | try: |
|
306 | try: | |
299 | for chnk in f: |
|
307 | for chnk in f: | |
300 | yield zd.decompress(chnk) |
|
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) | |||
|
319 | ||||
|
320 | def zgenerator(f): | |||
|
321 | zd = zlib.decompressobj() | |||
|
322 | try: | |||
|
323 | for chnk in f: | |||
|
324 | yield zd.decompress(chnk) | |||
301 | except httplib.HTTPException: |
|
325 | except httplib.HTTPException: | |
302 | raise IOError(None, _('connection ended unexpectedly')) |
|
326 | raise IOError(None, _('connection ended unexpectedly')) | |
303 | yield zd.flush() |
|
327 | yield zd.flush() |
General Comments 0
You need to be logged in to leave comments.
Login now