##// END OF EJS Templates
hgweb: move capabilities calculation back into hgweb.protocol
Dirkjan Ochtman -
r6780:4c1d67e0 default
parent child Browse files
Show More
@@ -10,7 +10,7 b' import os, mimetypes'
10 from mercurial.node import hex, nullid
10 from mercurial.node import hex, nullid
11 from mercurial.repo import RepoError
11 from mercurial.repo import RepoError
12 from mercurial import mdiff, ui, hg, util, patch, hook
12 from mercurial import mdiff, ui, hg, util, patch, hook
13 from mercurial import revlog, templater, templatefilters, changegroup
13 from mercurial import revlog, templater, templatefilters
14 from common import get_mtime, style_map, paritygen, countgen, ErrorResponse
14 from common import get_mtime, style_map, paritygen, countgen, ErrorResponse
15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
15 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
16 from request import wsgirequest
16 from request import wsgirequest
@@ -36,7 +36,6 b' class hgweb(object):'
36 self.reponame = name
36 self.reponame = name
37 self.archives = 'zip', 'gz', 'bz2'
37 self.archives = 'zip', 'gz', 'bz2'
38 self.stripecount = 1
38 self.stripecount = 1
39 self._capabilities = None
40 # a repo owner may set web.templates in .hg/hgrc to get any file
39 # a repo owner may set web.templates in .hg/hgrc to get any file
41 # readable by the user running the CGI script
40 # readable by the user running the CGI script
42 self.templatepath = self.config("web", "templates",
41 self.templatepath = self.config("web", "templates",
@@ -68,18 +67,6 b' class hgweb(object):'
68 self.maxfiles = int(self.config("web", "maxfiles", 10))
67 self.maxfiles = int(self.config("web", "maxfiles", 10))
69 self.allowpull = self.configbool("web", "allowpull", True)
68 self.allowpull = self.configbool("web", "allowpull", True)
70 self.encoding = self.config("web", "encoding", util._encoding)
69 self.encoding = self.config("web", "encoding", util._encoding)
71 self._capabilities = None
72
73 def capabilities(self):
74 if self._capabilities is not None:
75 return self._capabilities
76 caps = ['lookup', 'changegroupsubset']
77 if self.configbool('server', 'uncompressed'):
78 caps.append('stream=%d' % self.repo.changelog.version)
79 if changegroup.bundlepriority:
80 caps.append('unbundle=%s' % ','.join(changegroup.bundlepriority))
81 self._capabilities = caps
82 return caps
83
70
84 def run(self):
71 def run(self):
85 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
72 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
@@ -97,9 +97,14 b' def changegroupsubset(web, req):'
97 req.write(z.flush())
97 req.write(z.flush())
98
98
99 def capabilities(web, req):
99 def capabilities(web, req):
100 resp = ' '.join(web.capabilities())
100 caps = ['lookup', 'changegroupsubset']
101 req.respond(HTTP_OK, HGTYPE, length=len(resp))
101 if web.repo.ui.configbool('server', 'uncompressed', untrusted=True):
102 req.write(resp)
102 caps.append('stream=%d' % web.repo.changelog.version)
103 if changegroupmod.bundlepriority:
104 caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
105 rsp = ' '.join(caps)
106 req.respond(HTTP_OK, HGTYPE, length=len(rsp))
107 req.write(rsp)
103
108
104 def unbundle(web, req):
109 def unbundle(web, req):
105
110
General Comments 0
You need to be logged in to leave comments. Login now