##// END OF EJS Templates
hgweb: use bundletypes from mercurial.changegroup
Dirkjan Ochtman -
r6152:c0505483 default
parent child Browse files
Show More
@@ -53,6 +53,9 b' bundletypes = {'
53 "HG10GZ": ("HG10GZ", lambda: zlib.compressobj()),
53 "HG10GZ": ("HG10GZ", lambda: zlib.compressobj()),
54 }
54 }
55
55
56 # hgweb uses this list to communicate it's preferred type
57 bundlepriority = ['HG10GZ', 'HG10BZ', 'HG10UN']
58
56 def writebundle(cg, filename, bundletype):
59 def writebundle(cg, filename, bundletype):
57 """Write a bundle file and return its filename.
60 """Write a bundle file and return its filename.
58
61
@@ -9,7 +9,7 b''
9 import os, mimetypes, re
9 import os, mimetypes, re
10 from mercurial.node import *
10 from mercurial.node import *
11 from mercurial import mdiff, ui, hg, util, archival, patch, hook
11 from mercurial import mdiff, ui, hg, util, archival, patch, hook
12 from mercurial import revlog, templater, templatefilters
12 from mercurial import revlog, templater, templatefilters, changegroup
13 from common import get_mtime, style_map, paritygen, countgen, get_contact
13 from common import get_mtime, style_map, paritygen, countgen, get_contact
14 from common import ErrorResponse
14 from common import 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
@@ -92,6 +92,7 b' class hgweb(object):'
92 self.reponame = name
92 self.reponame = name
93 self.archives = 'zip', 'gz', 'bz2'
93 self.archives = 'zip', 'gz', 'bz2'
94 self.stripecount = 1
94 self.stripecount = 1
95 self._capabilities = None
95 # a repo owner may set web.templates in .hg/hgrc to get any file
96 # a repo owner may set web.templates in .hg/hgrc to get any file
96 # readable by the user running the CGI script
97 # readable by the user running the CGI script
97 self.templatepath = self.config("web", "templates",
98 self.templatepath = self.config("web", "templates",
@@ -123,6 +124,18 b' class hgweb(object):'
123 self.maxfiles = int(self.config("web", "maxfiles", 10))
124 self.maxfiles = int(self.config("web", "maxfiles", 10))
124 self.allowpull = self.configbool("web", "allowpull", True)
125 self.allowpull = self.configbool("web", "allowpull", True)
125 self.encoding = self.config("web", "encoding", util._encoding)
126 self.encoding = self.config("web", "encoding", util._encoding)
127 self._capabilities = None
128
129 def capabilities(self):
130 if self._capabilities is not None:
131 return self._capabilities
132 caps = ['lookup', 'changegroupsubset']
133 if self.configbool('server', 'uncompressed'):
134 caps.append('stream=%d' % self.repo.changelog.version)
135 if changegroup.bundlepriority:
136 caps.append('unbundle=%s' % ','.join(changegroup.bundlepriority))
137 self._capabilities = caps
138 return caps
126
139
127 def run(self):
140 def run(self):
128 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
141 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
@@ -101,14 +101,7 b' def changegroupsubset(web, req):'
101 req.write(z.flush())
101 req.write(z.flush())
102
102
103 def capabilities(web, req):
103 def capabilities(web, req):
104 caps = ['lookup', 'changegroupsubset']
104 resp = ' '.join(web.capabilities())
105 if web.configbool('server', 'uncompressed'):
106 caps.append('stream=%d' % web.repo.changelog.version)
107 # XXX: make configurable and/or share code with do_unbundle:
108 unbundleversions = ['HG10GZ', 'HG10BZ', 'HG10UN']
109 if unbundleversions:
110 caps.append('unbundle=%s' % ','.join(unbundleversions))
111 resp = ' '.join(caps)
112 req.respond(HTTP_OK, HGTYPE, length=len(resp))
105 req.respond(HTTP_OK, HGTYPE, length=len(resp))
113 req.write(resp)
106 req.write(resp)
114
107
General Comments 0
You need to be logged in to leave comments. Login now