[cig-commits] commit: Cloning a forest is now possible over HTTP.
Mercurial
hg at geodynamics.org
Mon Nov 24 11:27:05 PST 2008
changeset: 49:728167aff824
user: Simon Law <simon at akoha.org>
date: Mon Jul 09 18:04:44 2007 -0400
files: forest.py
description:
Cloning a forest is now possible over HTTP.
diff -r d8e40f82bb3d -r 728167aff824 forest.py
--- a/forest.py Mon Jul 09 17:46:20 2007 -0400
+++ b/forest.py Mon Jul 09 18:04:44 2007 -0400
@@ -49,7 +49,8 @@ import re
import re
from mercurial import commands, hg, node, util
-from mercurial import localrepo, httprepo, sshrepo, sshserver
+from mercurial import localrepo, sshrepo, sshserver, httprepo
+from mercurial.hgweb import hgweb_mod
if not hasattr(commands, "findcmd"):
from mercurial.cmdutil import findcmd
else:
@@ -138,7 +139,6 @@ def _sshrepo_forests(self, walkhg):
if 'forests' not in self.capabilities:
raise util.Abort(_("Remote forests cannot be cloned because the other repository doesn't support the forest extension."))
data = self.call("forests", walkhg=("", "True")[walkhg])
- print data
return data.splitlines()
sshrepo.sshrepository.forests = _sshrepo_forests
@@ -178,14 +178,37 @@ def _httprepo_forests(self, walkhg):
"""
if 'forests' not in self.capabilities:
raise util.Abort(_("Remote forests cannot be cloned because the other repository doesn't support the forest extension."))
- d = self.do_read("forests", walkhg=("", "True")[walkhg])
- success, data = d[:-1].split(" ", 1)
- if int(success):
- return data.splitlines()
- else:
- self.raise_(hg.RepoError(data))
+ data = self.do_read("forests", walkhg=("", "True")[walkhg])
+ return data.splitlines()
httprepo.httprepository.forests = _httprepo_forests
+
+
+def _httpserver_do_capabilities(self, req):
+ caps = ['lookup', 'changegroupsubset', 'forests']
+ if self.configbool('server', 'uncompressed'):
+ caps.append('stream=%d' % self.repo.revlogversion)
+ # XXX: make configurable and/or share code with do_unbundle:
+ unbundleversions = ['HG10GZ', 'HG10BZ', 'HG10UN']
+ if unbundleversions:
+ caps.append('unbundle=%s' % ','.join(unbundleversions))
+ resp = ' '.join(caps)
+ req.httphdr("application/mercurial-0.1", length=len(resp))
+ req.write(resp)
+
+hgweb_mod.hgweb.do_capabilities = _httpserver_do_capabilities
+
+
+def _httpserver_do_forests(self, req):
+ resp = ""
+ if req.form.has_key('walkhg'):
+ f = self.repo.forests(bool(req.form['walkhg'][0]))
+ resp = "\n".join(f)
+ req.httphdr("application/mercurial-0.1", length=len(resp))
+ req.write(resp)
+
+
+hgweb_mod.hgweb.do_forests = _httpserver_do_forests
tree_section_re = re.compile(r"^tree(\w+)$")
More information about the CIG-COMMITS
mailing list