Exemplo n.º 1
0
 def make_handler():
     if webdir_conf:
         hgwebobj = hgwebdir(webdir_conf, ui)
     elif repo is not None:
         hgwebobj = hgweb(hg.repository(repo.ui, repo.root))
     else:
         raise error.RepoError(_("There is no Mercurial repository"
                                 " here (.hg not found)"))
     return hgwebobj
Exemplo n.º 2
0
 def make_handler():
     if webdir_conf:
         hgwebobj = hgwebdir(webdir_conf, ui)
     elif repo is not None:
         hgwebobj = hgweb(hg.repository(repo.ui, repo.root))
     else:
         raise error.RepoError(
             _("There is no Mercurial repository"
               " here (.hg not found)"))
     return hgwebobj
Exemplo n.º 3
0
 def refresh(self):
     mtime = get_mtime(self.repo.root)
     if mtime != self.mtime:
         self.mtime = mtime
         self.repo = hg.repository(self.repo.ui, self.repo.root)
         self.maxchanges = int(self.config("web", "maxchanges", 10))
         self.stripecount = int(self.config("web", "stripes", 1))
         self.maxshortchanges = int(self.config("web", "maxshortchanges", 60))
         self.maxfiles = int(self.config("web", "maxfiles", 10))
         self.allowpull = self.configbool("web", "allowpull", True)
         encoding.encoding = self.config("web", "encoding",
                                         encoding.encoding)
Exemplo n.º 4
0
 def refresh(self):
     mtime = get_mtime(self.repo.root)
     if mtime != self.mtime:
         self.mtime = mtime
         self.repo = hg.repository(self.repo.ui, self.repo.root)
         self.maxchanges = int(self.config("web", "maxchanges", 10))
         self.stripecount = int(self.config("web", "stripes", 1))
         self.maxshortchanges = int(
             self.config("web", "maxshortchanges", 60))
         self.maxfiles = int(self.config("web", "maxfiles", 10))
         self.allowpull = self.configbool("web", "allowpull", True)
         encoding.encoding = self.config("web", "encoding",
                                         encoding.encoding)
Exemplo n.º 5
0
    def __init__(self, repo, name=None):
        if isinstance(repo, str):
            u = ui.ui()
            u.setconfig('ui', 'report_untrusted', 'off')
            u.setconfig('ui', 'interactive', 'off')
            self.repo = hg.repository(u, repo)
        else:
            self.repo = repo

        hook.redirect(True)
        self.mtime = -1
        self.reponame = name
        self.archives = 'zip', 'gz', 'bz2'
        self.stripecount = 1
        # a repo owner may set web.templates in .hg/hgrc to get any file
        # readable by the user running the CGI script
        self.templatepath = self.config('web', 'templates')
Exemplo n.º 6
0
    def __init__(self, repo, name=None):
        if isinstance(repo, str):
            u = ui.ui()
            u.setconfig('ui', 'report_untrusted', 'off')
            u.setconfig('ui', 'interactive', 'off')
            self.repo = hg.repository(u, repo)
        else:
            self.repo = repo

        hook.redirect(True)
        self.mtime = -1
        self.reponame = name
        self.archives = 'zip', 'gz', 'bz2'
        self.stripecount = 1
        # a repo owner may set web.templates in .hg/hgrc to get any file
        # readable by the user running the CGI script
        self.templatepath = self.config('web', 'templates')
Exemplo n.º 7
0
    def run_wsgi(self, req):
        try:
            try:
                self.refresh()

                virtual = req.env.get("PATH_INFO", "").strip('/')
                tmpl = self.templater(req)
                ctype = tmpl('mimetype', encoding=encoding.encoding)
                ctype = templater.stringify(ctype)

                # a static file
                if virtual.startswith('static/') or 'static' in req.form:
                    if virtual.startswith('static/'):
                        fname = virtual[7:]
                    else:
                        fname = req.form['static'][0]
                    static = templater.templatepath('static')
                    return (staticfile(static, fname, req), )

                # top-level index
                elif not virtual:
                    req.respond(HTTP_OK, ctype)
                    return self.makeindex(req, tmpl)

                # nested indexes and hgwebs

                repos = dict(self.repos)
                while virtual:
                    real = repos.get(virtual)
                    if real:
                        req.env['REPO_NAME'] = virtual
                        try:
                            repo = hg.repository(self.ui, real)
                            return hgweb(repo).run_wsgi(req)
                        except IOError, inst:
                            msg = inst.strerror
                            raise ErrorResponse(HTTP_SERVER_ERROR, msg)
                        except error.RepoError, inst:
                            raise ErrorResponse(HTTP_SERVER_ERROR, str(inst))
Exemplo n.º 8
0
    def run_wsgi(self, req):
        try:
            try:
                self.refresh()

                virtual = req.env.get("PATH_INFO", "").strip('/')
                tmpl = self.templater(req)
                ctype = tmpl('mimetype', encoding=encoding.encoding)
                ctype = templater.stringify(ctype)

                # a static file
                if virtual.startswith('static/') or 'static' in req.form:
                    if virtual.startswith('static/'):
                        fname = virtual[7:]
                    else:
                        fname = req.form['static'][0]
                    static = templater.templatepath('static')
                    return (staticfile(static, fname, req),)

                # top-level index
                elif not virtual:
                    req.respond(HTTP_OK, ctype)
                    return self.makeindex(req, tmpl)

                # nested indexes and hgwebs

                repos = dict(self.repos)
                while virtual:
                    real = repos.get(virtual)
                    if real:
                        req.env['REPO_NAME'] = virtual
                        try:
                            repo = hg.repository(self.ui, real)
                            return hgweb(repo).run_wsgi(req)
                        except IOError, inst:
                            msg = inst.strerror
                            raise ErrorResponse(HTTP_SERVER_ERROR, msg)
                        except error.RepoError, inst:
                            raise ErrorResponse(HTTP_SERVER_ERROR, str(inst))