# HG changeset patch # User Vadim Gelfer # Date 2006-06-16 00:07:30 # Node ID c660691fb45d2cc1a411556e877e796c5a80b84c # Parent 801dfe0aa53af984477b71fc29214babe1ffbb9a http: query server for capabilities diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -833,3 +833,9 @@ class hgweb(object): "static")) req.write(staticfile(static, fname) or self.t("error", error="%r not found" % fname)) + + def do_capabilities(self, req): + resp = '' + req.httphdr("application/mercurial-0.1", length=len(resp)) + req.write(resp) + diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -71,7 +71,7 @@ def netlocunsplit(host, port, user=None, class httprepository(remoterepository): def __init__(self, ui, path): - self.capabilities = () + self.caps = None scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) if query or frag: raise util.Abort(_('unsupported URL component: "%s"') % @@ -145,6 +145,18 @@ class httprepository(remoterepository): opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] urllib2.install_opener(opener) + # look up capabilities only when needed + + def get_caps(self): + if self.caps is None: + try: + self.caps = self.do_read('capabilities').split() + except hg.RepoError: + self.caps = () + return self.caps + + capabilities = property(get_caps) + def dev(self): return -1