Changeset - 976a1e77932e
[Not reviewed]
CONTRIBUTORS
Show inline comments
 
List of contributors to Kallithea project:
 

	
 
    Mads Kiilerich <mads@kiilerich.com> 2016-2024
 
    Aristotelis Stageiritis <aristotelis79@gmail.com> 2024
 
    Poesty Li <poesty7450@gmail.com> 2024
 
    Valentin Kleibel <valentin@vrvis.at> 2024
 
    Manuel Jacob <me@manueljacob.de> 2019-2020 2022-2023
 
    Mathias De Mare <mathias.de_mare@nokia.com> 2023
 
    qy117121 <mixuan121@gmail.com> 2023
 
    Asterios Dimitriou <steve@pci.gr> 2016-2017 2020 2022
 
    Étienne Gilli <etienne@gilli.io> 2020-2022
 
    Jaime Marquínez Ferrándiz <weblate@jregistros.fastmail.net> 2022
docs/setup.rst
Show inline comments
 
@@ -628,25 +628,26 @@ that, you'll need to:
 
- Add global Apache configuration to tell mod_wsgi that Python only will be
 
  used in the WSGI processes and shouldn't be initialized in the Apache
 
  processes::
 

	
 
    WSGIRestrictEmbedded On
 

	
 
- Create a WSGI dispatch script, like the one below. The ``WSGIDaemonProcess``
 
  ``python-home`` directive will make sure it uses the right Python Virtual
 
  Environment and that paste thus can pick up the right Kallithea
 
  application.
 
- Create a WSGI dispatch script, like `/srv/kallithea/wsgi.py`:
 

	
 
  .. code-block:: python
 

	
 
      ini = '/srv/kallithea/my.ini'
 
      from logging.config import fileConfig
 
      fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'})
 
      from paste.deploy import loadapp
 
      application = loadapp('config:' + ini)
 

	
 
  We will use the ``WSGIDaemonProcess`` directive ``python-home`` to make sure
 
  it uses the right Python Virtual Environment where paste loadapp will pick up
 
  the right Kallithea application.
 

	
 
- Add the necessary ``WSGI*`` directives to the Apache Virtual Host configuration
 
  file, like in the example below. Notice that the WSGI dispatch script created
 
  above is referred to with the ``WSGIScriptAlias`` directive.
 
  The default locale settings Apache provides for web services are often not
 
  adequate, with `C` as the default language and `ASCII` as the encoding.
 
  Instead, use the ``lang`` parameter of ``WSGIDaemonProcess`` to specify a
 
@@ -662,14 +663,19 @@ that, you'll need to:
 

	
 
  .. code-block:: apache
 

	
 
      WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \
 
          python-home=/srv/kallithea/venv lang=C.UTF-8
 
      WSGIProcessGroup kallithea
 
      WSGIScriptAlias / /srv/kallithea/dispatch.wsgi
 
      WSGIScriptAlias / /srv/kallithea/wsgi.py
 
      WSGIPassAuthorization On
 
      <Directory /srv/kallithea>
 
          <Files wsgi.py>
 
              Require all granted
 
          </Files>
 
      </Directory>
 

	
 

	
 
Other configuration files
 
-------------------------
 

	
 
A number of `example init.d scripts`__ can be found in
kallithea/bin/kallithea_cli_base.py
Show inline comments
 
@@ -76,11 +76,11 @@ def register_command(needs_config_file=F
 
                cp.read_string(read_config(path_to_ini_file, strip_section_prefix=annotated.__name__))
 
                logging.config.fileConfig(cp,
 
                    {'__file__': path_to_ini_file, 'here': os.path.dirname(path_to_ini_file)})
 
                if needs_config_file:
 
                    annotated(*args, config=config, **kwargs)
 
                if config_file_initialize_app:
 
                    kallithea.config.application.make_app(config.global_conf, **config.local_conf)
 
                    kallithea.config.application.make_app_raw(config.global_conf, **config.local_conf)
 
                    annotated(*args, **kwargs)
 
            return cli_command(runtime_wrapper)
 
        return annotator
 
    return cli_command
kallithea/bin/kallithea_cli_celery.py
Show inline comments
 
@@ -37,13 +37,13 @@ def celery_run(celery_args, config):
 
    if not asbool(config.get('use_celery')):
 
        raise Exception('Please set use_celery = true in .ini config '
 
                        'file before running this command')
 

	
 
    kallithea.CELERY_APP.config_from_object(celery_app.make_celery_config(config))
 

	
 
    kallithea.CELERY_APP.loader.on_worker_process_init = lambda: kallithea.config.application.make_app(config.global_conf, **config.local_conf)
 
    kallithea.CELERY_APP.loader.on_worker_process_init = lambda: kallithea.config.application.make_app_raw(config.global_conf, **config.local_conf)
 

	
 
    args = list(celery_args)
 
    # args[0] is generally ignored when prog_name is specified, but -h *needs* it to be 'worker' ... but will also suggest that users specify 'worker' explicitly
 
    if not args or args[0] != 'worker':
 
        args.insert(0, 'worker')
 

	
kallithea/bin/vcs_hooks.py
Show inline comments
 
@@ -113,13 +113,13 @@ def _git_hook_environment(repo_path):
 
    """
 
    extras = get_hook_environment()
 

	
 
    path_to_ini_file = extras['config']
 
    config = paste.deploy.appconfig('config:' + path_to_ini_file)
 
    #logging.config.fileConfig(ini_file_path) # Note: we are in a different process - don't use configured logging
 
    kallithea.config.application.make_app(config.global_conf, **config.local_conf)
 
    kallithea.config.application.make_app_raw(config.global_conf, **config.local_conf)
 

	
 
    # fix if it's not a bare repo
 
    if repo_path.endswith(os.sep + '.git'):
 
        repo_path = repo_path[:-5]
 

	
 
    repo = db.Repository.get_by_full_path(repo_path)
kallithea/config/application.py
Show inline comments
 
@@ -17,12 +17,13 @@ from kallithea.config.app_cfg import bas
 
from kallithea.config.middleware.https_fixup import HttpsFixup
 
from kallithea.config.middleware.permanent_repo_url import PermanentRepoUrl
 
from kallithea.config.middleware.simplegit import SimpleGit
 
from kallithea.config.middleware.simplehg import SimpleHg
 
from kallithea.config.middleware.wrapper import RequestWrapper
 
from kallithea.lib.utils2 import asbool
 
from kallithea.lib.vcs.utils import hgcompat
 

	
 

	
 
__all__ = ['make_app']
 

	
 

	
 
def wrap_app(app):
 
@@ -45,12 +46,19 @@ def wrap_app(app):
 
        app = RequestWrapper(app, config)
 

	
 
    return app
 

	
 

	
 
def make_app(global_conf, **app_conf):
 
    """Return WSGI app with logging Mercurial stdout/stderr - to be used as
 
    Paste or mod_wsgi entry point"""
 
    hgcompat.redirect_stdio_to_logging()
 
    return make_app_raw(global_conf, **app_conf)
 

	
 

	
 
def make_app_raw(global_conf, **app_conf):
 
    """
 
    Set up Kallithea with the settings found in the PasteDeploy configuration
 
    file used.
 

	
 
    :param global_conf: The global settings for Kallithea (those
 
        defined under the ``[DEFAULT]`` section).
kallithea/config/middleware/simplehg.py
Show inline comments
 
@@ -67,12 +67,13 @@ cmd_mapping = {
 
    'branchmap': 'pull',
 
    'capabilities': 'pull',
 
    'changegroup': 'pull',
 
    'changegroupsubset': 'pull',
 
    'changesetdata': 'pull',
 
    'clonebundles': 'pull',
 
    'clonebundles_manifest': 'pull',
 
    'debugwireargs': 'pull',
 
    'filedata': 'pull',
 
    'getbundle': 'pull',
 
    'getlfile': 'pull',
 
    'heads': 'pull',
 
    'hello': 'pull',
kallithea/controllers/base.py
Show inline comments
 
@@ -453,14 +453,22 @@ class BaseController(TGController):
 
        """Perform basic security/sanity checks before processing the request."""
 

	
 
        # Only allow the following HTTP request methods.
 
        if request.method not in ['GET', 'HEAD', 'POST']:
 
            raise webob.exc.HTTPMethodNotAllowed()
 

	
 
        try:
 
            params = request.params
 
        except UnicodeDecodeError as e:
 
            # webobj will leak UnicodeDecodeError when decoding invalid
 
            # URLencoded byte sequences in parameters
 
            log.error('Error decoding request parameters: %s' % e)
 
            raise webob.exc.HTTPBadRequest()
 

	
 
        # Also verify the _method override - no longer allowed.
 
        if request.params.get('_method') is None:
 
        if params.get('_method') is None:
 
            pass # no override, no problem
 
        else:
 
            raise webob.exc.HTTPMethodNotAllowed()
 

	
 
        # Make sure CSRF token never appears in the URL. If so, invalidate it.
 
        if webutils.session_csrf_secret_name in request.GET:
kallithea/lib/feeds.py
Show inline comments
 
@@ -54,13 +54,13 @@ def rfc3339_date(date):
 

	
 
# From ``django.utils.feedgenerator`` via webhelpers.feedgenerator
 
def get_tag_uri(url, date):
 
    "Creates a TagURI. See http://diveintomark.org/archives/2004/05/28/howto-atom-id"
 
    tag = re.sub('^http://', '', url)
 
    if date is not None:
 
        tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1)
 
        tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, count=1)
 
    tag = re.sub('#', '/', tag)
 
    return 'tag:' + tag
 

	
 

	
 
class Attributes(object):
 
    """Simple namespace for attribute dict access in mako and elsewhere"""
kallithea/lib/vcs/backends/git/changeset.py
Show inline comments
 
@@ -313,13 +313,13 @@ class GitChangeset(BaseChangeset):
 
        # -l     ==> outputs long shas (and we need all 40 characters)
 
        # --root ==> doesn't put '^' character for boundaries
 
        # -r sha ==> blames for the given revision
 
        so = self.repository.run_git_command(cmd)
 

	
 
        for i, blame_line in enumerate(so.split('\n')[:-1]):
 
            sha, line = re.split(r' ', blame_line, 1)
 
            sha, line = re.split(r' ', blame_line, maxsplit=1)
 
            yield (i + 1, sha, lambda sha=sha: self.repository.get_changeset(sha), line)
 

	
 
    def fill_archive(self, stream=None, kind='tgz', prefix=None,
 
                     subrepos=False):
 
        """
 
        Fills up given stream.
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
"""
 
Mercurial libs compatibility
 
"""
 

	
 
import logging
 

	
 
import mercurial.encoding
 
import mercurial.localrepo
 

	
 

	
 
class MercurialStdLogger:
 
    def __init__(self, logger):
 
        self.logger = logger
 

	
 
    def write(self, message):
 
        try:
 
            self.logger(message.decode().rstrip())
 
        except:
 
            self.logger(message)
 

	
 
    def flush(self):
 
        pass
 

	
 
def monkey_do():
 
    """Apply some Mercurial monkey patching"""
 
    # workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly, and test_archival failing
 
    mercurial.localrepo.localrepository._lfstatuswriters = [lambda *msg, **opts: None]
 
    # 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
 
    mercurial.localrepo.localrepository.lfstatus = False
 

	
 
    # Minimize potential impact from custom configuration
 
    mercurial.encoding.environ[b'HGPLAIN'] = b'1'
 

	
 

	
 
hglog = logging.getLogger("mercurial")
 

	
 

	
 
def redirect_stdio_to_logging():
 
    # Capture Mercurial stdout/stderr and send to a 'mercurial' logger
 
    try:
 
        import mercurial.utils.procutil as procutil
 
        if not isinstance(procutil.stdout, MercurialStdLogger):
 
            procutil.stdout = MercurialStdLogger(hglog.info)
 
        if not isinstance(procutil.stderr, MercurialStdLogger):
 
            procutil.stderr = MercurialStdLogger(hglog.warning)
 
    except Exception as e:
 
        hglog.error("Exception installing procutil stdout/stderr: %s", e)
kallithea/templates/about.html
Show inline comments
 
@@ -24,12 +24,13 @@
 
  necessarily limited to the following:</p>
 
  <ul>
 

	
 
  <li>Copyright &copy; 2012&ndash;2024, Mads Kiilerich</li>
 
  <li>Copyright &copy; 2024, Aristotelis Stageiritis</li>
 
  <li>Copyright &copy; 2024, Poesty Li</li>
 
  <li>Copyright &copy; 2024, Valentin Kleibel</li>
 
  <li>Copyright &copy; 2019&ndash;2020, 2022&ndash;2023, Manuel Jacob</li>
 
  <li>Copyright &copy; 2023, Mathias De Mare</li>
 
  <li>Copyright &copy; 2023, qy117121</li>
 
  <li>Copyright &copy; 2015&ndash;2017, 2019&ndash;2022, Étienne Gilli</li>
 
  <li>Copyright &copy; 2016&ndash;2017, 2020, 2022, Asterios Dimitriou</li>
 
  <li>Copyright &copy; 2022, Jaime Marquínez Ferrándiz</li>
kallithea/tests/scripts/manual_test_concurrency.py
Show inline comments
 
@@ -44,13 +44,13 @@ from kallithea.model.base import init_mo
 
from kallithea.model.repo import RepoModel
 
from kallithea.tests.base import HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
 

	
 

	
 
rel_path = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
 
conf = appconfig('config:development.ini', relative_to=rel_path)
 
kallithea.config.application.make_app(conf.global_conf, **conf.local_conf)
 
kallithea.config.application.make_app_raw(conf.global_conf, **conf.local_conf)
 

	
 
USER = TEST_USER_ADMIN_LOGIN
 
PASS = TEST_USER_ADMIN_PASS
 
HOST = 'server.local'
 
METHOD = 'pull'
 
DEBUG = True
0 comments (0 inline, 0 general)