Beispiel #1
0
    def __init__(self, hgwebdirconfig=None, cyd=None):
        if cyd is None:
            cyd = cydra.Cydra()

        self.cydra = self.compmgr = cyd
        self.authenticator = HTTPBasicAuthenticator(self.compmgr)

        self.config = config = cyd.config.get_component_config(
            'cydra.repository.hg.HgRepositories', {})
        if 'base' not in config:
            raise Exception("hg base path not configured")

        baseui = None

        if hgwebdirconfig is None:
            hgwebdirconfig = {'/': os.path.join(config['base'], '**')}

            baseui = ui.ui()

            # provide sensible defaults
            baseui.setconfig(
                "web", "allow_archive", "gz, zip, bz2"
            )  #read access -> downloading archive should be fine
            baseui.setconfig("web", "allow_push",
                             "*")  # we are doing access checks, not hg
            baseui.setconfig(
                "web", "push_ssl",
                "false")  # enforcing SSL is left to the user / apache
            baseui.setconfig("web", "encoding", "utf-8")

        self.hgwebdir = hgwebdir(hgwebdirconfig, baseui)
Beispiel #2
0
    def __init__(self, hgwebdirconfig=None, cyd=None):
        if cyd is None:
            cyd = cydra.Cydra()

        self.cydra = self.compmgr = cyd
        self.authenticator = HTTPBasicAuthenticator(self.compmgr)

        self.config = config = cyd.config.get_component_config('cydra.repository.hg.HgRepositories', {})
        if 'base' not in config:
            raise Exception("hg base path not configured")

        baseui = None

        if hgwebdirconfig is None:
            hgwebdirconfig = {'/': os.path.join(config['base'], '**')}

            baseui = ui.ui()

            # provide sensible defaults
            baseui.setconfig("web", "allow_archive", "gz, zip, bz2") #read access -> downloading archive should be fine
            baseui.setconfig("web", "allow_push", "*") # we are doing access checks, not hg
            baseui.setconfig("web", "push_ssl", "false") # enforcing SSL is left to the user / apache
            baseui.setconfig("web", "encoding", "utf-8")

        self.hgwebdir = hgwebdir(hgwebdirconfig, baseui)
Beispiel #3
0
def make_web_app():
    hgweb_config = "%s/hgweb.config" % os.getcwd()
    if not os.path.exists(hgweb_config):
        raise Exception(
            "Required file hgweb.config does not exist in directory %s" %
            os.getcwd())
    hgwebapp = hgwebdir(hgweb_config)
    return hgwebapp
Beispiel #4
0
 def init(self):
     self.stopped = True
     util.set_signal_handler()
     try:
         baseui = repo and repo.baseui or ui
         repoui = repo and repo.ui != baseui and repo.ui or None
         optlist = ("name templates style address port prefix ipv6"
                    " accesslog errorlog webdir_conf certificate")
         for o in optlist.split():
             if opts[o]:
                 baseui.setconfig("web", o, str(opts[o]))
                 if repoui:
                     repoui.setconfig("web", o, str(opts[o]))
         o = opts.get('web_conf') or opts.get('webdir_conf')
         if o:
             app = hgwebdir_mod.hgwebdir(o, repo.ui)
         else:
             app = hgweb_mod.hgweb(hg.repository(repo.ui, repo.root))
         self.httpd = server.create_server(ui, app)
     except socket.error, inst:
         raise util.Abort(_('cannot start server: ') + inst.args[1])
Beispiel #5
0
 def make_web_app():
     hgwebapp = hgwebdir(hgweb_config)
     return hgwebapp
Beispiel #6
0
os.environ['HGENCODING'] = 'UTF-8'


import isapi_wsgi
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir

# Example tweak: Replace isapi_wsgi's handler to provide better error message
# Other stuff could also be done here, like logging errors etc.
class WsgiHandler(isapi_wsgi.IsapiWsgiHandler):
    error_status = '500 Internal Server Error' # less silly error message

isapi_wsgi.IsapiWsgiHandler = WsgiHandler

# Only create the hgwebdir instance once
application = hgwebdir(hgweb_config)

def handler(environ, start_response):

    # Translate IIS's weird URLs
    url = environ['SCRIPT_NAME'] + environ['PATH_INFO']
    paths = url[1:].split('/')[path_strip:]
    script_name = '/' + '/'.join(paths[:path_prefix])
    path_info = '/'.join(paths[path_prefix:])
    if path_info:
        path_info = '/' + path_info
    environ['SCRIPT_NAME'] = script_name
    environ['PATH_INFO'] = path_info

    return application(environ, start_response)
Beispiel #7
0
 def make_web_app():
     hgwebapp = hgwebdir( hgweb_config )
     return hgwebapp
Beispiel #8
0
 def make_web_app():
     hgwebapp = hgwebdir(hgweb_config.encode('utf-8'))
     return hgwebapp
Beispiel #9
0
def make_web_app():
    hgweb_config = "%s/hgweb.config" %  os.getcwd()
    if not os.path.exists( hgweb_config ):
        raise Exception( "Required file hgweb.config does not exist in directory %s" % os.getcwd() )
    hgwebapp = hgwebdir( hgweb_config )
    return hgwebapp
os.chdir('b')
hg.repository(u, 'd', create=1)
os.chdir('..')
hg.repository(u, 'c', create=1)
os.chdir('..')

paths = {
    't/a/': '%s/a' % webdir,
    'b': '%s/b' % webdir,
    'coll': '%s/*' % webdir,
    'rcoll': '%s/**' % webdir
}

config = os.path.join(webdir, 'hgwebdir.conf')
configfile = open(config, 'w')
configfile.write('[paths]\n')
for k, v in paths.items():
    configfile.write('%s = %s\n' % (k, v))
configfile.close()

confwd = hgwebdir(config)
dictwd = hgwebdir(paths)

assert len(confwd.repos) == len(dictwd.repos), 'different numbers'
assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos)

found = dict(confwd.repos)
for key, path in dictwd.repos:
    assert key in found, 'repository %s was not found' % key
    assert found[key] == path, 'different paths for repo %s' % key
Beispiel #11
0
def make_web_app():
    return hgwebdir("/etc/mercurial/hgwebdir.conf")
Beispiel #12
0
 def __call__(self, environ, start_response):
     application = hgwebdir(repositories, parentui)
     output = application(environ, start_response)
     return ''.join([x for x in output])
hg.repository(u, 'a', create=1)
hg.repository(u, 'b', create=1)
os.chdir('b')
hg.repository(u, 'd', create=1)
os.chdir('..')
hg.repository(u, 'c', create=1)
os.chdir('..')

paths = {'t/a/': '%s/a' % webdir,
         'b': '%s/b' % webdir,
         'coll': '%s/*' % webdir,
         'rcoll': '%s/**' % webdir}

config = os.path.join(webdir, 'hgwebdir.conf')
configfile = open(config, 'w')
configfile.write('[paths]\n')
for k, v in paths.items():
    configfile.write('%s = %s\n' % (k, v))
configfile.close()

confwd = hgwebdir(config)
dictwd = hgwebdir(paths)

assert len(confwd.repos) == len(dictwd.repos), 'different numbers'
assert len(confwd.repos) == 9, 'expected 9 repos, found %d' % len(confwd.repos)

found = dict(confwd.repos)
for key, path in dictwd.repos:
    assert key in found, 'repository %s was not found' % key
    assert found[key] == path, 'different paths for repo %s' % key