comparison mercurial/hgweb/hgweb_mod.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 6bd676ee8b99
children 233c733e4af5
comparison
equal deleted inserted replaced
3443:e6045fc3cd50 3444:3505fcd5a231
881 req.write(self.fileannotate(self.filectx(req))) 881 req.write(self.fileannotate(self.filectx(req)))
882 882
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))
889 req.write(resp) 894 req.write(resp)
890 895
927 break 932 break
928 req.write(z.compress(chunk)) 933 req.write(z.compress(chunk))
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]
935 allowed = self.repo.ui.configlist("web", "allow_archive") 962 allowed = self.repo.ui.configlist("web", "allow_archive")
936 if (type_ in self.archives and (type_ in allowed or 963 if (type_ in self.archives and (type_ in allowed or
947 "static")) 974 "static"))
948 req.write(staticfile(static, fname, req) 975 req.write(staticfile(static, fname, req)
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)
956 req.httphdr("application/mercurial-0.1", length=len(resp)) 983 req.httphdr("application/mercurial-0.1", length=len(resp))
957 req.write(resp) 984 req.write(resp)