mercurial/hgweb/hgweb_mod.py
changeset 6780 4c1d67e0fa8c
parent 6779 d3147b4e3e8a
child 6781 b4b7261164d5
equal deleted inserted replaced
6779:d3147b4e3e8a 6780:4c1d67e0fa8c
     8 
     8 
     9 import os, mimetypes
     9 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
    17 import webcommands, protocol, webutil
    17 import webcommands, protocol, webutil
    18 
    18 
    34         hook.redirect(True)
    34         hook.redirect(True)
    35         self.mtime = -1
    35         self.mtime = -1
    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",
    43                                         templater.templatepath(),
    42                                         templater.templatepath(),
    44                                         untrusted=False)
    43                                         untrusted=False)
    66             self.stripecount = int(self.config("web", "stripes", 1))
    65             self.stripecount = int(self.config("web", "stripes", 1))
    67             self.maxshortchanges = int(self.config("web", "maxshortchanges", 60))
    66             self.maxshortchanges = int(self.config("web", "maxshortchanges", 60))
    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."):
    86             raise RuntimeError("This function is only intended to be called while running as a CGI script.")
    73             raise RuntimeError("This function is only intended to be called while running as a CGI script.")
    87         import mercurial.hgweb.wsgicgi as wsgicgi
    74         import mercurial.hgweb.wsgicgi as wsgicgi