comparison mercurial/hgweb/hgweb_mod.py @ 6152:c050548307a4

hgweb: use bundletypes from mercurial.changegroup
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 21 Feb 2008 15:00:25 +0100
parents b023915aa1bc
children 2ab54f48dbe8
comparison
equal deleted inserted replaced
6151:8bc4fe428103 6152:c050548307a4
7 # of the GNU General Public License, incorporated herein by reference. 7 # of the GNU General Public License, incorporated herein by reference.
8 8
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
16 from request import wsgirequest 16 from request import wsgirequest
17 import webcommands, protocol 17 import webcommands, protocol
90 hook.redirect(True) 90 hook.redirect(True)
91 self.mtime = -1 91 self.mtime = -1
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",
98 templater.templatepath(), 99 templater.templatepath(),
99 untrusted=False) 100 untrusted=False)
121 self.stripecount = int(self.config("web", "stripes", 1)) 122 self.stripecount = int(self.config("web", "stripes", 1))
122 self.maxshortchanges = int(self.config("web", "maxshortchanges", 60)) 123 self.maxshortchanges = int(self.config("web", "maxshortchanges", 60))
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."):
129 raise RuntimeError("This function is only intended to be called while running as a CGI script.") 142 raise RuntimeError("This function is only intended to be called while running as a CGI script.")
130 import mercurial.hgweb.wsgicgi as wsgicgi 143 import mercurial.hgweb.wsgicgi as wsgicgi