##// END OF EJS Templates
scripts: initial run of import cleanup using isort
Mads Kiilerich -
r7718:0a277465 default
parent child Browse files
Show More
@@ -1,7 +1,9 b''
1 import os
2 import sys
3
1 import mock
4 import mock
2 import os
3 import pytest
5 import pytest
4 import sys
6
5
7
6 here = os.path.dirname(__file__)
8 here = os.path.dirname(__file__)
7
9
@@ -11,8 +11,11 b''
11 # All configuration values have a default; values that are commented out
11 # All configuration values have a default; values that are commented out
12 # serve to show the default.
12 # serve to show the default.
13
13
14 import os
14 import sys
15 import sys
15 import os
16
17 from kallithea import __version__
18
16
19
17 # If extensions (or modules to document with autodoc) are in another directory,
20 # If extensions (or modules to document with autodoc) are in another directory,
18 # add these directories to sys.path here. If the directory is relative to the
21 # add these directories to sys.path here. If the directory is relative to the
@@ -53,7 +56,6 b" copyright = u'2010-2019 by various autho"
53 # The short X.Y version.
56 # The short X.Y version.
54 root = os.path.dirname(os.path.dirname(__file__))
57 root = os.path.dirname(os.path.dirname(__file__))
55 sys.path.append(root)
58 sys.path.append(root)
56 from kallithea import __version__
57 version = __version__
59 version = __version__
58 # The full version, including alpha/beta/rc tags.
60 # The full version, including alpha/beta/rc tags.
59 release = __version__
61 release = __version__
@@ -27,8 +27,9 b' Original author and date, and relevant c'
27 :license: GPLv3, see LICENSE.md for more details.
27 :license: GPLv3, see LICENSE.md for more details.
28 """
28 """
29
29
30 import platform
30 import sys
31 import sys
31 import platform
32
32
33
33 VERSION = (0, 4, 99)
34 VERSION = (0, 4, 99)
34 BACKENDS = {
35 BACKENDS = {
@@ -27,8 +27,10 b' branch_labels = None'
27 depends_on = None
27 depends_on = None
28
28
29 from alembic import op
29 from alembic import op
30 from sqlalchemy import MetaData, Table
31
30 from kallithea.model.db import Ui
32 from kallithea.model.db import Ui
31 from sqlalchemy import Table, MetaData
33
32
34
33 meta = MetaData()
35 meta = MetaData()
34
36
@@ -26,10 +26,12 b" down_revision = 'a020f7044fd6'"
26 branch_labels = None
26 branch_labels = None
27 depends_on = None
27 depends_on = None
28
28
29 import sqlalchemy as sa
29 from alembic import op
30 from alembic import op
30 import sqlalchemy as sa
31 from sqlalchemy import MetaData, Table
32
31 from kallithea.model.db import Ui
33 from kallithea.model.db import Ui
32 from sqlalchemy import Table, MetaData
34
33
35
34 meta = MetaData()
36 meta = MetaData()
35
37
@@ -26,8 +26,8 b" down_revision = 'ad357ccd9521'"
26 branch_labels = None
26 branch_labels = None
27 depends_on = None
27 depends_on = None
28
28
29 import sqlalchemy as sa
29 from alembic import op
30 from alembic import op
30 import sqlalchemy as sa
31
31
32 from kallithea.model import db
32 from kallithea.model import db
33
33
@@ -26,13 +26,14 b' Original author and date, and relevant c'
26 """
26 """
27
27
28 import os
28 import os
29 import sys
29 import pprint
30 import random
30 import random
31 import sys
31 import urllib2
32 import urllib2
32 import pprint
33
33
34 from kallithea.lib.compat import json
34 from kallithea.lib.compat import json
35
35
36
36 CONFIG_NAME = '.config/kallithea'
37 CONFIG_NAME = '.config/kallithea'
37 FORMAT_PRETTY = 'pretty'
38 FORMAT_PRETTY = 'pretty'
38 FORMAT_JSON = 'json'
39 FORMAT_JSON = 'json'
@@ -25,10 +25,10 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import argparse
28 import sys
29 import sys
29 import argparse
30
30
31 from kallithea.bin.base import json, api_call, RcConf, FORMAT_JSON, FORMAT_PRETTY
31 from kallithea.bin.base import FORMAT_JSON, FORMAT_PRETTY, RcConf, api_call, json
32
32
33
33
34 def argparser(argv):
34 def argparser(argv):
@@ -26,14 +26,15 b' Original author and date, and relevant c'
26 :license: GPLv3, see LICENSE.md for more details.
26 :license: GPLv3, see LICENSE.md for more details.
27 """
27 """
28
28
29 import datetime
30 import logging
29 import os
31 import os
32 import subprocess
30 import sys
33 import sys
31 import logging
32 import tarfile
34 import tarfile
33 import datetime
34 import subprocess
35 import tempfile
35 import tempfile
36
36
37
37 logging.basicConfig(level=logging.DEBUG,
38 logging.basicConfig(level=logging.DEBUG,
38 format="%(asctime)s %(levelname)-5.5s %(message)s")
39 format="%(asctime)s %(levelname)-5.5s %(message)s")
39
40
@@ -12,9 +12,6 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 # 'cli' is the main entry point for 'kallithea-cli', specified in setup.py as entry_points console_scripts
16 from kallithea.bin.kallithea_cli_base import cli
17
18 # import commands (they will add themselves to the 'cli' object)
15 # import commands (they will add themselves to the 'cli' object)
19 import kallithea.bin.kallithea_cli_celery
16 import kallithea.bin.kallithea_cli_celery
20 import kallithea.bin.kallithea_cli_config
17 import kallithea.bin.kallithea_cli_config
@@ -26,3 +23,5 b' import kallithea.bin.kallithea_cli_index'
26 import kallithea.bin.kallithea_cli_ishell
23 import kallithea.bin.kallithea_cli_ishell
27 import kallithea.bin.kallithea_cli_repo
24 import kallithea.bin.kallithea_cli_repo
28 import kallithea.bin.kallithea_cli_ssh
25 import kallithea.bin.kallithea_cli_ssh
26 # 'cli' is the main entry point for 'kallithea-cli', specified in setup.py as entry_points console_scripts
27 from kallithea.bin.kallithea_cli_base import cli
@@ -12,16 +12,17 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import click
16 import cStringIO
15 import cStringIO
17 import functools
16 import functools
17 import logging.config
18 import os
18 import os
19 import re
19 import re
20 import sys
20 import sys
21
21
22 import click
23 import paste.deploy
24
22 import kallithea
25 import kallithea
23 import logging.config
24 import paste.deploy
25
26
26
27
27 # kallithea_cli is usually invoked through the 'kallithea-cli' wrapper script
28 # kallithea_cli is usually invoked through the 'kallithea-cli' wrapper script
@@ -13,9 +13,10 b''
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import click
15 import click
16
17 import kallithea
16 import kallithea.bin.kallithea_cli_base as cli_base
18 import kallithea.bin.kallithea_cli_base as cli_base
17
19
18 import kallithea
19
20
20 @cli_base.register_command(config_file_initialize_app=True)
21 @cli_base.register_command(config_file_initialize_app=True)
21 @click.argument('celery_args', nargs=-1)
22 @click.argument('celery_args', nargs=-1)
@@ -12,19 +12,19 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import click
16 import kallithea.bin.kallithea_cli_base as cli_base
17
18 import os
15 import os
19 import sys
16 import sys
20 import uuid
17 import uuid
21 from collections import defaultdict
18 from collections import defaultdict
22
19
20 import click
23 import mako.exceptions
21 import mako.exceptions
24
22
23 import kallithea.bin.kallithea_cli_base as cli_base
25 import kallithea.lib.locale
24 import kallithea.lib.locale
26 from kallithea.lib import inifile
25 from kallithea.lib import inifile
27
26
27
28 def show_defaults(ctx, param, value):
28 def show_defaults(ctx, param, value):
29 # Following construct is taken from the Click documentation:
29 # Following construct is taken from the Click documentation:
30 # https://click.palletsprojects.com/en/7.x/options/#callbacks-and-eager-options
30 # https://click.palletsprojects.com/en/7.x/options/#callbacks-and-eager-options
@@ -12,12 +12,13 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 import click
14 import click
15 import kallithea.bin.kallithea_cli_base as cli_base
16
15
17 import kallithea
16 import kallithea
17 import kallithea.bin.kallithea_cli_base as cli_base
18 from kallithea.lib.db_manage import DbManage
18 from kallithea.lib.db_manage import DbManage
19 from kallithea.model.meta import Session
19 from kallithea.model.meta import Session
20
20
21
21 @cli_base.register_command(config_file=True)
22 @cli_base.register_command(config_file=True)
22 @click.option('--user', help='Username of administrator account.')
23 @click.option('--user', help='Username of administrator account.')
23 @click.option('--password', help='Password for administrator account.')
24 @click.option('--password', help='Password for administrator account.')
@@ -19,15 +19,16 b' Original author and date, and relevant c'
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
20 :license: GPLv3, see LICENSE.md for more details.
20 :license: GPLv3, see LICENSE.md for more details.
21 """
21 """
22 import os
23
22 import click
24 import click
23 import kallithea.bin.kallithea_cli_base as cli_base
24
25 import os
26 import pkg_resources
25 import pkg_resources
27
26
28 import kallithea
27 import kallithea
28 import kallithea.bin.kallithea_cli_base as cli_base
29 from kallithea.lib.utils2 import ask_ok
29 from kallithea.lib.utils2 import ask_ok
30
30
31
31 @cli_base.register_command(config_file=True)
32 @cli_base.register_command(config_file=True)
32 def extensions_create():
33 def extensions_create():
33 """Write template file for extending Kallithea in Python.
34 """Write template file for extending Kallithea in Python.
@@ -12,15 +12,16 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import click
15 import json
16 import kallithea.bin.kallithea_cli_base as cli_base
17
18 import os
16 import os
19 import shutil
17 import shutil
20 import subprocess
18 import subprocess
21 import json
19
20 import click
22
21
23 import kallithea
22 import kallithea
23 import kallithea.bin.kallithea_cli_base as cli_base
24
24
25
25 @cli_base.register_command()
26 @cli_base.register_command()
26 @click.option('--install-deps/--no-install-deps', default=True,
27 @click.option('--install-deps/--no-install-deps', default=True,
@@ -11,12 +11,14 b''
11 #
11 #
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 import os
15 import sys
16
14 import click
17 import click
18
15 import kallithea
19 import kallithea
16 import kallithea.bin.kallithea_cli_base as cli_base
20 import kallithea.bin.kallithea_cli_base as cli_base
17
21
18 import os
19 import sys
20
22
21 dispath_py_template = '''\
23 dispath_py_template = '''\
22 # Created by Kallithea 'kallithea-cli iis-install'
24 # Created by Kallithea 'kallithea-cli iis-install'
@@ -19,18 +19,19 b' Original author and date, and relevant c'
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
20 :license: GPLv3, see LICENSE.md for more details.
20 :license: GPLv3, see LICENSE.md for more details.
21 """
21 """
22 import click
23 import kallithea.bin.kallithea_cli_base as cli_base
24
25 import os
22 import os
26 import sys
23 import sys
27
24
25 import click
26
28 import kallithea
27 import kallithea
28 import kallithea.bin.kallithea_cli_base as cli_base
29 from kallithea.lib.indexers.daemon import WhooshIndexingDaemon
29 from kallithea.lib.indexers.daemon import WhooshIndexingDaemon
30 from kallithea.lib.pidlock import LockHeld, DaemonLock
30 from kallithea.lib.pidlock import DaemonLock, LockHeld
31 from kallithea.lib.utils import load_rcextensions
31 from kallithea.lib.utils import load_rcextensions
32 from kallithea.model.repo import RepoModel
32 from kallithea.model.repo import RepoModel
33
33
34
34 @cli_base.register_command(config_file_initialize_app=True)
35 @cli_base.register_command(config_file_initialize_app=True)
35 @click.option('--repo-location', help='Base path of repositories to index. Default: all')
36 @click.option('--repo-location', help='Base path of repositories to index. Default: all')
36 @click.option('--index-only', help='Comma-separated list of repositories to build index on. Default: all')
37 @click.option('--index-only', help='Comma-separated list of repositories to build index on. Default: all')
@@ -19,14 +19,14 b' Original author and date, and relevant c'
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
20 :license: GPLv3, see LICENSE.md for more details.
20 :license: GPLv3, see LICENSE.md for more details.
21 """
21 """
22 import click
23 import kallithea.bin.kallithea_cli_base as cli_base
24
25 import sys
22 import sys
26
23
27 # make following imports directly available inside the ishell
24 import click
25
26 import kallithea.bin.kallithea_cli_base as cli_base
28 from kallithea.model.db import *
27 from kallithea.model.db import *
29
28
29
30 @cli_base.register_command(config_file_initialize_app=True)
30 @cli_base.register_command(config_file_initialize_app=True)
31 def ishell():
31 def ishell():
32 """Interactive shell for Kallithea."""
32 """Interactive shell for Kallithea."""
@@ -19,20 +19,21 b' Original author and date, and relevant c'
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
19 :copyright: (c) 2013 RhodeCode GmbH, and others.
20 :license: GPLv3, see LICENSE.md for more details.
20 :license: GPLv3, see LICENSE.md for more details.
21 """
21 """
22 import click
23 import kallithea.bin.kallithea_cli_base as cli_base
24
25 import datetime
22 import datetime
26 import os
23 import os
27 import re
24 import re
28 import shutil
25 import shutil
29
26
30 from kallithea.lib.utils import repo2db_mapper, REMOVED_REPO_PAT
27 import click
31 from kallithea.lib.utils2 import safe_unicode, safe_str, ask_ok
28
29 import kallithea.bin.kallithea_cli_base as cli_base
30 from kallithea.lib.utils import REMOVED_REPO_PAT, repo2db_mapper
31 from kallithea.lib.utils2 import ask_ok, safe_str, safe_unicode
32 from kallithea.model.db import Repository, Ui
32 from kallithea.model.db import Repository, Ui
33 from kallithea.model.meta import Session
33 from kallithea.model.meta import Session
34 from kallithea.model.scm import ScmModel
34 from kallithea.model.scm import ScmModel
35
35
36
36 @cli_base.register_command(config_file_initialize_app=True)
37 @cli_base.register_command(config_file_initialize_app=True)
37 @click.option('--remove-missing', is_flag=True,
38 @click.option('--remove-missing', is_flag=True,
38 help='Remove missing repositories from the Kallithea database.')
39 help='Remove missing repositories from the Kallithea database.')
@@ -12,21 +12,22 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import click
15 import logging
16 import kallithea.bin.kallithea_cli_base as cli_base
17
18 import os
16 import os
17 import re
18 import shlex
19 import sys
19 import sys
20 import re
20
21 import logging
21 import click
22 import shlex
23
22
24 import kallithea
23 import kallithea
24 import kallithea.bin.kallithea_cli_base as cli_base
25 from kallithea.lib.utils2 import str2bool
25 from kallithea.lib.utils2 import str2bool
26 from kallithea.lib.vcs.backends.git.ssh import GitSshHandler
26 from kallithea.lib.vcs.backends.git.ssh import GitSshHandler
27 from kallithea.lib.vcs.backends.hg.ssh import MercurialSshHandler
27 from kallithea.lib.vcs.backends.hg.ssh import MercurialSshHandler
28 from kallithea.model.ssh_key import SshKeyModel
28 from kallithea.model.ssh_key import SshKeyModel
29
29
30
30 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
31
32
32
33
@@ -25,13 +25,13 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import os
29 import sys
30 import stat
31 import argparse
28 import argparse
32 import fileinput
29 import fileinput
30 import os
31 import stat
32 import sys
33
33
34 from kallithea.bin.base import json, api_call, RcConf, FORMAT_JSON, FORMAT_PRETTY
34 from kallithea.bin.base import FORMAT_JSON, FORMAT_PRETTY, RcConf, api_call, json
35
35
36
36
37 def argparser(argv):
37 def argparser(argv):
@@ -25,13 +25,14 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import ldap
29 import urllib2
28 import urllib2
30 import uuid
29 import uuid
30 from ConfigParser import ConfigParser
31
32 import ldap
31
33
32 from kallithea.lib.compat import json
34 from kallithea.lib.compat import json
33
35
34 from ConfigParser import ConfigParser
35
36
36 config = ConfigParser()
37 config = ConfigParser()
37 config.read('ldap_sync.conf')
38 config.read('ldap_sync.conf')
@@ -17,32 +17,33 b' Global configuration file for TurboGears'
17 This file complements the .ini file.
17 This file complements the .ini file.
18 """
18 """
19
19
20 import logging
21 import os
20 import platform
22 import platform
21 import os, sys, logging
23 import sys
22
24
25 import alembic.config
26 import formencode
27 import mercurial
23 import tg
28 import tg
29 from alembic.migration import MigrationContext
30 from alembic.script.base import ScriptDirectory
31 from sqlalchemy import create_engine
24 from tg import hooks
32 from tg import hooks
25 from tg.configuration import AppConfig
33 from tg.configuration import AppConfig
26 from tg.support.converters import asbool
34 from tg.support.converters import asbool
27 import alembic.config
28 from alembic.script.base import ScriptDirectory
29 from alembic.migration import MigrationContext
30 from sqlalchemy import create_engine
31 import mercurial
32
35
33 import kallithea.lib.locale
36 import kallithea.lib.locale
37 import kallithea.model.base
38 from kallithea.lib.auth import set_available_permissions
39 from kallithea.lib.middleware.https_fixup import HttpsFixup
34 from kallithea.lib.middleware.permanent_repo_url import PermanentRepoUrl
40 from kallithea.lib.middleware.permanent_repo_url import PermanentRepoUrl
35 from kallithea.lib.middleware.https_fixup import HttpsFixup
36 from kallithea.lib.middleware.simplegit import SimpleGit
41 from kallithea.lib.middleware.simplegit import SimpleGit
37 from kallithea.lib.middleware.simplehg import SimpleHg
42 from kallithea.lib.middleware.simplehg import SimpleHg
38 from kallithea.lib.auth import set_available_permissions
43 from kallithea.lib.utils import check_git_version, load_rcextensions, make_ui, repo2db_mapper, set_app_settings, set_indexer_config, set_vcs_config
39 from kallithea.lib.utils import load_rcextensions, make_ui, set_app_settings, set_vcs_config, \
40 set_indexer_config, check_git_version, repo2db_mapper
41 from kallithea.lib.utils2 import str2bool
44 from kallithea.lib.utils2 import str2bool
42 import kallithea.model.base
43 from kallithea.model.scm import ScmModel
45 from kallithea.model.scm import ScmModel
44
46
45 import formencode
46
47
47 log = logging.getLogger(__name__)
48 log = logging.getLogger(__name__)
48
49
@@ -15,6 +15,7 b''
15
15
16 from kallithea.config.app_cfg import base_config
16 from kallithea.config.app_cfg import base_config
17
17
18
18 __all__ = ['load_environment']
19 __all__ = ['load_environment']
19
20
20 # Use base_config to setup the environment loader function
21 # Use base_config to setup the environment loader function
@@ -14,9 +14,11 b''
14 """WSGI middleware initialization for the Kallithea application."""
14 """WSGI middleware initialization for the Kallithea application."""
15
15
16 import logging.config
16 import logging.config
17
17 from kallithea.config.app_cfg import base_config
18 from kallithea.config.app_cfg import base_config
18 from kallithea.config.environment import load_environment
19 from kallithea.config.environment import load_environment
19
20
21
20 __all__ = ['make_app']
22 __all__ = ['make_app']
21
23
22 # Use base_config to setup the necessary PasteDeploy application factory.
24 # Use base_config to setup the necessary PasteDeploy application factory.
@@ -11,6 +11,9 b' hook will use.'
11 import os
11 import os
12 import sys
12 import sys
13
13
14 import kallithea.lib.hooks
15
16
14 # Set output mode on windows to binary for stderr.
17 # Set output mode on windows to binary for stderr.
15 # This prevents python (or the windows console) from replacing \n with \r\n.
18 # This prevents python (or the windows console) from replacing \n with \r\n.
16 # Git doesn't display remote output lines that contain \r,
19 # Git doesn't display remote output lines that contain \r,
@@ -22,7 +25,6 b' if sys.platform == "win32":'
22
25
23 KALLITHEA_HOOK_VER = '_TMPL_'
26 KALLITHEA_HOOK_VER = '_TMPL_'
24 os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
27 os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
25 import kallithea.lib.hooks
26
28
27
29
28 def main():
30 def main():
@@ -11,6 +11,9 b' hook will use.'
11 import os
11 import os
12 import sys
12 import sys
13
13
14 import kallithea.lib.hooks
15
16
14 # Set output mode on windows to binary for stderr.
17 # Set output mode on windows to binary for stderr.
15 # This prevents python (or the windows console) from replacing \n with \r\n.
18 # This prevents python (or the windows console) from replacing \n with \r\n.
16 # Git doesn't display remote output lines that contain \r,
19 # Git doesn't display remote output lines that contain \r,
@@ -22,7 +25,6 b' if sys.platform == "win32":'
22
25
23 KALLITHEA_HOOK_VER = '_TMPL_'
26 KALLITHEA_HOOK_VER = '_TMPL_'
24 os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
27 os.environ['KALLITHEA_HOOK_VER'] = KALLITHEA_HOOK_VER
25 import kallithea.lib.hooks
26
28
27
29
28 def main():
30 def main():
@@ -19,8 +19,9 b' may take precedent over the more generic'
19 refer to the routes manual at http://routes.groovie.org/docs/
19 refer to the routes manual at http://routes.groovie.org/docs/
20 """
20 """
21
21
22 from routes import Mapper
22 from tg import request
23 from tg import request
23 from routes import Mapper
24
24
25
25 # prefix for non repository related links needs to be prefixed with `/`
26 # prefix for non repository related links needs to be prefixed with `/`
26 ADMIN_PREFIX = '/_admin'
27 ADMIN_PREFIX = '/_admin'
@@ -28,20 +28,21 b' Original author and date, and relevant c'
28
28
29 import logging
29 import logging
30
30
31 from tg import request, tmpl_context as c
32 from sqlalchemy.orm import joinedload
31 from sqlalchemy.orm import joinedload
32 from sqlalchemy.sql.expression import and_, func, or_
33 from tg import request
34 from tg import tmpl_context as c
35 from whoosh import query
36 from whoosh.qparser.dateparse import DateParserPlugin
33 from whoosh.qparser.default import QueryParser
37 from whoosh.qparser.default import QueryParser
34 from whoosh.qparser.dateparse import DateParserPlugin
35 from whoosh import query
36 from sqlalchemy.sql.expression import or_, and_, func
37
38
38 from kallithea.config.routing import url
39 from kallithea.config.routing import url
39 from kallithea.model.db import UserLog
40 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
40 from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
41 from kallithea.lib.base import BaseController, render
41 from kallithea.lib.base import BaseController, render
42 from kallithea.lib.utils2 import safe_int, remove_prefix, remove_suffix
43 from kallithea.lib.indexers import JOURNAL_SCHEMA
42 from kallithea.lib.indexers import JOURNAL_SCHEMA
44 from kallithea.lib.page import Page
43 from kallithea.lib.page import Page
44 from kallithea.lib.utils2 import remove_prefix, remove_suffix, safe_int
45 from kallithea.model.db import UserLog
45
46
46
47
47 log = logging.getLogger(__name__)
48 log = logging.getLogger(__name__)
@@ -24,23 +24,25 b' Original author and date, and relevant c'
24 """
24 """
25
25
26 import logging
26 import logging
27 import formencode.htmlfill
28 import traceback
27 import traceback
29
28
30 from tg import request, tmpl_context as c
29 import formencode.htmlfill
30 from tg import request
31 from tg import tmpl_context as c
31 from tg.i18n import ugettext as _
32 from tg.i18n import ugettext as _
32 from webob.exc import HTTPFound
33 from webob.exc import HTTPFound
33
34
34 from kallithea.config.routing import url
35 from kallithea.config.routing import url
36 from kallithea.lib import auth_modules
35 from kallithea.lib import helpers as h
37 from kallithea.lib import helpers as h
36 from kallithea.lib.compat import formatted_json
38 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
37 from kallithea.lib.base import BaseController, render
39 from kallithea.lib.base import BaseController, render
38 from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
40 from kallithea.lib.compat import formatted_json
39 from kallithea.lib import auth_modules
41 from kallithea.model.db import Setting
40 from kallithea.model.forms import AuthSettingsForm
42 from kallithea.model.forms import AuthSettingsForm
41 from kallithea.model.db import Setting
42 from kallithea.model.meta import Session
43 from kallithea.model.meta import Session
43
44
45
44 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
45
47
46
48
@@ -27,20 +27,22 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30 import formencode
31 import formencode
31 from formencode import htmlfill
32 from formencode import htmlfill
32
33 from tg import request
33 from tg import request, tmpl_context as c
34 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
35 from tg.i18n import ugettext as _
35 from webob.exc import HTTPFound
36 from webob.exc import HTTPFound
36
37
37 from kallithea.config.routing import url
38 from kallithea.config.routing import url
38 from kallithea.lib import helpers as h
39 from kallithea.lib import helpers as h
39 from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
40 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
40 from kallithea.lib.base import BaseController, render
41 from kallithea.lib.base import BaseController, render
42 from kallithea.model.db import Setting
41 from kallithea.model.forms import DefaultsForm
43 from kallithea.model.forms import DefaultsForm
42 from kallithea.model.meta import Session
44 from kallithea.model.meta import Session
43 from kallithea.model.db import Setting
45
44
46
45 log = logging.getLogger(__name__)
47 log = logging.getLogger(__name__)
46
48
@@ -25,27 +25,29 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import logging
28 import time
29 import time
29 import logging
30 import traceback
30 import traceback
31
31 import formencode.htmlfill
32 import formencode.htmlfill
32
33 from sqlalchemy.sql.expression import or_
33 from tg import request, response, tmpl_context as c
34 from tg import request, response
35 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
35 from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden
37 from webob.exc import HTTPForbidden, HTTPFound, HTTPNotFound
36
38
37 from kallithea.config.routing import url
39 from kallithea.config.routing import url
40 from kallithea.lib import helpers as h
41 from kallithea.lib.auth import LoginRequired
42 from kallithea.lib.base import BaseController, jsonify, render
43 from kallithea.lib.page import Page
44 from kallithea.lib.utils2 import safe_int, safe_unicode, time_to_datetime
45 from kallithea.lib.vcs.exceptions import NodeNotChangedError, VCSError
46 from kallithea.model.db import Gist, User
38 from kallithea.model.forms import GistForm
47 from kallithea.model.forms import GistForm
39 from kallithea.model.gist import GistModel
48 from kallithea.model.gist import GistModel
40 from kallithea.model.meta import Session
49 from kallithea.model.meta import Session
41 from kallithea.model.db import Gist, User
50
42 from kallithea.lib import helpers as h
43 from kallithea.lib.base import BaseController, render, jsonify
44 from kallithea.lib.auth import LoginRequired
45 from kallithea.lib.utils2 import safe_int, safe_unicode, time_to_datetime
46 from kallithea.lib.page import Page
47 from sqlalchemy.sql.expression import or_
48 from kallithea.lib.vcs.exceptions import VCSError, NodeNotChangedError
49
51
50 log = logging.getLogger(__name__)
52 log = logging.getLogger(__name__)
51
53
@@ -27,27 +27,29 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30 import formencode
31 import formencode
31
32 from formencode import htmlfill
32 from sqlalchemy import func
33 from sqlalchemy import func
33 from formencode import htmlfill
34 from tg import request
34 from tg import request, tmpl_context as c
35 from tg import tmpl_context as c
35 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
36 from webob.exc import HTTPFound
37 from webob.exc import HTTPFound
37
38
38 from kallithea.config.routing import url
39 from kallithea.config.routing import url
40 from kallithea.lib import auth_modules
39 from kallithea.lib import helpers as h
41 from kallithea.lib import helpers as h
40 from kallithea.lib import auth_modules
42 from kallithea.lib.auth import AuthUser, LoginRequired
41 from kallithea.lib.auth import LoginRequired, AuthUser
43 from kallithea.lib.base import BaseController, IfSshEnabled, render
42 from kallithea.lib.base import BaseController, render, IfSshEnabled
43 from kallithea.lib.utils2 import generate_api_key, safe_int
44 from kallithea.lib.utils2 import generate_api_key, safe_int
44 from kallithea.model.db import Repository, UserEmailMap, User, UserFollowing
45 from kallithea.model.api_key import ApiKeyModel
45 from kallithea.model.forms import UserForm, PasswordChangeForm
46 from kallithea.model.db import Repository, User, UserEmailMap, UserFollowing
46 from kallithea.model.user import UserModel
47 from kallithea.model.forms import PasswordChangeForm, UserForm
48 from kallithea.model.meta import Session
47 from kallithea.model.repo import RepoModel
49 from kallithea.model.repo import RepoModel
48 from kallithea.model.api_key import ApiKeyModel
49 from kallithea.model.ssh_key import SshKeyModel, SshKeyModelException
50 from kallithea.model.ssh_key import SshKeyModel, SshKeyModelException
50 from kallithea.model.meta import Session
51 from kallithea.model.user import UserModel
52
51
53
52 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
53
55
@@ -28,21 +28,23 b' Original author and date, and relevant c'
28
28
29 import logging
29 import logging
30 import traceback
30 import traceback
31
31 import formencode
32 import formencode
32 from formencode import htmlfill
33 from formencode import htmlfill
33
34 from tg import request
34 from tg import request, tmpl_context as c
35 from tg import tmpl_context as c
35 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
36 from webob.exc import HTTPFound
37 from webob.exc import HTTPFound
37
38
38 from kallithea.config.routing import url
39 from kallithea.config.routing import url
39 from kallithea.lib import helpers as h
40 from kallithea.lib import helpers as h
40 from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator, AuthUser
41 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
41 from kallithea.lib.base import BaseController, render
42 from kallithea.lib.base import BaseController, render
43 from kallithea.model.db import User, UserIpMap
42 from kallithea.model.forms import DefaultPermissionsForm
44 from kallithea.model.forms import DefaultPermissionsForm
45 from kallithea.model.meta import Session
43 from kallithea.model.permission import PermissionModel
46 from kallithea.model.permission import PermissionModel
44 from kallithea.model.db import User, UserIpMap
47
45 from kallithea.model.meta import Session
46
48
47 log = logging.getLogger(__name__)
49 log = logging.getLogger(__name__)
48
50
@@ -25,32 +25,31 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import itertools
28 import logging
29 import logging
29 import traceback
30 import traceback
31
30 import formencode
32 import formencode
31 import itertools
32
33 from formencode import htmlfill
33 from formencode import htmlfill
34
34 from sqlalchemy.sql.expression import func
35 from tg import request, tmpl_context as c, app_globals
35 from tg import app_globals, request
36 from tg.i18n import ugettext as _, ungettext
36 from tg import tmpl_context as c
37 from webob.exc import HTTPFound, HTTPForbidden, HTTPNotFound, HTTPInternalServerError
37 from tg.i18n import ugettext as _
38 from tg.i18n import ungettext
39 from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
38
40
39 import kallithea
41 import kallithea
40 from kallithea.config.routing import url
42 from kallithea.config.routing import url
41 from kallithea.lib import helpers as h
43 from kallithea.lib import helpers as h
42 from kallithea.lib.auth import LoginRequired, \
44 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoGroupPermissionLevelDecorator, LoginRequired
43 HasRepoGroupPermissionLevelDecorator, HasRepoGroupPermissionLevel, \
44 HasPermissionAny
45 from kallithea.lib.base import BaseController, render
45 from kallithea.lib.base import BaseController, render
46 from kallithea.lib.utils2 import safe_int
46 from kallithea.model.db import RepoGroup, Repository
47 from kallithea.model.db import RepoGroup, Repository
47 from kallithea.model.scm import RepoGroupList, AvailableRepoGroupChoices
48 from kallithea.model.repo_group import RepoGroupModel
49 from kallithea.model.forms import RepoGroupForm, RepoGroupPermsForm
48 from kallithea.model.forms import RepoGroupForm, RepoGroupPermsForm
50 from kallithea.model.meta import Session
49 from kallithea.model.meta import Session
51 from kallithea.model.repo import RepoModel
50 from kallithea.model.repo import RepoModel
52 from kallithea.lib.utils2 import safe_int
51 from kallithea.model.repo_group import RepoGroupModel
53 from sqlalchemy.sql.expression import func
52 from kallithea.model.scm import AvailableRepoGroupChoices, RepoGroupList
54
53
55
54
56 log = logging.getLogger(__name__)
55 log = logging.getLogger(__name__)
@@ -27,28 +27,29 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30 import formencode
31 import formencode
31 from formencode import htmlfill
32 from formencode import htmlfill
32 from tg import request, tmpl_context as c
33 from sqlalchemy.sql.expression import func
34 from tg import request
35 from tg import tmpl_context as c
33 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
34 from sqlalchemy.sql.expression import func
37 from webob.exc import HTTPForbidden, HTTPFound, HTTPInternalServerError, HTTPNotFound
35 from webob.exc import HTTPFound, HTTPInternalServerError, HTTPForbidden, HTTPNotFound
36
38
37 from kallithea.config.routing import url
39 from kallithea.config.routing import url
38 from kallithea.lib import helpers as h
40 from kallithea.lib import helpers as h
39 from kallithea.lib.auth import LoginRequired, \
41 from kallithea.lib.auth import HasPermissionAny, HasRepoPermissionLevelDecorator, LoginRequired, NotAnonymous
40 HasRepoPermissionLevelDecorator, NotAnonymous, HasPermissionAny
42 from kallithea.lib.base import BaseRepoController, jsonify, render
41 from kallithea.lib.base import BaseRepoController, render, jsonify
43 from kallithea.lib.exceptions import AttachedForksError
42 from kallithea.lib.utils import action_logger
44 from kallithea.lib.utils import action_logger
45 from kallithea.lib.utils2 import safe_int
43 from kallithea.lib.vcs import RepositoryError
46 from kallithea.lib.vcs import RepositoryError
47 from kallithea.model.db import RepoGroup, Repository, RepositoryField, Setting, User, UserFollowing
48 from kallithea.model.forms import RepoFieldForm, RepoForm, RepoPermsForm
44 from kallithea.model.meta import Session
49 from kallithea.model.meta import Session
45 from kallithea.model.db import User, Repository, UserFollowing, RepoGroup, \
46 Setting, RepositoryField
47 from kallithea.model.forms import RepoForm, RepoFieldForm, RepoPermsForm
48 from kallithea.model.scm import ScmModel, AvailableRepoGroupChoices, RepoList
49 from kallithea.model.repo import RepoModel
50 from kallithea.model.repo import RepoModel
50 from kallithea.lib.exceptions import AttachedForksError
51 from kallithea.model.scm import AvailableRepoGroupChoices, RepoList, ScmModel
51 from kallithea.lib.utils2 import safe_int
52
52
53
53 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
54
55
@@ -27,28 +27,30 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30 import formencode
31 import formencode
31
32 from formencode import htmlfill
32 from formencode import htmlfill
33 from tg import request, tmpl_context as c, config
33 from tg import config, request
34 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
35 from tg.i18n import ugettext as _
35 from webob.exc import HTTPFound
36 from webob.exc import HTTPFound
36
37
37 from kallithea.config.routing import url
38 from kallithea.config.routing import url
38 from kallithea.lib import helpers as h
39 from kallithea.lib import helpers as h
39 from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator
40 from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired
40 from kallithea.lib.base import BaseController, render
41 from kallithea.lib.base import BaseController, render
41 from kallithea.lib.celerylib import tasks
42 from kallithea.lib.celerylib import tasks
42 from kallithea.lib.exceptions import HgsubversionImportError
43 from kallithea.lib.exceptions import HgsubversionImportError
43 from kallithea.lib.utils import repo2db_mapper, set_app_settings
44 from kallithea.lib.utils import repo2db_mapper, set_app_settings
45 from kallithea.lib.utils2 import safe_unicode, str2bool
44 from kallithea.lib.vcs import VCSError
46 from kallithea.lib.vcs import VCSError
45 from kallithea.model.db import Ui, Repository, Setting
47 from kallithea.model.db import Repository, Setting, Ui
46 from kallithea.model.forms import ApplicationSettingsForm, \
48 from kallithea.model.forms import ApplicationSettingsForm, ApplicationUiSettingsForm, ApplicationVisualisationForm
47 ApplicationUiSettingsForm, ApplicationVisualisationForm
49 from kallithea.model.meta import Session
50 from kallithea.model.notification import EmailNotificationModel
48 from kallithea.model.scm import ScmModel
51 from kallithea.model.scm import ScmModel
49 from kallithea.model.notification import EmailNotificationModel
52
50 from kallithea.model.meta import Session
53
51 from kallithea.lib.utils2 import str2bool, safe_unicode
52 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
53
55
54
56
@@ -27,35 +27,31 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30 import formencode
31 import formencode
31
32 from formencode import htmlfill
32 from formencode import htmlfill
33 from tg import request, tmpl_context as c, config, app_globals
34 from tg.i18n import ugettext as _
35 from webob.exc import HTTPFound
36
37 from sqlalchemy.orm import joinedload
33 from sqlalchemy.orm import joinedload
38 from sqlalchemy.sql.expression import func
34 from sqlalchemy.sql.expression import func
39 from webob.exc import HTTPInternalServerError
35 from tg import app_globals, config, request
36 from tg import tmpl_context as c
37 from tg.i18n import ugettext as _
38 from webob.exc import HTTPFound, HTTPInternalServerError
40
39
41 import kallithea
40 import kallithea
42 from kallithea.config.routing import url
41 from kallithea.config.routing import url
43 from kallithea.lib import helpers as h
42 from kallithea.lib import helpers as h
44 from kallithea.lib.exceptions import UserGroupsAssignedException, \
43 from kallithea.lib.auth import HasPermissionAnyDecorator, HasUserGroupPermissionLevelDecorator, LoginRequired
45 RepoGroupAssignmentError
46 from kallithea.lib.utils2 import safe_unicode, safe_int
47 from kallithea.lib.auth import LoginRequired, \
48 HasUserGroupPermissionLevelDecorator, HasPermissionAnyDecorator
49 from kallithea.lib.base import BaseController, render
44 from kallithea.lib.base import BaseController, render
45 from kallithea.lib.exceptions import RepoGroupAssignmentError, UserGroupsAssignedException
46 from kallithea.lib.utils import action_logger
47 from kallithea.lib.utils2 import safe_int, safe_unicode
48 from kallithea.model.db import User, UserGroup, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserGroupToPerm
49 from kallithea.model.forms import CustomDefaultPermissionsForm, UserGroupForm, UserGroupPermsForm
50 from kallithea.model.meta import Session
51 from kallithea.model.repo import RepoModel
50 from kallithea.model.scm import UserGroupList
52 from kallithea.model.scm import UserGroupList
51 from kallithea.model.user_group import UserGroupModel
53 from kallithea.model.user_group import UserGroupModel
52 from kallithea.model.repo import RepoModel
54
53 from kallithea.model.db import User, UserGroup, UserGroupToPerm, \
54 UserGroupRepoToPerm, UserGroupRepoGroupToPerm
55 from kallithea.model.forms import UserGroupForm, UserGroupPermsForm, \
56 CustomDefaultPermissionsForm
57 from kallithea.model.meta import Session
58 from kallithea.lib.utils import action_logger
59
55
60 log = logging.getLogger(__name__)
56 log = logging.getLogger(__name__)
61
57
@@ -27,31 +27,31 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30 import formencode
31 import formencode
31
32 from formencode import htmlfill
32 from formencode import htmlfill
33 from tg import request, tmpl_context as c, config, app_globals
33 from sqlalchemy.sql.expression import func
34 from tg import app_globals, config, request
35 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
35 from sqlalchemy.sql.expression import func
36 from webob.exc import HTTPFound, HTTPNotFound
37 from webob.exc import HTTPFound, HTTPNotFound
37
38
38 import kallithea
39 import kallithea
39 from kallithea.config.routing import url
40 from kallithea.config.routing import url
40 from kallithea.lib.exceptions import DefaultUserException, \
41 from kallithea.lib import auth_modules
41 UserOwnsReposException, UserCreationError
42 from kallithea.lib import helpers as h
42 from kallithea.lib import helpers as h
43 from kallithea.lib.auth import LoginRequired, HasPermissionAnyDecorator, \
43 from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator, LoginRequired
44 AuthUser
44 from kallithea.lib.base import BaseController, IfSshEnabled, render
45 from kallithea.lib import auth_modules
45 from kallithea.lib.exceptions import DefaultUserException, UserCreationError, UserOwnsReposException
46 from kallithea.lib.base import BaseController, render, IfSshEnabled
46 from kallithea.lib.utils import action_logger
47 from kallithea.lib.utils2 import datetime_to_time, generate_api_key, safe_int
47 from kallithea.model.api_key import ApiKeyModel
48 from kallithea.model.api_key import ApiKeyModel
49 from kallithea.model.db import User, UserEmailMap, UserIpMap, UserToPerm
50 from kallithea.model.forms import CustomDefaultPermissionsForm, UserForm
51 from kallithea.model.meta import Session
48 from kallithea.model.ssh_key import SshKeyModel, SshKeyModelException
52 from kallithea.model.ssh_key import SshKeyModel, SshKeyModelException
49 from kallithea.model.db import User, UserEmailMap, UserIpMap, UserToPerm
50 from kallithea.model.forms import UserForm, CustomDefaultPermissionsForm
51 from kallithea.model.user import UserModel
53 from kallithea.model.user import UserModel
52 from kallithea.model.meta import Session
54
53 from kallithea.lib.utils import action_logger
54 from kallithea.lib.utils2 import datetime_to_time, safe_int, generate_api_key
55
55
56 log = logging.getLogger(__name__)
56 log = logging.getLogger(__name__)
57
57
@@ -26,22 +26,23 b' Original author and date, and relevant c'
26 """
26 """
27
27
28 import inspect
28 import inspect
29 import itertools
29 import logging
30 import logging
30 import types
31 import traceback
32 import time
31 import time
33 import itertools
32 import traceback
33 import types
34
34
35 from tg import Response, response, request, TGController
35 from tg import Response, TGController, request, response
36
37 from webob.exc import HTTPError, HTTPException, WSGIHTTPException
36 from webob.exc import HTTPError, HTTPException, WSGIHTTPException
38
37
39 from kallithea.model.db import User
38 from kallithea.lib.auth import AuthUser
40 from kallithea.model import meta
39 from kallithea.lib.base import _get_access_path
40 from kallithea.lib.base import _get_ip_addr as _get_ip
41 from kallithea.lib.compat import json
41 from kallithea.lib.compat import json
42 from kallithea.lib.auth import AuthUser
42 from kallithea.lib.utils2 import safe_str, safe_unicode
43 from kallithea.lib.base import _get_ip_addr as _get_ip, _get_access_path
43 from kallithea.model import meta
44 from kallithea.lib.utils2 import safe_unicode, safe_str
44 from kallithea.model.db import User
45
45
46
46 log = logging.getLogger('JSONRPC')
47 log = logging.getLogger('JSONRPC')
47
48
@@ -25,42 +25,35 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import logging
28 import time
29 import time
29 import traceback
30 import traceback
30 import logging
31 from datetime import datetime
31
32
32 from datetime import datetime
33 from sqlalchemy import or_
33 from sqlalchemy import or_
34
35 from tg import request
34 from tg import request
36
35
37 from kallithea.controllers.api import JSONRPCController, JSONRPCError
36 from kallithea.controllers.api import JSONRPCController, JSONRPCError
38 from kallithea.lib.auth import (
37 from kallithea.lib.auth import (
39 PasswordGenerator, AuthUser, HasPermissionAnyDecorator,
38 AuthUser, HasPermissionAny, HasPermissionAnyDecorator, HasRepoGroupPermissionLevel, HasRepoPermissionLevel, HasUserGroupPermissionLevel, PasswordGenerator)
40 HasPermissionAnyDecorator, HasPermissionAny, HasRepoPermissionLevel,
39 from kallithea.lib.compat import json
41 HasRepoGroupPermissionLevel, HasUserGroupPermissionLevel)
40 from kallithea.lib.exceptions import DefaultUserException, UserGroupsAssignedException
42 from kallithea.lib.utils import map_groups, repo2db_mapper
41 from kallithea.lib.utils import action_logger, map_groups, repo2db_mapper
43 from kallithea.lib.utils2 import (
42 from kallithea.lib.utils2 import OAttr, Optional, safe_int, str2bool, time_to_datetime
44 str2bool, time_to_datetime, safe_int, Optional, OAttr)
43 from kallithea.lib.vcs.backends.base import EmptyChangeset
44 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
45 from kallithea.model.changeset_status import ChangesetStatusModel
46 from kallithea.model.comment import ChangesetCommentsModel
47 from kallithea.model.db import ChangesetStatus, Gist, Permission, PullRequest, RepoGroup, Repository, Setting, User, UserGroup, UserIpMap
48 from kallithea.model.gist import GistModel
45 from kallithea.model.meta import Session
49 from kallithea.model.meta import Session
50 from kallithea.model.pull_request import PullRequestModel
51 from kallithea.model.repo import RepoModel
46 from kallithea.model.repo_group import RepoGroupModel
52 from kallithea.model.repo_group import RepoGroupModel
47 from kallithea.model.scm import ScmModel, UserGroupList
53 from kallithea.model.scm import ScmModel, UserGroupList
48 from kallithea.model.repo import RepoModel
49 from kallithea.model.user import UserModel
54 from kallithea.model.user import UserModel
50 from kallithea.model.user_group import UserGroupModel
55 from kallithea.model.user_group import UserGroupModel
51 from kallithea.model.gist import GistModel
56
52 from kallithea.model.changeset_status import ChangesetStatusModel
53 from kallithea.model.comment import ChangesetCommentsModel
54 from kallithea.model.pull_request import PullRequestModel
55 from kallithea.model.db import (
56 Repository, Setting, UserIpMap, Permission, User, Gist,
57 RepoGroup, UserGroup, PullRequest, ChangesetStatus)
58 from kallithea.lib.compat import json
59 from kallithea.lib.exceptions import (
60 DefaultUserException, UserGroupsAssignedException)
61 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
62 from kallithea.lib.vcs.backends.base import EmptyChangeset
63 from kallithea.lib.utils import action_logger
64
57
65 log = logging.getLogger(__name__)
58 log = logging.getLogger(__name__)
66
59
@@ -28,19 +28,19 b' Original author and date, and relevant c'
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30
31 from tg import request, session, tmpl_context as c
31 from tg import request, session
32 from tg import tmpl_context as c
32 from tg.i18n import ugettext as _
33 from tg.i18n import ugettext as _
33 from webob.exc import HTTPFound, HTTPNotFound, HTTPBadRequest
34 from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
34
35
35 import kallithea.lib.helpers as h
36 import kallithea.lib.helpers as h
36 from kallithea.config.routing import url
37 from kallithea.config.routing import url
37 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
38 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
38 from kallithea.lib.base import BaseRepoController, render
39 from kallithea.lib.base import BaseRepoController, render
39 from kallithea.lib.graphmod import graph_data
40 from kallithea.lib.graphmod import graph_data
40 from kallithea.lib.page import RepoPage
41 from kallithea.lib.page import RepoPage
41 from kallithea.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError, \
42 ChangesetError, NodeDoesNotExistError, EmptyRepositoryError
43 from kallithea.lib.utils2 import safe_int, safe_str
42 from kallithea.lib.utils2 import safe_int, safe_str
43 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, EmptyRepositoryError, NodeDoesNotExistError, RepositoryError
44
44
45
45
46 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
@@ -27,29 +27,29 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30 from collections import defaultdict, OrderedDict
30 from collections import OrderedDict, defaultdict
31
31
32 from tg import tmpl_context as c, request, response
32 from tg import request, response
33 from tg import tmpl_context as c
33 from tg.i18n import ugettext as _
34 from tg.i18n import ugettext as _
34 from webob.exc import HTTPFound, HTTPForbidden, HTTPBadRequest, HTTPNotFound
35 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
35
36 from kallithea.lib.vcs.exceptions import RepositoryError, \
37 ChangesetDoesNotExistError, EmptyRepositoryError
38
36
39 import kallithea.lib.helpers as h
37 import kallithea.lib.helpers as h
40 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
38 from kallithea.lib import diffs
41 from kallithea.lib.base import BaseRepoController, render, jsonify
39 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
40 from kallithea.lib.base import BaseRepoController, jsonify, render
41 from kallithea.lib.graphmod import graph_data
42 from kallithea.lib.utils import action_logger
42 from kallithea.lib.utils import action_logger
43 from kallithea.lib import diffs
43 from kallithea.lib.utils2 import safe_unicode
44 from kallithea.lib.vcs.backends.base import EmptyChangeset
45 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
46 from kallithea.model.changeset_status import ChangesetStatusModel
47 from kallithea.model.comment import ChangesetCommentsModel
44 from kallithea.model.db import ChangesetComment, ChangesetStatus
48 from kallithea.model.db import ChangesetComment, ChangesetStatus
45 from kallithea.model.comment import ChangesetCommentsModel
46 from kallithea.model.changeset_status import ChangesetStatusModel
47 from kallithea.model.meta import Session
49 from kallithea.model.meta import Session
48 from kallithea.model.pull_request import PullRequestModel
50 from kallithea.model.pull_request import PullRequestModel
49 from kallithea.model.repo import RepoModel
51 from kallithea.model.repo import RepoModel
50 from kallithea.lib.vcs.backends.base import EmptyChangeset
52
51 from kallithea.lib.utils2 import safe_unicode
52 from kallithea.lib.graphmod import graph_data
53
53
54 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
55
55
@@ -30,20 +30,22 b' Original author and date, and relevant c'
30 import logging
30 import logging
31 import re
31 import re
32
32
33 from tg import request, tmpl_context as c
33 from tg import request
34 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
35 from tg.i18n import ugettext as _
35 from webob.exc import HTTPFound, HTTPBadRequest, HTTPNotFound
36 from webob.exc import HTTPBadRequest, HTTPFound, HTTPNotFound
36
37
37 from kallithea.config.routing import url
38 from kallithea.config.routing import url
38 from kallithea.lib.utils2 import safe_str, safe_int
39 from kallithea.controllers.changeset import _context_url, _ignorews_url
39 from kallithea.lib.vcs.utils.hgcompat import unionrepo
40 from kallithea.lib import diffs
40 from kallithea.lib import helpers as h
41 from kallithea.lib import helpers as h
42 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
41 from kallithea.lib.base import BaseRepoController, render
43 from kallithea.lib.base import BaseRepoController, render
42 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
44 from kallithea.lib.graphmod import graph_data
43 from kallithea.lib import diffs
45 from kallithea.lib.utils2 import safe_int, safe_str
46 from kallithea.lib.vcs.utils.hgcompat import unionrepo
44 from kallithea.model.db import Repository
47 from kallithea.model.db import Repository
45 from kallithea.controllers.changeset import _ignorews_url, _context_url
48
46 from kallithea.lib.graphmod import graph_data
47
49
48 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
49
51
@@ -25,15 +25,17 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import os
29 import cgi
28 import cgi
30 import logging
29 import logging
30 import os
31
31
32 from tg import tmpl_context as c, request, config, expose
32 from tg import config, expose, request
33 from tg import tmpl_context as c
33 from tg.i18n import ugettext as _
34 from tg.i18n import ugettext as _
34
35
35 from kallithea.lib.base import BaseController, render
36 from kallithea.lib.base import BaseController, render
36
37
38
37 log = logging.getLogger(__name__)
39 log = logging.getLogger(__name__)
38
40
39
41
@@ -28,19 +28,20 b' Original author and date, and relevant c'
28
28
29 import logging
29 import logging
30
30
31 from tg import response, tmpl_context as c
31 from beaker.cache import cache_region, region_invalidate
32 from tg import response
33 from tg import tmpl_context as c
32 from tg.i18n import ugettext as _
34 from tg.i18n import ugettext as _
33
34 from beaker.cache import cache_region, region_invalidate
35 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
35 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
36
36
37 from kallithea import CONFIG
37 from kallithea import CONFIG
38 from kallithea.lib import helpers as h
38 from kallithea.lib import helpers as h
39 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
39 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
40 from kallithea.lib.base import BaseRepoController
40 from kallithea.lib.base import BaseRepoController
41 from kallithea.lib.diffs import DiffProcessor
41 from kallithea.lib.diffs import DiffProcessor
42 from kallithea.lib.utils2 import safe_int, safe_unicode, str2bool
42 from kallithea.model.db import CacheInvalidation
43 from kallithea.model.db import CacheInvalidation
43 from kallithea.lib.utils2 import safe_int, str2bool, safe_unicode
44
44
45
45 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
46
47
@@ -25,43 +25,36 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import logging
28 import os
29 import os
29 import posixpath
30 import posixpath
30 import logging
31 import shutil
32 import tempfile
31 import traceback
33 import traceback
32 import tempfile
33 import shutil
34 from collections import OrderedDict
34 from collections import OrderedDict
35
35
36 from tg import request, response, tmpl_context as c
36 from tg import request, response
37 from tg import tmpl_context as c
37 from tg.i18n import ugettext as _
38 from tg.i18n import ugettext as _
38 from webob.exc import HTTPFound
39 from webob.exc import HTTPFound, HTTPNotFound
39
40
40 from kallithea.config.routing import url
41 from kallithea.config.routing import url
41 from kallithea.lib.utils import action_logger
42 from kallithea.controllers.changeset import _context_url, _ignorews_url, anchor_url, get_ignore_ws, get_line_ctx
42 from kallithea.lib import diffs
43 from kallithea.lib import diffs
43 from kallithea.lib import helpers as h
44 from kallithea.lib import helpers as h
44
45 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
45 from kallithea.lib.utils2 import convert_line_endings, detect_mode, safe_str, \
46 from kallithea.lib.base import BaseRepoController, jsonify, render
46 str2bool, safe_int
47 from kallithea.lib.exceptions import NonRelativePathError
47 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
48 from kallithea.lib.utils import action_logger
48 from kallithea.lib.base import BaseRepoController, render, jsonify
49 from kallithea.lib.utils2 import convert_line_endings, detect_mode, safe_int, safe_str, str2bool
49 from kallithea.lib.vcs.backends.base import EmptyChangeset
50 from kallithea.lib.vcs.backends.base import EmptyChangeset
50 from kallithea.lib.vcs.conf import settings
51 from kallithea.lib.vcs.conf import settings
51 from kallithea.lib.vcs.exceptions import RepositoryError, \
52 from kallithea.lib.vcs.exceptions import (
52 ChangesetDoesNotExistError, EmptyRepositoryError, \
53 ChangesetDoesNotExistError, ChangesetError, EmptyRepositoryError, ImproperArchiveTypeError, NodeAlreadyExistsError, NodeDoesNotExistError, NodeError, RepositoryError, VCSError)
53 ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError, \
54 NodeDoesNotExistError, ChangesetError, NodeError
55 from kallithea.lib.vcs.nodes import FileNode
54 from kallithea.lib.vcs.nodes import FileNode
56
55 from kallithea.model.db import Repository
57 from kallithea.model.repo import RepoModel
56 from kallithea.model.repo import RepoModel
58 from kallithea.model.scm import ScmModel
57 from kallithea.model.scm import ScmModel
59 from kallithea.model.db import Repository
60
61 from kallithea.controllers.changeset import anchor_url, _ignorews_url, \
62 _context_url, get_line_ctx, get_ignore_ws
63 from webob.exc import HTTPNotFound
64 from kallithea.lib.exceptions import NonRelativePathError
65
58
66
59
67 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
@@ -27,14 +27,16 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29
29
30 from tg import tmpl_context as c, request
30 from tg import request
31 from tg import tmpl_context as c
31
32
32 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
33 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
33 from kallithea.lib.base import BaseRepoController, render
34 from kallithea.lib.base import BaseRepoController, render
34 from kallithea.lib.page import Page
35 from kallithea.lib.page import Page
35 from kallithea.lib.utils2 import safe_int
36 from kallithea.lib.utils2 import safe_int
36 from kallithea.model.db import UserFollowing
37 from kallithea.model.db import UserFollowing
37
38
39
38 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
39
41
40
42
@@ -26,26 +26,26 b' Original author and date, and relevant c'
26 """
26 """
27
27
28 import logging
28 import logging
29 import traceback
30
29 import formencode
31 import formencode
30 import traceback
31 from formencode import htmlfill
32 from formencode import htmlfill
32
33 from tg import request
33 from tg import tmpl_context as c, request
34 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
35 from tg.i18n import ugettext as _
35 from webob.exc import HTTPFound
36 from webob.exc import HTTPFound
36
37
37 import kallithea.lib.helpers as h
38 import kallithea.lib.helpers as h
38
39 from kallithea.config.routing import url
39 from kallithea.config.routing import url
40 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator, \
40 from kallithea.lib.auth import HasPermissionAny, HasPermissionAnyDecorator, HasRepoPermissionLevel, HasRepoPermissionLevelDecorator, LoginRequired
41 HasRepoPermissionLevel, HasPermissionAnyDecorator, HasPermissionAny
42 from kallithea.lib.base import BaseRepoController, render
41 from kallithea.lib.base import BaseRepoController, render
43 from kallithea.lib.page import Page
42 from kallithea.lib.page import Page
44 from kallithea.lib.utils2 import safe_int
43 from kallithea.lib.utils2 import safe_int
45 from kallithea.model.db import Repository, UserFollowing, User, Ui
44 from kallithea.model.db import Repository, Ui, User, UserFollowing
45 from kallithea.model.forms import RepoForkForm
46 from kallithea.model.repo import RepoModel
46 from kallithea.model.repo import RepoModel
47 from kallithea.model.forms import RepoForkForm
47 from kallithea.model.scm import AvailableRepoGroupChoices, ScmModel
48 from kallithea.model.scm import ScmModel, AvailableRepoGroupChoices
48
49
49
50 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
51
51
@@ -28,20 +28,22 b' Original author and date, and relevant c'
28
28
29 import logging
29 import logging
30
30
31 from tg import tmpl_context as c, request
31 from sqlalchemy import and_, or_
32 from sqlalchemy.sql.expression import func
33 from tg import request
34 from tg import tmpl_context as c
32 from tg.i18n import ugettext as _
35 from tg.i18n import ugettext as _
33 from webob.exc import HTTPBadRequest
36 from webob.exc import HTTPBadRequest
34 from sqlalchemy.sql.expression import func
35 from sqlalchemy import or_, and_
36
37
38 from kallithea.lib import helpers as h
39 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
40 from kallithea.lib.base import BaseController, jsonify, render
37 from kallithea.lib.utils import conditional_cache
41 from kallithea.lib.utils import conditional_cache
38 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
42 from kallithea.model.db import RepoGroup, Repository, User, UserGroup
39 from kallithea.lib.base import BaseController, render, jsonify
40 from kallithea.lib import helpers as h
41 from kallithea.model.db import Repository, RepoGroup, User, UserGroup
42 from kallithea.model.repo import RepoModel
43 from kallithea.model.repo import RepoModel
43 from kallithea.model.scm import UserGroupList
44 from kallithea.model.scm import UserGroupList
44
45
46
45 log = logging.getLogger(__name__)
47 log = logging.getLogger(__name__)
46
48
47
49
@@ -33,23 +33,23 b' from itertools import groupby'
33 from sqlalchemy import or_
33 from sqlalchemy import or_
34 from sqlalchemy.orm import joinedload
34 from sqlalchemy.orm import joinedload
35 from sqlalchemy.sql.expression import func
35 from sqlalchemy.sql.expression import func
36
36 from tg import request, response
37 from tg import tmpl_context as c
38 from tg.i18n import ugettext as _
37 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
39 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
38
39 from webob.exc import HTTPBadRequest
40 from webob.exc import HTTPBadRequest
40 from tg import request, tmpl_context as c, response
41 from tg.i18n import ugettext as _
42
41
42 import kallithea.lib.helpers as h
43 from kallithea.config.routing import url
43 from kallithea.config.routing import url
44 from kallithea.controllers.admin.admin import _journal_filter
44 from kallithea.controllers.admin.admin import _journal_filter
45 from kallithea.model.db import UserLog, UserFollowing, Repository, User
46 from kallithea.model.meta import Session
47 from kallithea.model.repo import RepoModel
48 import kallithea.lib.helpers as h
49 from kallithea.lib.auth import LoginRequired
45 from kallithea.lib.auth import LoginRequired
50 from kallithea.lib.base import BaseController, render
46 from kallithea.lib.base import BaseController, render
51 from kallithea.lib.page import Page
47 from kallithea.lib.page import Page
52 from kallithea.lib.utils2 import safe_int, AttributeDict
48 from kallithea.lib.utils2 import AttributeDict, safe_int
49 from kallithea.model.db import Repository, User, UserFollowing, UserLog
50 from kallithea.model.meta import Session
51 from kallithea.model.repo import RepoModel
52
53
53
54 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
55
55
@@ -28,12 +28,13 b' Original author and date, and relevant c'
28
28
29 import logging
29 import logging
30 import re
30 import re
31
31 import formencode
32 import formencode
32
33 from formencode import htmlfill
33 from formencode import htmlfill
34 from tg import request, session
35 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
35 from tg import request, session, tmpl_context as c
37 from webob.exc import HTTPBadRequest, HTTPFound
36 from webob.exc import HTTPFound, HTTPBadRequest
37
38
38 import kallithea.lib.helpers as h
39 import kallithea.lib.helpers as h
39 from kallithea.config.routing import url
40 from kallithea.config.routing import url
@@ -41,11 +42,10 b' from kallithea.lib.auth import AuthUser,'
41 from kallithea.lib.base import BaseController, log_in_user, render
42 from kallithea.lib.base import BaseController, log_in_user, render
42 from kallithea.lib.exceptions import UserCreationError
43 from kallithea.lib.exceptions import UserCreationError
43 from kallithea.lib.utils2 import safe_str
44 from kallithea.lib.utils2 import safe_str
44 from kallithea.model.db import User, Setting
45 from kallithea.model.db import Setting, User
45 from kallithea.model.forms import \
46 from kallithea.model.forms import LoginForm, PasswordResetConfirmationForm, PasswordResetRequestForm, RegisterForm
46 LoginForm, RegisterForm, PasswordResetRequestForm, PasswordResetConfirmationForm
47 from kallithea.model.meta import Session
47 from kallithea.model.user import UserModel
48 from kallithea.model.user import UserModel
48 from kallithea.model.meta import Session
49
49
50
50
51 log = logging.getLogger(__name__)
51 log = logging.getLogger(__name__)
@@ -27,35 +27,35 b' Original author and date, and relevant c'
27
27
28 import logging
28 import logging
29 import traceback
29 import traceback
30
30 import formencode
31 import formencode
31
32 from tg import request
32 from tg import request, tmpl_context as c
33 from tg import tmpl_context as c
33 from tg.i18n import ugettext as _
34 from tg.i18n import ugettext as _
34 from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest
35 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
35
36
36 from kallithea.config.routing import url
37 from kallithea.config.routing import url
37 from kallithea.lib import helpers as h
38 from kallithea.controllers.changeset import _context_url, _ignorews_url, create_cs_pr_comment, delete_cs_pr_comment
39 from kallithea.controllers.compare import CompareController
38 from kallithea.lib import diffs
40 from kallithea.lib import diffs
39 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
41 from kallithea.lib import helpers as h
40 from kallithea.lib.base import BaseRepoController, render, jsonify
42 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
43 from kallithea.lib.base import BaseRepoController, jsonify, render
44 from kallithea.lib.graphmod import graph_data
41 from kallithea.lib.page import Page
45 from kallithea.lib.page import Page
42 from kallithea.lib.utils import action_logger
46 from kallithea.lib.utils import action_logger
43 from kallithea.lib.vcs.exceptions import EmptyRepositoryError, ChangesetDoesNotExistError
47 from kallithea.lib.utils2 import safe_int
48 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
44 from kallithea.lib.vcs.utils import safe_str
49 from kallithea.lib.vcs.utils import safe_str
45 from kallithea.lib.vcs.utils.hgcompat import unionrepo
50 from kallithea.lib.vcs.utils.hgcompat import unionrepo
46 from kallithea.model.db import PullRequest, ChangesetStatus, \
51 from kallithea.model.changeset_status import ChangesetStatusModel
47 PullRequestReviewer, Repository, User
48 from kallithea.model.pull_request import CreatePullRequestAction, CreatePullRequestIterationAction, PullRequestModel
49 from kallithea.model.meta import Session
50 from kallithea.model.repo import RepoModel
51 from kallithea.model.comment import ChangesetCommentsModel
52 from kallithea.model.comment import ChangesetCommentsModel
52 from kallithea.model.changeset_status import ChangesetStatusModel
53 from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, Repository, User
53 from kallithea.model.forms import PullRequestForm, PullRequestPostForm
54 from kallithea.model.forms import PullRequestForm, PullRequestPostForm
54 from kallithea.lib.utils2 import safe_int
55 from kallithea.model.meta import Session
55 from kallithea.controllers.changeset import _ignorews_url, _context_url, \
56 from kallithea.model.pull_request import CreatePullRequestAction, CreatePullRequestIterationAction, PullRequestModel
56 create_cs_pr_comment, delete_cs_pr_comment
57 from kallithea.model.repo import RepoModel
57 from kallithea.controllers.compare import CompareController
58
58 from kallithea.lib.graphmod import graph_data
59
59
60 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
61
61
@@ -11,11 +11,12 b''
11 #
11 #
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 from tg import config
14 from tgext.routes import RoutedController
15 from tgext.routes import RoutedController
16
15 from kallithea.config.routing import make_map
17 from kallithea.config.routing import make_map
18 from kallithea.controllers.error import ErrorController
16 from kallithea.lib.base import BaseController
19 from kallithea.lib.base import BaseController
17 from kallithea.controllers.error import ErrorController
18 from tg import config
19
20
20
21
21 # This is the main Kallithea entry point; TurboGears will forward all requests
22 # This is the main Kallithea entry point; TurboGears will forward all requests
@@ -28,22 +28,23 b' Original author and date, and relevant c'
28 import logging
28 import logging
29 import traceback
29 import traceback
30 import urllib
30 import urllib
31
32 from tg import config, request
33 from tg import tmpl_context as c
31 from tg.i18n import ugettext as _
34 from tg.i18n import ugettext as _
32 from tg import request, config, tmpl_context as c
35 from webhelpers2.html.tools import update_params
33
36 from whoosh.index import EmptyIndexError, exists_in, open_dir
34 from whoosh.index import open_dir, exists_in, EmptyIndexError
35 from whoosh.qparser import QueryParser, QueryParserError
37 from whoosh.qparser import QueryParser, QueryParserError
36 from whoosh.query import Phrase, Prefix
38 from whoosh.query import Phrase, Prefix
37 from webhelpers2.html.tools import update_params
38
39
39 from kallithea.lib.auth import LoginRequired
40 from kallithea.lib.auth import LoginRequired
40 from kallithea.lib.base import BaseRepoController, render
41 from kallithea.lib.base import BaseRepoController, render
41 from kallithea.lib.indexers import CHGSETS_SCHEMA, SCHEMA, CHGSET_IDX_NAME, \
42 from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA, WhooshResultWrapper
42 IDX_NAME, WhooshResultWrapper
43 from kallithea.lib.page import Page
43 from kallithea.lib.page import Page
44 from kallithea.lib.utils2 import safe_str, safe_int
44 from kallithea.lib.utils2 import safe_int, safe_str
45 from kallithea.model.repo import RepoModel
45 from kallithea.model.repo import RepoModel
46
46
47
47 log = logging.getLogger(__name__)
48 log = logging.getLogger(__name__)
48
49
49
50
@@ -25,32 +25,32 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import traceback
29 import calendar
28 import calendar
30 import logging
31 import itertools
29 import itertools
30 import logging
31 import traceback
32 from datetime import date, timedelta
32 from time import mktime
33 from time import mktime
33 from datetime import timedelta, date
34
34
35 from tg import tmpl_context as c, request
35 from beaker.cache import cache_region, region_invalidate
36 from tg import request
37 from tg import tmpl_context as c
36 from tg.i18n import ugettext as _
38 from tg.i18n import ugettext as _
37 from webob.exc import HTTPBadRequest
39 from webob.exc import HTTPBadRequest
38
40
39 from beaker.cache import cache_region, region_invalidate
41 from kallithea.config.conf import ALL_EXTS, ALL_READMES, LANGUAGES_EXTENSIONS_MAP
40
42 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
41 from kallithea.lib.vcs.exceptions import ChangesetError, EmptyRepositoryError, \
43 from kallithea.lib.base import BaseRepoController, jsonify, render
42 NodeDoesNotExistError
43 from kallithea.config.conf import ALL_READMES, ALL_EXTS, LANGUAGES_EXTENSIONS_MAP
44 from kallithea.model.db import Statistics, CacheInvalidation, User
45 from kallithea.lib.utils2 import safe_int, safe_str
46 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
47 from kallithea.lib.base import BaseRepoController, render, jsonify
48 from kallithea.lib.vcs.backends.base import EmptyChangeset
49 from kallithea.lib.markup_renderer import MarkupRenderer
50 from kallithea.lib.celerylib.tasks import get_commits_stats
44 from kallithea.lib.celerylib.tasks import get_commits_stats
51 from kallithea.lib.compat import json
45 from kallithea.lib.compat import json
46 from kallithea.lib.markup_renderer import MarkupRenderer
47 from kallithea.lib.page import RepoPage
48 from kallithea.lib.utils2 import safe_int, safe_str
49 from kallithea.lib.vcs.backends.base import EmptyChangeset
50 from kallithea.lib.vcs.exceptions import ChangesetError, EmptyRepositoryError, NodeDoesNotExistError
52 from kallithea.lib.vcs.nodes import FileNode
51 from kallithea.lib.vcs.nodes import FileNode
53 from kallithea.lib.page import RepoPage
52 from kallithea.model.db import CacheInvalidation, Statistics, User
53
54
54
55 log = logging.getLogger(__name__)
55 log = logging.getLogger(__name__)
56
56
@@ -27,10 +27,11 b' Original author and date, and relevant c'
27
27
28 import StringIO
28 import StringIO
29
29
30 from pygments import highlight
31 from pygments.formatters import HtmlFormatter
32
30 from kallithea.lib.vcs.exceptions import VCSError
33 from kallithea.lib.vcs.exceptions import VCSError
31 from kallithea.lib.vcs.nodes import FileNode
34 from kallithea.lib.vcs.nodes import FileNode
32 from pygments.formatters import HtmlFormatter
33 from pygments import highlight
34
35
35
36
36 def annotate_highlight(filenode, annotate_from_changeset_func=None,
37 def annotate_highlight(filenode, annotate_from_changeset_func=None,
@@ -24,36 +24,31 b' Original author and date, and relevant c'
24 :copyright: (c) 2013 RhodeCode GmbH, and others.
24 :copyright: (c) 2013 RhodeCode GmbH, and others.
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27 import os
27 import collections
28 import logging
29 import traceback
30 import hashlib
28 import hashlib
31 import itertools
29 import itertools
32 import collections
30 import logging
33
31 import os
34 from decorator import decorator
32 import traceback
35
33
36 import ipaddr
34 import ipaddr
35 from decorator import decorator
36 from sqlalchemy.orm import joinedload
37 from sqlalchemy.orm.exc import ObjectDeletedError
37 from tg import request, session
38 from tg import request, session
38 from tg.i18n import ugettext as _
39 from tg.i18n import ugettext as _
39 from sqlalchemy.orm.exc import ObjectDeletedError
40 from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPMethodNotAllowed
40 from sqlalchemy.orm import joinedload
41 from webob.exc import HTTPFound, HTTPBadRequest, HTTPForbidden, HTTPMethodNotAllowed
42
41
43 from kallithea import __platform__, is_windows, is_unix
42 from kallithea import __platform__, is_unix, is_windows
44 from kallithea.config.routing import url
43 from kallithea.config.routing import url
44 from kallithea.lib.caching_query import FromCache
45 from kallithea.lib.utils import conditional_cache, get_repo_group_slug, get_repo_slug, get_user_group_slug
46 from kallithea.lib.utils2 import aslist, safe_str, safe_unicode
45 from kallithea.lib.vcs.utils.lazy import LazyProperty
47 from kallithea.lib.vcs.utils.lazy import LazyProperty
48 from kallithea.model.db import (
49 Permission, RepoGroup, Repository, User, UserApiKeys, UserGroup, UserGroupMember, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserGroupToPerm, UserGroupUserGroupToPerm, UserIpMap, UserToPerm)
46 from kallithea.model.meta import Session
50 from kallithea.model.meta import Session
47 from kallithea.model.user import UserModel
51 from kallithea.model.user import UserModel
48 from kallithea.model.db import User, Repository, Permission, \
49 UserToPerm, UserGroupRepoToPerm, UserGroupToPerm, UserGroupMember, \
50 RepoGroup, UserGroupRepoGroupToPerm, UserIpMap, UserGroupUserGroupToPerm, \
51 UserGroup, UserApiKeys
52
53 from kallithea.lib.utils2 import safe_str, safe_unicode, aslist
54 from kallithea.lib.utils import get_repo_slug, get_repo_group_slug, \
55 get_user_group_slug, conditional_cache
56 from kallithea.lib.caching_query import FromCache
57
52
58
53
59 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
@@ -15,18 +15,19 b''
15 Authentication modules
15 Authentication modules
16 """
16 """
17
17
18 import importlib
18 import logging
19 import logging
19 import traceback
20 import traceback
20 import importlib
21
21
22 from kallithea.lib.auth import AuthUser, PasswordGenerator
23 from kallithea.lib.compat import formatted_json, hybrid_property
22 from kallithea.lib.utils2 import str2bool
24 from kallithea.lib.utils2 import str2bool
23 from kallithea.lib.compat import formatted_json, hybrid_property
24 from kallithea.lib.auth import PasswordGenerator, AuthUser
25 from kallithea.model.user import UserModel
26 from kallithea.model.db import Setting, User
25 from kallithea.model.db import Setting, User
27 from kallithea.model.meta import Session
26 from kallithea.model.meta import Session
27 from kallithea.model.user import UserModel
28 from kallithea.model.user_group import UserGroupModel
28 from kallithea.model.user_group import UserGroupModel
29
29
30
30 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
31
32
32
33
@@ -26,10 +26,12 b' Original author and date, and relevant c'
26 """
26 """
27
27
28 import logging
28 import logging
29
29 from kallithea.lib import auth_modules
30 from kallithea.lib import auth_modules
30 from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str
31 from kallithea.lib.compat import hybrid_property
31 from kallithea.lib.compat import hybrid_property
32 from kallithea.model.db import User, Setting
32 from kallithea.lib.utils2 import safe_str, safe_unicode, str2bool
33 from kallithea.model.db import Setting, User
34
33
35
34 log = logging.getLogger(__name__)
36 log = logging.getLogger(__name__)
35
37
@@ -29,10 +29,12 b' Original author and date, and relevant c'
29 import base64
29 import base64
30 import logging
30 import logging
31 import urllib2
31 import urllib2
32
32 from kallithea.lib import auth_modules
33 from kallithea.lib import auth_modules
33 from kallithea.lib.compat import json, formatted_json, hybrid_property
34 from kallithea.lib.compat import formatted_json, hybrid_property, json
34 from kallithea.model.db import User
35 from kallithea.model.db import User
35
36
37
36 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
37
39
38
40
@@ -32,6 +32,7 b' from kallithea.lib import auth_modules'
32 from kallithea.lib.compat import formatted_json, hybrid_property
32 from kallithea.lib.compat import formatted_json, hybrid_property
33 from kallithea.model.db import User
33 from kallithea.model.db import User
34
34
35
35 log = logging.getLogger(__name__)
36 log = logging.getLogger(__name__)
36
37
37
38
@@ -31,12 +31,11 b' import traceback'
31
31
32 from kallithea.lib import auth_modules
32 from kallithea.lib import auth_modules
33 from kallithea.lib.compat import hybrid_property
33 from kallithea.lib.compat import hybrid_property
34 from kallithea.lib.utils2 import safe_unicode, safe_str
34 from kallithea.lib.exceptions import LdapConnectionError, LdapImportError, LdapPasswordError, LdapUsernameError
35 from kallithea.lib.exceptions import (
35 from kallithea.lib.utils2 import safe_str, safe_unicode
36 LdapConnectionError, LdapUsernameError, LdapPasswordError, LdapImportError
37 )
38 from kallithea.model.db import User
36 from kallithea.model.db import User
39
37
38
40 log = logging.getLogger(__name__)
39 log = logging.getLogger(__name__)
41
40
42 try:
41 try:
@@ -23,9 +23,18 b' Original author and date, and relevant c'
23 :author: Alexey Larikov
23 :author: Alexey Larikov
24 """
24 """
25
25
26 import grp
26 import logging
27 import logging
28 import pwd
29 import re
30 import socket
31 import threading
27 import time
32 import time
28
33
34 from kallithea.lib import auth_modules
35 from kallithea.lib.compat import formatted_json, hybrid_property
36
37
29 try:
38 try:
30 from pam import authenticate as pam_authenticate
39 from pam import authenticate as pam_authenticate
31 except ImportError:
40 except ImportError:
@@ -33,14 +42,7 b' except ImportError:'
33 from pam import pam
42 from pam import pam
34 pam_authenticate = pam().authenticate
43 pam_authenticate = pam().authenticate
35
44
36 import pwd
37 import grp
38 import re
39 import socket
40 import threading
41
45
42 from kallithea.lib import auth_modules
43 from kallithea.lib.compat import formatted_json, hybrid_property
44
46
45 log = logging.getLogger(__name__)
47 log = logging.getLogger(__name__)
46
48
@@ -29,36 +29,33 b' Original author and date, and relevant c'
29 """
29 """
30
30
31 import datetime
31 import datetime
32 import decorator
33 import logging
32 import logging
34 import time
33 import time
35 import traceback
34 import traceback
36 import warnings
35 import warnings
37
36
38 import webob.exc
37 import decorator
38 import paste.auth.basic
39 import paste.httpexceptions
39 import paste.httpexceptions
40 import paste.auth.basic
41 import paste.httpheaders
40 import paste.httpheaders
42
41 import webob.exc
43 from tg import config, tmpl_context as c, request, response, session, render_template
42 from tg import TGController, config, render_template, request, response, session
44 from tg import TGController
43 from tg import tmpl_context as c
45 from tg.i18n import ugettext as _
44 from tg.i18n import ugettext as _
46
45
47 from kallithea import __version__, BACKENDS
46 from kallithea import BACKENDS, __version__
48
49 from kallithea.config.routing import url
47 from kallithea.config.routing import url
50 from kallithea.lib.utils2 import str2bool, safe_unicode, AttributeDict, \
51 safe_str, safe_int, set_hook_environment
52 from kallithea.lib import auth_modules
48 from kallithea.lib import auth_modules
53 from kallithea.lib.auth import AuthUser, HasPermissionAnyMiddleware
49 from kallithea.lib.auth import AuthUser, HasPermissionAnyMiddleware
54 from kallithea.lib.compat import json
50 from kallithea.lib.compat import json
51 from kallithea.lib.exceptions import UserCreationError
55 from kallithea.lib.utils import get_repo_slug, is_valid_repo
52 from kallithea.lib.utils import get_repo_slug, is_valid_repo
56 from kallithea.lib.exceptions import UserCreationError
53 from kallithea.lib.utils2 import AttributeDict, safe_int, safe_str, safe_unicode, set_hook_environment, str2bool
57 from kallithea.lib.vcs.exceptions import RepositoryError, EmptyRepositoryError, ChangesetDoesNotExistError
54 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
58 from kallithea.model import meta
55 from kallithea.model import meta
56 from kallithea.model.db import PullRequest, Repository, Setting, User
57 from kallithea.model.scm import ScmModel
59
58
60 from kallithea.model.db import PullRequest, Repository, User, Setting
61 from kallithea.model.scm import ScmModel
62
59
63 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
64
61
@@ -18,10 +18,10 b' Beaker constructs.'
18 """
18 """
19 import beaker
19 import beaker
20 from beaker.exceptions import BeakerException
20 from beaker.exceptions import BeakerException
21
22 from sqlalchemy.orm.interfaces import MapperOption
21 from sqlalchemy.orm.interfaces import MapperOption
23 from sqlalchemy.orm.query import Query
22 from sqlalchemy.orm.query import Query
24 from sqlalchemy.sql import visitors
23 from sqlalchemy.sql import visitors
24
25 from kallithea.lib.utils2 import safe_str
25 from kallithea.lib.utils2 import safe_str
26
26
27
27
@@ -26,19 +26,18 b' Original author and date, and relevant c'
26 """
26 """
27
27
28
28
29 import logging
29 import os
30 import os
30 import logging
31 from hashlib import md5
31
32
33 from decorator import decorator
32 from tg import config
34 from tg import config
33
35
34 from hashlib import md5
36 from kallithea import CELERY_EAGER, CELERY_ON
35 from decorator import decorator
37 from kallithea.lib.pidlock import DaemonLock, LockHeld
36
37 from kallithea import CELERY_ON, CELERY_EAGER
38 from kallithea.lib.utils2 import safe_str
38 from kallithea.lib.utils2 import safe_str
39 from kallithea.lib.pidlock import DaemonLock, LockHeld
39 from kallithea.model import meta
40 from kallithea.model.base import init_model
40 from kallithea.model.base import init_model
41 from kallithea.model import meta
42
41
43
42
44 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
@@ -26,28 +26,26 b' Original author and date, and relevant c'
26 :license: GPLv3, see LICENSE.md for more details.
26 :license: GPLv3, see LICENSE.md for more details.
27 """
27 """
28
28
29 import logging
29 import os
30 import os
30 import traceback
31 import logging
32 import rfc822
31 import rfc822
33
32 import traceback
34 from collections import OrderedDict
33 from collections import OrderedDict
34 from operator import itemgetter
35 from time import mktime
35 from time import mktime
36 from operator import itemgetter
37
36
38 from tg import config
37 from tg import config
39
38
40 from kallithea import CELERY_ON
39 from kallithea import CELERY_ON
41 from kallithea.lib import celerylib
40 from kallithea.lib import celerylib
41 from kallithea.lib.compat import json
42 from kallithea.lib.helpers import person
42 from kallithea.lib.helpers import person
43 from kallithea.lib.hooks import log_create_repository
43 from kallithea.lib.rcmail.smtp_mailer import SmtpMailer
44 from kallithea.lib.rcmail.smtp_mailer import SmtpMailer
44 from kallithea.lib.utils import action_logger
45 from kallithea.lib.utils import action_logger
45 from kallithea.lib.utils2 import str2bool
46 from kallithea.lib.utils2 import str2bool
46 from kallithea.lib.vcs.utils import author_email
47 from kallithea.lib.vcs.utils import author_email
47 from kallithea.lib.compat import json
48 from kallithea.model.db import RepoGroup, Repository, Statistics, User
48 from kallithea.lib.hooks import log_create_repository
49
50 from kallithea.model.db import Statistics, RepoGroup, Repository, User
51
49
52
50
53 __all__ = ['whoosh_index', 'get_commits_stats', 'send_email']
51 __all__ = ['whoosh_index', 'get_commits_stats', 'send_email']
@@ -17,8 +17,11 b' mandatory settings.'
17 import os
17 import os
18 import warnings
18 import warnings
19
19
20 import celery
21 import celery.result as result
20 import tg
22 import tg
21 import celery
23 from celery.bin import worker
24 from celery.task import task
22
25
23
26
24 def celery_config(config):
27 def celery_config(config):
@@ -56,7 +59,3 b' def celery_config(config):'
56 # Create celery app from the TurboGears configuration file
59 # Create celery app from the TurboGears configuration file
57 app = celery.Celery()
60 app = celery.Celery()
58 app.config_from_object(celery_config(tg.config))
61 app.config_from_object(celery_config(tg.config))
59
60 import celery.result as result
61 from celery.task import task
62 from celery.bin import worker
@@ -14,6 +14,7 b''
14
14
15 import logging
15 import logging
16
16
17
17 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
18 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
18
19
19 # Sequences
20 # Sequences
@@ -27,29 +27,31 b' Original author and date, and relevant c'
27 """
27 """
28
28
29
29
30 import sys
30 import functools
31 import os
31 import os
32 import functools
32 import sys
33
34 #==============================================================================
35 # Hybrid property/method
36 #==============================================================================
37 from sqlalchemy.ext.hybrid import hybrid_property
38 #==============================================================================
39 # OrderedSet
40 #==============================================================================
41 from sqlalchemy.util import OrderedSet
33
42
34 #==============================================================================
43 #==============================================================================
35 # json
44 # json
36 #==============================================================================
45 #==============================================================================
37 from kallithea.lib.ext_json import json
46 from kallithea.lib.ext_json import json
38
47
48
39 # alias for formatted json
49 # alias for formatted json
40 formatted_json = functools.partial(json.dumps, indent=4, sort_keys=True)
50 formatted_json = functools.partial(json.dumps, indent=4, sort_keys=True)
41
51
42
52
43 #==============================================================================
44 # OrderedSet
45 #==============================================================================
46 from sqlalchemy.util import OrderedSet
47
53
48
54
49 #==============================================================================
50 # Hybrid property/method
51 #==============================================================================
52 from sqlalchemy.ext.hybrid import hybrid_property
53
55
54
56
55 #==============================================================================
57 #==============================================================================
@@ -26,29 +26,26 b' Original author and date, and relevant c'
26 :license: GPLv3, see LICENSE.md for more details.
26 :license: GPLv3, see LICENSE.md for more details.
27 """
27 """
28
28
29 import logging
29 import os
30 import os
30 import sys
31 import sys
31 import time
32 import time
32 import uuid
33 import uuid
33 import logging
34 import sqlalchemy
35 from os.path import dirname
34 from os.path import dirname
36
35
36 import alembic.command
37 import alembic.config
37 import alembic.config
38 import alembic.command
38 import sqlalchemy
39 from sqlalchemy.engine import create_engine
39
40
40 from kallithea.model.user import UserModel
41 from kallithea.model.base import init_model
41 from kallithea.model.base import init_model
42 from kallithea.model.db import User, Permission, Ui, \
42 from kallithea.model.db import CacheInvalidation, Permission, RepoGroup, Repository, Setting, Ui, User, UserRepoGroupToPerm, UserToPerm
43 Setting, UserToPerm, RepoGroup, \
43 #from kallithea.model import meta
44 UserRepoGroupToPerm, CacheInvalidation, Repository
44 from kallithea.model.meta import Base, Session
45
45 from kallithea.model.permission import PermissionModel
46 from sqlalchemy.engine import create_engine
46 from kallithea.model.repo import RepoModel
47 from kallithea.model.repo_group import RepoGroupModel
47 from kallithea.model.repo_group import RepoGroupModel
48 #from kallithea.model import meta
48 from kallithea.model.user import UserModel
49 from kallithea.model.meta import Session, Base
50 from kallithea.model.repo import RepoModel
51 from kallithea.model.permission import PermissionModel
52
49
53
50
54 log = logging.getLogger(__name__)
51 log = logging.getLogger(__name__)
@@ -25,17 +25,18 b' Original author and date, and relevant c'
25 :copyright: (c) 2013 RhodeCode GmbH, and others.
25 :copyright: (c) 2013 RhodeCode GmbH, and others.
26 :license: GPLv3, see LICENSE.md for more details.
26 :license: GPLv3, see LICENSE.md for more details.
27 """
27 """
28 import re
29 import difflib
28 import difflib
30 import logging
29 import logging
30 import re
31
31
32 from tg.i18n import ugettext as _
32 from tg.i18n import ugettext as _
33
33
34 from kallithea.lib import helpers as h
34 from kallithea.lib import helpers as h
35 from kallithea.lib.utils2 import safe_unicode
36 from kallithea.lib.vcs.backends.base import EmptyChangeset
35 from kallithea.lib.vcs.exceptions import VCSError
37 from kallithea.lib.vcs.exceptions import VCSError
36 from kallithea.lib.vcs.nodes import FileNode, SubModuleNode
38 from kallithea.lib.vcs.nodes import FileNode, SubModuleNode
37 from kallithea.lib.vcs.backends.base import EmptyChangeset
39
38 from kallithea.lib.utils2 import safe_unicode
39
40
40 log = logging.getLogger(__name__)
41 log = logging.getLogger(__name__)
41
42
@@ -5,9 +5,10 b' json.org does not specify how date time '
5 """
5 """
6
6
7 import datetime
7 import datetime
8 import decimal
8 import functools
9 import functools
9 import decimal
10 import json # is re-exported after monkey patching
10 import json # is re-exported after monkey patching
11
11
12
12 __all__ = ['json']
13 __all__ = ['json']
13
14
@@ -19,35 +19,45 b' available to Controllers. This module is'
19 """
19 """
20 import hashlib
20 import hashlib
21 import json
21 import json
22 import StringIO
23 import logging
22 import logging
23 import random
24 import re
24 import re
25 import urlparse
25 import StringIO
26 import textwrap
26 import textwrap
27 import random
27 import urlparse
28
28
29 from beaker.cache import cache_region
29 from beaker.cache import cache_region
30 from pygments import highlight as code_highlight
30 from pygments.formatters.html import HtmlFormatter
31 from pygments.formatters.html import HtmlFormatter
31 from pygments import highlight as code_highlight
32 from tg.i18n import ugettext as _
32 from tg.i18n import ugettext as _
33
33 from webhelpers2.html import HTML, escape, literal
34 from webhelpers2.html import literal, HTML, escape
34 from webhelpers2.html.tags import NotGiven, Option, Options, _input, _make_safe_id_component, checkbox, end_form
35 from webhelpers2.html.tags import checkbox, end_form, hidden, link_to, \
35 from webhelpers2.html.tags import form as insecure_form
36 select as webhelpers2_select, Option, Options, \
36 from webhelpers2.html.tags import hidden, link_to, password, radio
37 submit, text, password, textarea, radio, form as insecure_form
37 from webhelpers2.html.tags import select as webhelpers2_select
38 from webhelpers2.html.tags import submit, text, textarea
38 from webhelpers2.number import format_byte_size
39 from webhelpers2.number import format_byte_size
40 from webhelpers2.text import chop_at, truncate, wrap_paragraphs
39 from webhelpers.pylonslib import Flash as _Flash
41 from webhelpers.pylonslib import Flash as _Flash
40 from webhelpers2.text import chop_at, truncate, wrap_paragraphs
41 from webhelpers2.html.tags import _input, NotGiven, _make_safe_id_component
42
42
43 from kallithea.config.routing import url
43 from kallithea.config.routing import url
44 from kallithea.lib.annotate import annotate_highlight
44 from kallithea.lib.annotate import annotate_highlight
45 #==============================================================================
46 # PERMS
47 #==============================================================================
48 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoPermissionLevel
49 from kallithea.lib.markup_renderer import url_re
45 from kallithea.lib.pygmentsutils import get_custom_lexer
50 from kallithea.lib.pygmentsutils import get_custom_lexer
46 from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str, \
51 from kallithea.lib.utils2 import MENTIONS_REGEX, AttributeDict
47 time_to_datetime, AttributeDict, safe_int, MENTIONS_REGEX
52 from kallithea.lib.utils2 import age as _age
48 from kallithea.lib.markup_renderer import url_re
53 from kallithea.lib.utils2 import credentials_filter, safe_int, safe_str, safe_unicode, str2bool, time_to_datetime
54 from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
49 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
55 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
50 from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
56 #==============================================================================
57 # SCM FILTERS available via h.
58 #==============================================================================
59 from kallithea.lib.vcs.utils import author_email, author_name
60
51
61
52 log = logging.getLogger(__name__)
62 log = logging.getLogger(__name__)
53
63
@@ -454,11 +464,6 b' class Flash(_Flash):'
454
464
455 flash = Flash()
465 flash = Flash()
456
466
457 #==============================================================================
458 # SCM FILTERS available via h.
459 #==============================================================================
460 from kallithea.lib.vcs.utils import author_name, author_email
461 from kallithea.lib.utils2 import credentials_filter, age as _age
462
467
463 age = lambda x, y=False: _age(x, y)
468 age = lambda x, y=False: _age(x, y)
464 capitalize = lambda x: x.capitalize()
469 capitalize = lambda x: x.capitalize()
@@ -843,11 +848,6 b' def action_parser(user_log, feed=False, '
843
848
844
849
845
850
846 #==============================================================================
847 # PERMS
848 #==============================================================================
849 from kallithea.lib.auth import HasPermissionAny, \
850 HasRepoPermissionLevel, HasRepoGroupPermissionLevel
851
851
852
852
853 #==============================================================================
853 #==============================================================================
@@ -25,18 +25,17 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import binascii
28 import os
29 import os
29 import time
30 import time
30 import binascii
31
31
32 from kallithea.lib.vcs.utils.hgcompat import nullrev, revrange
33 from kallithea.lib import helpers as h
32 from kallithea.lib import helpers as h
34 from kallithea.lib.utils import action_logger
33 from kallithea.lib.exceptions import UserCreationError
34 from kallithea.lib.utils import action_logger, make_ui, setup_cache_regions
35 from kallithea.lib.utils2 import get_hook_environment, safe_str, safe_unicode
35 from kallithea.lib.vcs.backends.base import EmptyChangeset
36 from kallithea.lib.vcs.backends.base import EmptyChangeset
36 from kallithea.lib.exceptions import UserCreationError
37 from kallithea.lib.vcs.utils.hgcompat import nullrev, revrange
37 from kallithea.lib.utils import make_ui, setup_cache_regions
38 from kallithea.model.db import Repository, Ui, User
38 from kallithea.lib.utils2 import safe_str, safe_unicode, get_hook_environment
39 from kallithea.model.db import Repository, User, Ui
40
39
41
40
42 def _get_scm_size(alias, root_path):
41 def _get_scm_size(alias, root_path):
@@ -25,19 +25,23 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import logging
28 import os
29 import os
29 import sys
30 import sys
30 import logging
31 from os.path import dirname
31 from os.path import dirname
32
32
33 from whoosh.analysis import IDTokenizer, LowercaseFilter, RegexTokenizer
34 from whoosh.fields import BOOLEAN, DATETIME, ID, NUMERIC, STORED, TEXT, FieldType, Schema
35 from whoosh.formats import Characters
36 from whoosh.highlight import ContextFragmenter, HtmlFormatter
37 from whoosh.highlight import highlight as whoosh_highlight
38
39 from kallithea.lib.utils2 import LazyProperty
40
41
33 # Add location of top level folder to sys.path
42 # Add location of top level folder to sys.path
34 sys.path.append(dirname(dirname(dirname(os.path.realpath(__file__)))))
43 sys.path.append(dirname(dirname(dirname(os.path.realpath(__file__)))))
35
44
36 from whoosh.analysis import RegexTokenizer, LowercaseFilter, IDTokenizer
37 from whoosh.fields import TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME
38 from whoosh.formats import Characters
39 from whoosh.highlight import highlight as whoosh_highlight, HtmlFormatter, ContextFragmenter
40 from kallithea.lib.utils2 import LazyProperty
41
45
42 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
43
47
@@ -26,33 +26,32 b' Original author and date, and relevant c'
26 """
26 """
27
27
28
28
29 import logging
29 import os
30 import os
30 import sys
31 import sys
31 import logging
32 import traceback
32 import traceback
33
33 from os.path import dirname
34 from shutil import rmtree
34 from shutil import rmtree
35 from time import mktime
35 from time import mktime
36
36
37 from os.path import dirname
37 from whoosh.index import create_in, exists_in, open_dir
38 from whoosh.qparser import QueryParser
39 from whoosh.query import *
40
41 from kallithea.config.conf import INDEX_EXTENSIONS, INDEX_FILENAMES
42 from kallithea.lib.indexers import CHGSET_IDX_NAME, CHGSETS_SCHEMA, IDX_NAME, SCHEMA
43 from kallithea.lib.utils2 import safe_str, safe_unicode
44 from kallithea.lib.vcs.exceptions import ChangesetError, NodeDoesNotExistError, RepositoryError
45 from kallithea.model.db import Repository
46 from kallithea.model.scm import ScmModel
47
38
48
39 # Add location of top level folder to sys.path
49 # Add location of top level folder to sys.path
40 project_path = dirname(dirname(dirname(dirname(os.path.realpath(__file__)))))
50 project_path = dirname(dirname(dirname(dirname(os.path.realpath(__file__)))))
41 sys.path.append(project_path)
51 sys.path.append(project_path)
42
52
43 from kallithea.config.conf import INDEX_EXTENSIONS, INDEX_FILENAMES
44 from kallithea.model.scm import ScmModel
45 from kallithea.model.db import Repository
46 from kallithea.lib.utils2 import safe_unicode, safe_str
47 from kallithea.lib.indexers import SCHEMA, IDX_NAME, CHGSETS_SCHEMA, \
48 CHGSET_IDX_NAME
49
53
50 from kallithea.lib.vcs.exceptions import ChangesetError, RepositoryError, \
51 NodeDoesNotExistError
52
54
53 from whoosh.index import create_in, open_dir, exists_in
54 from whoosh.query import *
55 from whoosh.qparser import QueryParser
56
55
57 log = logging.getLogger('whoosh_indexer')
56 log = logging.getLogger('whoosh_indexer')
58
57
@@ -21,8 +21,8 b' other custom values.'
21 """
21 """
22
22
23 import logging
23 import logging
24 import os
24 import re
25 import re
25 import os
26
26
27 import mako.template
27 import mako.template
28
28
@@ -15,6 +15,7 b' import logging'
15 import os
15 import os
16 import sys
16 import sys
17
17
18
18 log = logging.getLogger(__name__)
19 log = logging.getLogger(__name__)
19
20
20 def current_locale_is_valid():
21 def current_locale_is_valid():
@@ -26,14 +26,15 b' Original author and date, and relevant c'
26 """
26 """
27
27
28
28
29 import logging
29 import re
30 import re
30 import logging
31 import traceback
31 import traceback
32
32
33 import bleach
33 import markdown as markdown_mod
34 import markdown as markdown_mod
34 import bleach
35
35
36 from kallithea.lib.utils2 import safe_unicode, MENTIONS_REGEX
36 from kallithea.lib.utils2 import MENTIONS_REGEX, safe_unicode
37
37
38
38 log = logging.getLogger(__name__)
39 log = logging.getLogger(__name__)
39
40
@@ -20,7 +20,7 b' middleware to handle permanent repo URLs'
20 """
20 """
21
21
22
22
23 from kallithea.lib.utils import safe_str, fix_repo_id_name
23 from kallithea.lib.utils import fix_repo_id_name, safe_str
24
24
25
25
26 class PermanentRepoUrl(object):
26 class PermanentRepoUrl(object):
@@ -25,16 +25,17 b' Copyright (c) 2012 Marcin Kuzminski <mar'
25 This file was forked by the Kallithea project in July 2014.
25 This file was forked by the Kallithea project in July 2014.
26 """
26 """
27
27
28 import logging
28 import os
29 import os
29 import socket
30 import socket
30 import logging
31 import traceback
31 import traceback
32
32
33 from webob import Request, Response, exc
33 from webob import Request, Response, exc
34
34
35 import kallithea
35 import kallithea
36 from kallithea.lib.utils2 import safe_unicode
36 from kallithea.lib.vcs import subprocessio
37 from kallithea.lib.vcs import subprocessio
37 from kallithea.lib.utils2 import safe_unicode
38
38
39
39 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
40
41
@@ -23,8 +23,8 b' class to automagically use secure cookie'
23 Original Beaker SessionMiddleware class written by Ben Bangert
23 Original Beaker SessionMiddleware class written by Ben Bangert
24 """
24 """
25
25
26 from beaker.middleware import SessionMiddleware
26 from beaker.session import SessionObject
27 from beaker.session import SessionObject
27 from beaker.middleware import SessionMiddleware
28
28
29
29
30 class SecureSessionMiddleware(SessionMiddleware):
30 class SecureSessionMiddleware(SessionMiddleware):
@@ -28,15 +28,16 b' Original author and date, and relevant c'
28 """
28 """
29
29
30
30
31 import logging
31 import re
32 import re
32 import logging
33
33
34 from kallithea.model.db import Ui, Repository
35 from kallithea.lib.utils2 import safe_unicode
36 from kallithea.lib.base import BaseVCSController
34 from kallithea.lib.base import BaseVCSController
37 from kallithea.lib.utils import make_ui
38 from kallithea.lib.hooks import log_pull_action
35 from kallithea.lib.hooks import log_pull_action
39 from kallithea.lib.middleware.pygrack import make_wsgi_app
36 from kallithea.lib.middleware.pygrack import make_wsgi_app
37 from kallithea.lib.utils import make_ui
38 from kallithea.lib.utils2 import safe_unicode
39 from kallithea.model.db import Repository, Ui
40
40
41
41 log = logging.getLogger(__name__)
42 log = logging.getLogger(__name__)
42
43
@@ -28,15 +28,16 b' Original author and date, and relevant c'
28 """
28 """
29
29
30
30
31 import logging
31 import os
32 import os
32 import logging
33 import urllib
33 import urllib
34
34
35 from kallithea.lib.utils2 import safe_str, safe_unicode
36 from kallithea.lib.base import BaseVCSController
35 from kallithea.lib.base import BaseVCSController
37 from kallithea.lib.utils import make_ui
36 from kallithea.lib.utils import make_ui
37 from kallithea.lib.utils2 import safe_str, safe_unicode
38 from kallithea.lib.vcs.utils.hgcompat import hgweb_mod
38 from kallithea.lib.vcs.utils.hgcompat import hgweb_mod
39
39
40
40 log = logging.getLogger(__name__)
41 log = logging.getLogger(__name__)
41
42
42
43
@@ -25,9 +25,10 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import logging
28 import time
29 import time
29 import logging
30
30 from kallithea.lib.base import _get_ip_addr, _get_access_path
31 from kallithea.lib.base import _get_access_path, _get_ip_addr
31 from kallithea.lib.utils2 import safe_unicode
32 from kallithea.lib.utils2 import safe_unicode
32
33
33
34
@@ -17,9 +17,12 b' Custom paging classes'
17 import logging
17 import logging
18 import math
18 import math
19 import re
19 import re
20
21 from webhelpers2.html import HTML, literal
22 from webhelpers.paginate import Page as _Page
23
20 from kallithea.config.routing import url
24 from kallithea.config.routing import url
21 from webhelpers2.html import literal, HTML
25
22 from webhelpers.paginate import Page as _Page
23
26
24 log = logging.getLogger(__name__)
27 log = logging.getLogger(__name__)
25
28
@@ -12,9 +12,8 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import errno
15 import os
16 import os
16 import errno
17
18 from multiprocessing.util import Finalize
17 from multiprocessing.util import Finalize
19
18
20 from kallithea.lib.compat import kill
19 from kallithea.lib.compat import kill
@@ -1,8 +1,6 b''
1 from kallithea.lib.rcmail.exceptions import BadHeaders, InvalidMessage
1 from kallithea.lib.rcmail.response import MailResponse
2 from kallithea.lib.rcmail.response import MailResponse
2
3
3 from kallithea.lib.rcmail.exceptions import BadHeaders
4 from kallithea.lib.rcmail.exceptions import InvalidMessage
5
6
4
7 class Attachment(object):
5 class Attachment(object):
8 """
6 """
@@ -33,13 +33,14 b''
33 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 # POSSIBILITY OF SUCH DAMAGE.
34 # POSSIBILITY OF SUCH DAMAGE.
35
35
36 import mimetypes
36 import os
37 import os
37 import mimetypes
38 import string
38 import string
39 from email import encoders
39 from email import encoders
40 from email.charset import Charset
40 from email.charset import Charset
41 from email.mime.base import MIMEBase
41 from email.utils import parseaddr
42 from email.utils import parseaddr
42 from email.mime.base import MIMEBase
43
43
44
44 ADDRESS_HEADERS_WHITELIST = ['From', 'To', 'Delivered-To', 'Cc']
45 ADDRESS_HEADERS_WHITELIST = ['From', 'To', 'Delivered-To', 'Cc']
45 DEFAULT_ENCODING = "utf-8"
46 DEFAULT_ENCODING = "utf-8"
@@ -25,11 +25,11 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import time
29 import logging
28 import logging
30 import smtplib
29 import smtplib
30 import time
31 from email.utils import formatdate
31 from ssl import SSLError
32 from ssl import SSLError
32 from email.utils import formatdate
33
33
34 from kallithea.lib.rcmail.message import Message
34 from kallithea.lib.rcmail.message import Message
35 from kallithea.lib.rcmail.utils import DNS_NAME
35 from kallithea.lib.rcmail.utils import DNS_NAME
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 import json
2 import urllib
3 import urllib
3 import urllib2
4 import urllib2
4 import json
5
5
6
6
7 class RecaptchaResponse(object):
7 class RecaptchaResponse(object):
@@ -21,12 +21,13 b''
21 # You should have received a copy of the GNU General Public License
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
24 import binascii
24 import logging
25 import logging
25 import binascii
26 import re
26 import re
27
27
28 from tg.i18n import ugettext as _
28 from tg.i18n import ugettext as _
29
29
30
30 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
31
32
32
33
@@ -12,10 +12,12 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import logging
15 import time
16 import time
16 import logging
17
17 from sqlalchemy.interfaces import ConnectionProxy
18 from sqlalchemy.interfaces import ConnectionProxy
18
19
20
19 log = logging.getLogger('timerproxy')
21 log = logging.getLogger('timerproxy')
20
22
21 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
23 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
@@ -25,28 +25,27 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import datetime
29 import logging
28 import os
30 import os
29 import re
31 import re
30 import logging
31 import datetime
32 import traceback
32 import traceback
33
33 import beaker
34 import beaker
34
35 from beaker.cache import _cache_decorate
35 from tg import request, response
36 from tg import request, response
36 from tg.i18n import ugettext as _
37 from tg.i18n import ugettext as _
37 from beaker.cache import _cache_decorate
38
39 from kallithea.lib.vcs.utils.hgcompat import ui, config
40 from kallithea.lib.vcs.utils.helpers import get_scm
41 from kallithea.lib.vcs.exceptions import VCSError
42
38
43 from kallithea.lib.exceptions import HgsubversionImportError
39 from kallithea.lib.exceptions import HgsubversionImportError
40 from kallithea.lib.utils2 import get_current_authuser, safe_str, safe_unicode
41 from kallithea.lib.vcs.exceptions import VCSError
42 from kallithea.lib.vcs.utils.fakemod import create_module
43 from kallithea.lib.vcs.utils.helpers import get_scm
44 from kallithea.lib.vcs.utils.hgcompat import config, ui
44 from kallithea.model import meta
45 from kallithea.model import meta
45 from kallithea.model.db import Repository, User, Ui, \
46 from kallithea.model.db import RepoGroup, Repository, Setting, Ui, User, UserGroup, UserLog
46 UserLog, RepoGroup, Setting, UserGroup
47 from kallithea.model.repo_group import RepoGroupModel
47 from kallithea.model.repo_group import RepoGroupModel
48 from kallithea.lib.utils2 import safe_str, safe_unicode, get_current_authuser
48
49 from kallithea.lib.vcs.utils.fakemod import create_module
50
49
51 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
52
51
@@ -28,23 +28,24 b' Original author and date, and relevant c'
28 """
28 """
29
29
30
30
31 import binascii
32 import datetime
31 import os
33 import os
34 import pwd
32 import re
35 import re
33 import sys
36 import sys
34 import time
37 import time
38 import urllib
35 import uuid
39 import uuid
36 import datetime
37 import urllib
38 import binascii
39 import pwd
40
40
41 import urlobject
41 import webob
42 import webob
42 import urlobject
43 from tg.i18n import ugettext as _
44 from tg.i18n import ungettext
43 from webhelpers2.text import collapse, remove_formatting, strip_tags
45 from webhelpers2.text import collapse, remove_formatting, strip_tags
44
46
45 from tg.i18n import ugettext as _, ungettext
47 from kallithea.lib.compat import json
46 from kallithea.lib.vcs.utils.lazy import LazyProperty
48 from kallithea.lib.vcs.utils.lazy import LazyProperty
47 from kallithea.lib.compat import json
48
49
49
50
50 def str2bool(_str):
51 def str2bool(_str):
@@ -20,8 +20,9 b" VERSION = (0, 5, 0, 'dev')"
20 ]
20 ]
21
21
22 import sys
22 import sys
23 from kallithea.lib.vcs.backends import get_repo, get_backend
23
24 from kallithea.lib.vcs.exceptions import VCSError, RepositoryError, ChangesetError
24 from kallithea.lib.vcs.backends import get_backend, get_repo
25 from kallithea.lib.vcs.exceptions import ChangesetError, RepositoryError, VCSError
25
26
26
27
27 def get_version():
28 def get_version():
@@ -10,11 +10,12 b''
10 """
10 """
11 import os
11 import os
12 from pprint import pformat
12 from pprint import pformat
13
13 from kallithea.lib.vcs.conf import settings
14 from kallithea.lib.vcs.conf import settings
14 from kallithea.lib.vcs.exceptions import VCSError
15 from kallithea.lib.vcs.exceptions import VCSError
15 from kallithea.lib.vcs.utils.helpers import get_scm
16 from kallithea.lib.vcs.utils.helpers import get_scm
17 from kallithea.lib.vcs.utils.imports import import_class
16 from kallithea.lib.vcs.utils.paths import abspath
18 from kallithea.lib.vcs.utils.paths import abspath
17 from kallithea.lib.vcs.utils.imports import import_class
18
19
19
20
20 def get_repo(path=None, alias=None, create=False):
21 def get_repo(path=None, alias=None, create=False):
@@ -12,16 +12,12 b''
12 import datetime
12 import datetime
13 import itertools
13 import itertools
14
14
15 from kallithea.lib.vcs.utils import author_name, author_email, safe_unicode
15 from kallithea.lib.vcs.conf import settings
16 from kallithea.lib.vcs.utils.lazy import LazyProperty
16 from kallithea.lib.vcs.exceptions import (
17 ChangesetError, EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError, RepositoryError)
18 from kallithea.lib.vcs.utils import author_email, author_name, safe_unicode
17 from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
19 from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
18 from kallithea.lib.vcs.conf import settings
20 from kallithea.lib.vcs.utils.lazy import LazyProperty
19
20 from kallithea.lib.vcs.exceptions import (
21 ChangesetError, EmptyRepositoryError, NodeAlreadyAddedError,
22 NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError,
23 NodeDoesNotExistError, NodeNotChangedError, RepositoryError
24 )
25
21
26
22
27 class BaseRepository(object):
23 class BaseRepository(object):
@@ -1,6 +1,6 b''
1 from .repository import GitRepository
2 from .changeset import GitChangeset
1 from .changeset import GitChangeset
3 from .inmemory import GitInMemoryChangeset
2 from .inmemory import GitInMemoryChangeset
3 from .repository import GitRepository
4 from .workdir import GitWorkdir
4 from .workdir import GitWorkdir
5
5
6
6
@@ -1,23 +1,17 b''
1 import re
1 import re
2 from io import BytesIO
2 from itertools import chain
3 from itertools import chain
4 from subprocess import PIPE, Popen
5
3 from dulwich import objects
6 from dulwich import objects
4 from dulwich.config import ConfigFile
7 from dulwich.config import ConfigFile
5 from subprocess import Popen, PIPE
6 from io import BytesIO
7
8
8 from kallithea.lib.vcs.conf import settings
9 from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
9 from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
10 from kallithea.lib.vcs.exceptions import (
10 from kallithea.lib.vcs.conf import settings
11 RepositoryError, ChangesetError, NodeDoesNotExistError, VCSError,
11 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError, NodeDoesNotExistError, RepositoryError, VCSError
12 ChangesetDoesNotExistError, ImproperArchiveTypeError
13 )
14 from kallithea.lib.vcs.nodes import (
12 from kallithea.lib.vcs.nodes import (
15 FileNode, DirNode, NodeKind, RootNode, SubModuleNode,
13 AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode, NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode)
16 ChangedFileNodesGenerator, AddedFileNodesGenerator, RemovedFileNodesGenerator
14 from kallithea.lib.vcs.utils import date_fromtimestamp, safe_int, safe_str, safe_unicode
17 )
18 from kallithea.lib.vcs.utils import (
19 safe_unicode, safe_str, safe_int, date_fromtimestamp
20 )
21 from kallithea.lib.vcs.utils.lazy import LazyProperty
15 from kallithea.lib.vcs.utils.lazy import LazyProperty
22
16
23
17
@@ -1,8 +1,10 b''
1 import time
2 import datetime
1 import datetime
3 import posixpath
2 import posixpath
4 import stat
3 import stat
4 import time
5
5 from dulwich import objects
6 from dulwich import objects
7
6 from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
8 from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
7 from kallithea.lib.vcs.exceptions import RepositoryError
9 from kallithea.lib.vcs.exceptions import RepositoryError
8 from kallithea.lib.vcs.utils import safe_str
10 from kallithea.lib.vcs.utils import safe_str
@@ -9,40 +9,35 b''
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
10 """
10 """
11
11
12 import errno
13 import logging
12 import os
14 import os
15 import posixpath
13 import re
16 import re
14 import time
17 import time
15 import errno
16 import urllib
18 import urllib
17 import urllib2
19 import urllib2
18 import logging
19 import posixpath
20 from collections import OrderedDict
20 from collections import OrderedDict
21
21
22 from dulwich.config import ConfigFile
22 from dulwich.objects import Tag
23 from dulwich.objects import Tag
23 from dulwich.repo import Repo, NotGitRepository
24 from dulwich.repo import NotGitRepository, Repo
24 from dulwich.config import ConfigFile
25
25
26 from kallithea.lib.vcs import subprocessio
26 from kallithea.lib.vcs import subprocessio
27 from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
27 from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
28 from kallithea.lib.vcs.conf import settings
28 from kallithea.lib.vcs.conf import settings
29
30 from kallithea.lib.vcs.exceptions import (
29 from kallithea.lib.vcs.exceptions import (
31 BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError,
30 BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError, TagDoesNotExistError)
32 RepositoryError, TagAlreadyExistError, TagDoesNotExistError
31 from kallithea.lib.vcs.utils import date_fromtimestamp, makedate, safe_str, safe_unicode
33 )
32 from kallithea.lib.vcs.utils.hgcompat import hg_url, httpbasicauthhandler, httpdigestauthhandler
34 from kallithea.lib.vcs.utils import safe_str, safe_unicode, makedate, date_fromtimestamp
35 from kallithea.lib.vcs.utils.lazy import LazyProperty
33 from kallithea.lib.vcs.utils.lazy import LazyProperty
36 from kallithea.lib.vcs.utils.paths import abspath, get_user_home
34 from kallithea.lib.vcs.utils.paths import abspath, get_user_home
37
35
38 from kallithea.lib.vcs.utils.hgcompat import (
39 hg_url, httpbasicauthhandler, httpdigestauthhandler
40 )
41
42 from .changeset import GitChangeset
36 from .changeset import GitChangeset
43 from .inmemory import GitInMemoryChangeset
37 from .inmemory import GitInMemoryChangeset
44 from .workdir import GitWorkdir
38 from .workdir import GitWorkdir
45
39
40
46 SHA_PATTERN = re.compile(r'^([0-9a-fA-F]{12}|[0-9a-fA-F]{40})$')
41 SHA_PATTERN = re.compile(r'^([0-9a-fA-F]{12}|[0-9a-fA-F]{40})$')
47
42
48 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
@@ -12,12 +12,12 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import logging
15 import os
16 import os
16 import logging
17
17
18 from kallithea.lib.hooks import log_pull_action
18 from kallithea.lib.hooks import log_pull_action
19 from kallithea.lib.utils import make_ui
19 from kallithea.lib.utils import make_ui
20 from kallithea.lib.utils2 import safe_unicode, safe_str
20 from kallithea.lib.utils2 import safe_str, safe_unicode
21 from kallithea.lib.vcs.backends.ssh import BaseSshHandler
21 from kallithea.lib.vcs.backends.ssh import BaseSshHandler
22
22
23
23
@@ -1,7 +1,7 b''
1 import re
1 import re
2
2 from kallithea.lib.vcs.backends.base import BaseWorkdir
3 from kallithea.lib.vcs.backends.base import BaseWorkdir
3 from kallithea.lib.vcs.exceptions import RepositoryError
4 from kallithea.lib.vcs.exceptions import BranchDoesNotExistError, RepositoryError
4 from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
5
5
6
6
7 class GitWorkdir(BaseWorkdir):
7 class GitWorkdir(BaseWorkdir):
@@ -9,9 +9,9 b''
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
10 """
10 """
11
11
12 from .repository import MercurialRepository
13 from .changeset import MercurialChangeset
12 from .changeset import MercurialChangeset
14 from .inmemory import MercurialInMemoryChangeset
13 from .inmemory import MercurialInMemoryChangeset
14 from .repository import MercurialRepository
15 from .workdir import MercurialWorkdir
15 from .workdir import MercurialWorkdir
16
16
17
17
@@ -1,22 +1,17 b''
1 import os
1 import os
2 import posixpath
2 import posixpath
3
3
4 from kallithea.lib.vcs.conf import settings
4 from mercurial import obsolete
5
5 from kallithea.lib.vcs.backends.base import BaseChangeset
6 from kallithea.lib.vcs.backends.base import BaseChangeset
6 from kallithea.lib.vcs.exceptions import (
7 from kallithea.lib.vcs.conf import settings
7 ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError,
8 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, ChangesetError, ImproperArchiveTypeError, NodeDoesNotExistError, VCSError
8 NodeDoesNotExistError, VCSError
9 )
10 from kallithea.lib.vcs.nodes import (
9 from kallithea.lib.vcs.nodes import (
11 AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode,
10 AddedFileNodesGenerator, ChangedFileNodesGenerator, DirNode, FileNode, NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode)
12 NodeKind, RemovedFileNodesGenerator, RootNode, SubModuleNode
11 from kallithea.lib.vcs.utils import date_fromtimestamp, safe_str, safe_unicode
13 )
12 from kallithea.lib.vcs.utils.hgcompat import archival, hex, obsutil
14 from kallithea.lib.vcs.utils import safe_str, safe_unicode, date_fromtimestamp
15 from kallithea.lib.vcs.utils.lazy import LazyProperty
13 from kallithea.lib.vcs.utils.lazy import LazyProperty
16 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
14 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
17 from kallithea.lib.vcs.utils.hgcompat import archival, hex, obsutil
18
19 from mercurial import obsolete
20
15
21
16
22 class MercurialChangeset(BaseChangeset):
17 class MercurialChangeset(BaseChangeset):
@@ -3,8 +3,7 b' import errno'
3
3
4 from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
4 from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
5 from kallithea.lib.vcs.exceptions import RepositoryError
5 from kallithea.lib.vcs.exceptions import RepositoryError
6
6 from kallithea.lib.vcs.utils.hgcompat import hex, memctx, memfilectx, tolocal
7 from kallithea.lib.vcs.utils.hgcompat import memfilectx, memctx, hex, tolocal
8
7
9
8
10 class MercurialInMemoryChangeset(BaseInMemoryChangeset):
9 class MercurialInMemoryChangeset(BaseInMemoryChangeset):
@@ -9,34 +9,28 b''
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
10 """
10 """
11
11
12 import datetime
13 import logging
12 import os
14 import os
13 import time
15 import time
14 import urllib
16 import urllib
15 import urllib2
17 import urllib2
16 import logging
17 import datetime
18 from collections import OrderedDict
18 from collections import OrderedDict
19
19
20 from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
20 from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
21 from kallithea.lib.vcs.exceptions import (
21 from kallithea.lib.vcs.exceptions import (
22 BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError,
22 BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError, TagDoesNotExistError, VCSError)
23 RepositoryError, VCSError, TagAlreadyExistError, TagDoesNotExistError
23 from kallithea.lib.vcs.utils import author_email, author_name, date_fromtimestamp, makedate, safe_str, safe_unicode
24 )
24 from kallithea.lib.vcs.utils.hgcompat import (
25 from kallithea.lib.vcs.utils import (
25 Abort, RepoError, RepoLookupError, clone, diffopts, get_contact, hex, hg_url, httpbasicauthhandler, httpdigestauthhandler, httppeer, localrepo, match, match_exact, nullid, patch, peer, scmutil, sshpeer, tag, ui)
26 author_email, author_name, date_fromtimestamp, makedate, safe_unicode, safe_str,
27 )
28 from kallithea.lib.vcs.utils.lazy import LazyProperty
26 from kallithea.lib.vcs.utils.lazy import LazyProperty
29 from kallithea.lib.vcs.utils.paths import abspath
27 from kallithea.lib.vcs.utils.paths import abspath
30 from kallithea.lib.vcs.utils.hgcompat import (
31 ui, nullid, match, match_exact, patch, diffopts, clone, get_contact,
32 localrepo, RepoLookupError, Abort, RepoError, hex, scmutil, hg_url,
33 httpbasicauthhandler, httpdigestauthhandler, peer, httppeer, sshpeer, tag
34 )
35
28
36 from .changeset import MercurialChangeset
29 from .changeset import MercurialChangeset
37 from .inmemory import MercurialInMemoryChangeset
30 from .inmemory import MercurialInMemoryChangeset
38 from .workdir import MercurialWorkdir
31 from .workdir import MercurialWorkdir
39
32
33
40 log = logging.getLogger(__name__)
34 log = logging.getLogger(__name__)
41
35
42
36
@@ -15,14 +15,17 b''
15 import logging
15 import logging
16
16
17 from mercurial import hg
17 from mercurial import hg
18
19 from kallithea.lib.utils import make_ui
20 from kallithea.lib.utils2 import safe_str, safe_unicode
21 from kallithea.lib.vcs.backends.ssh import BaseSshHandler
22
23
18 try:
24 try:
19 from mercurial.wireprotoserver import sshserver
25 from mercurial.wireprotoserver import sshserver
20 except ImportError:
26 except ImportError:
21 from mercurial.sshserver import sshserver # moved in Mercurial 4.6 (1bf5263fe5cc)
27 from mercurial.sshserver import sshserver # moved in Mercurial 4.6 (1bf5263fe5cc)
22
28
23 from kallithea.lib.utils import make_ui
24 from kallithea.lib.utils2 import safe_unicode, safe_str
25 from kallithea.lib.vcs.backends.ssh import BaseSshHandler
26
29
27
30
28 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
@@ -1,6 +1,5 b''
1 from kallithea.lib.vcs.backends.base import BaseWorkdir
1 from kallithea.lib.vcs.backends.base import BaseWorkdir
2 from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
2 from kallithea.lib.vcs.exceptions import BranchDoesNotExistError
3
4 from kallithea.lib.vcs.utils.hgcompat import hg_merge
3 from kallithea.lib.vcs.utils.hgcompat import hg_merge
5
4
6
5
@@ -19,14 +19,14 b' vcs.backends.ssh'
19 SSH backend for all available SCMs
19 SSH backend for all available SCMs
20 """
20 """
21
21
22 import sys
23 import datetime
22 import datetime
24 import logging
23 import logging
24 import sys
25
25
26 from kallithea.lib.auth import AuthUser, HasPermissionAnyMiddleware
27 from kallithea.lib.utils2 import safe_str, set_hook_environment
26 from kallithea.model.db import Repository, User, UserSshKeys
28 from kallithea.model.db import Repository, User, UserSshKeys
27 from kallithea.model.meta import Session
29 from kallithea.model.meta import Session
28 from kallithea.lib.auth import HasPermissionAnyMiddleware, AuthUser
29 from kallithea.lib.utils2 import safe_str, set_hook_environment
30
30
31
31
32 log = logging.getLogger(__name__)
32 log = logging.getLogger(__name__)
@@ -1,8 +1,10 b''
1 import os
1 import os
2 import tempfile
2 import tempfile
3
3 from kallithea.lib.vcs.utils import aslist
4 from kallithea.lib.vcs.utils import aslist
4 from kallithea.lib.vcs.utils.paths import get_user_home
5 from kallithea.lib.vcs.utils.paths import get_user_home
5
6
7
6 abspath = lambda * p: os.path.abspath(os.path.join(*p))
8 abspath = lambda * p: os.path.abspath(os.path.join(*p))
7
9
8 VCSRC_PATH = os.environ.get('VCSRC_PATH')
10 VCSRC_PATH = os.environ.get('VCSRC_PATH')
@@ -9,14 +9,14 b''
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
9 :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
10 """
10 """
11
11
12 import stat
12 import mimetypes
13 import posixpath
13 import posixpath
14 import mimetypes
14 import stat
15
15
16 from kallithea.lib.vcs.backends.base import EmptyChangeset
16 from kallithea.lib.vcs.backends.base import EmptyChangeset
17 from kallithea.lib.vcs.exceptions import NodeError, RemovedFileNodeError
17 from kallithea.lib.vcs.exceptions import NodeError, RemovedFileNodeError
18 from kallithea.lib.vcs.utils import safe_str, safe_unicode
18 from kallithea.lib.vcs.utils.lazy import LazyProperty
19 from kallithea.lib.vcs.utils.lazy import LazyProperty
19 from kallithea.lib.vcs.utils import safe_unicode, safe_str
20
20
21
21
22 class NodeKind:
22 class NodeKind:
@@ -22,9 +22,9 b' You should have received a copy of the G'
22 along with git_http_backend.py Project.
22 along with git_http_backend.py Project.
23 If not, see <http://www.gnu.org/licenses/>.
23 If not, see <http://www.gnu.org/licenses/>.
24 """
24 """
25 import collections
25 import os
26 import os
26 import subprocess
27 import subprocess
27 import collections
28 import threading
28 import threading
29
29
30
30
@@ -3,9 +3,9 b' This module provides some useful tools f'
3 output. It also includes some internal helpers.
3 output. It also includes some internal helpers.
4 """
4 """
5
5
6 import time
7 import datetime
6 import datetime
8 import re
7 import re
8 import time
9
9
10
10
11 def makedate():
11 def makedate():
@@ -1,7 +1,7 b''
1 import StringIO
1 import StringIO
2
2
3 from pygments import highlight
3 from pygments.formatters import HtmlFormatter
4 from pygments.formatters import HtmlFormatter
4 from pygments import highlight
5
5
6 from kallithea.lib.vcs.exceptions import VCSError
6 from kallithea.lib.vcs.exceptions import VCSError
7 from kallithea.lib.vcs.nodes import FileNode
7 from kallithea.lib.vcs.nodes import FileNode
@@ -3,16 +3,16 b' Utilities aimed to help achieve mostly b'
3 """
3 """
4 from __future__ import division
4 from __future__ import division
5
5
6 import datetime
7 import os
6 import re
8 import re
7 import os
8 import time
9 import time
9 import datetime
10 from subprocess import PIPE, Popen
10 from subprocess import Popen, PIPE
11
11
12 from kallithea.lib.vcs.exceptions import VCSError
12 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError
13 from kallithea.lib.vcs.exceptions import RepositoryError
14 from kallithea.lib.vcs.utils.paths import abspath
13 from kallithea.lib.vcs.utils.paths import abspath
15
14
15
16 ALIASES = ['hg', 'git']
16 ALIASES = ['hg', 'git']
17
17
18
18
@@ -2,35 +2,33 b''
2 Mercurial libs compatibility
2 Mercurial libs compatibility
3 """
3 """
4
4
5 # Mercurial 5.0 550a172a603b renamed memfilectx argument `copied` to `copysource`
6 import inspect
7
5 import mercurial
8 import mercurial
6 from mercurial import demandimport
9 from mercurial import archival, config, demandimport, discovery, httppeer, localrepo
10 from mercurial import merge as hg_merge
11 from mercurial import obsutil, patch, scmutil, sshpeer, ui, unionrepo
12 from mercurial.commands import clone, nullid, pull
13 from mercurial.context import memctx, memfilectx
14 from mercurial.discovery import findcommonoutgoing
15 from mercurial.encoding import tolocal
16 from mercurial.error import Abort, RepoError, RepoLookupError
17 from mercurial.hg import peer
18 from mercurial.hgweb import hgweb_mod
19 from mercurial.hgweb.common import get_contact
20 from mercurial.match import exact as match_exact
21 from mercurial.match import match
22 from mercurial.mdiff import diffopts
23 from mercurial.node import hex, nullrev
24 from mercurial.scmutil import revrange
25 from mercurial.tags import tag
26 from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
27 from mercurial.util import url as hg_url
28
29
7 # patch demandimport, due to bug in mercurial when it always triggers demandimport.enable()
30 # patch demandimport, due to bug in mercurial when it always triggers demandimport.enable()
8 demandimport.enable = lambda *args, **kwargs: 1
31 demandimport.enable = lambda *args, **kwargs: 1
9 from mercurial import archival, merge as hg_merge, patch, ui
10 from mercurial import discovery
11 from mercurial import localrepo
12 from mercurial import unionrepo
13 from mercurial import scmutil
14 from mercurial import config
15 from mercurial.tags import tag
16 from mercurial import httppeer
17 from mercurial import sshpeer
18 from mercurial import obsutil
19 from mercurial.commands import clone, nullid, pull
20 from mercurial.context import memctx, memfilectx
21 from mercurial.error import RepoError, RepoLookupError, Abort
22 from mercurial.hgweb import hgweb_mod
23 from mercurial.hgweb.common import get_contact
24 from mercurial.match import match, exact as match_exact
25 from mercurial.mdiff import diffopts
26 from mercurial.node import hex
27 from mercurial.encoding import tolocal
28 from mercurial.discovery import findcommonoutgoing
29 from mercurial.hg import peer
30 from mercurial.util import url as hg_url
31 from mercurial.scmutil import revrange
32 from mercurial.node import nullrev
33 from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
34
32
35
33
36 # workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly
34 # workaround for 3.3 94ac64bcf6fe and not calling largefiles reposetup correctly
@@ -38,8 +36,6 b' localrepo.localrepository._lfstatuswrite'
38 # 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
36 # 3.5 7699d3212994 added the invariant that repo.lfstatus must exist before hitting overridearchive
39 localrepo.localrepository.lfstatus = False
37 localrepo.localrepository.lfstatus = False
40
38
41 # Mercurial 5.0 550a172a603b renamed memfilectx argument `copied` to `copysource`
42 import inspect
43 if inspect.getargspec(memfilectx.__init__).args[7] != 'copysource':
39 if inspect.getargspec(memfilectx.__init__).args[7] != 'copysource':
44 assert inspect.getargspec(memfilectx.__init__).args[7] == 'copied', inspect.getargspec(memfilectx.__init__).args
40 assert inspect.getargspec(memfilectx.__init__).args[7] == 'copied', inspect.getargspec(memfilectx.__init__).args
45 __org_memfilectx_ = memfilectx
41 __org_memfilectx_ = memfilectx
@@ -1,5 +1,6 b''
1 import os
1 import os
2
2
3
3 abspath = lambda * p: os.path.abspath(os.path.join(*p))
4 abspath = lambda * p: os.path.abspath(os.path.join(*p))
4
5
5
6
@@ -1,7 +1,7 b''
1 # encoding: UTF-8
1 # encoding: UTF-8
2 import sys
3 import datetime
2 import datetime
4 import string
3 import string
4 import sys
5
5
6 from kallithea.lib.vcs.utils.filesize import filesizeformat
6 from kallithea.lib.vcs.utils.filesize import filesizeformat
7
7
@@ -25,13 +25,14 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import logging
28 import time
29 import time
29 import logging
30
30
31 from kallithea.lib.utils2 import generate_api_key
31 from kallithea.lib.utils2 import generate_api_key
32 from kallithea.model.db import User, UserApiKeys
32 from kallithea.model.db import User, UserApiKeys
33 from kallithea.model.meta import Session
33 from kallithea.model.meta import Session
34
34
35
35 log = logging.getLogger(__name__)
36 log = logging.getLogger(__name__)
36
37
37
38
@@ -27,8 +27,10 b' Original author and date, and relevant c'
27
27
28
28
29 import logging
29 import logging
30
31 from kallithea.lib.utils2 import obfuscate_url_pw
30 from kallithea.model import meta
32 from kallithea.model import meta
31 from kallithea.lib.utils2 import obfuscate_url_pw
33
32
34
33 log = logging.getLogger(__name__)
35 log = logging.getLogger(__name__)
34
36
@@ -26,9 +26,11 b' Original author and date, and relevant c'
26 """
26 """
27
27
28 import logging
28 import logging
29
29 from sqlalchemy.orm import joinedload
30 from sqlalchemy.orm import joinedload
30
31
31 from kallithea.model.db import ChangesetStatus, PullRequest, Repository, User, Session
32 from kallithea.model.db import ChangesetStatus, PullRequest, Repository, Session, User
33
32
34
33 log = logging.getLogger(__name__)
35 log = logging.getLogger(__name__)
34
36
@@ -26,16 +26,16 b' Original author and date, and relevant c'
26 """
26 """
27
27
28 import logging
28 import logging
29
30 from tg.i18n import ugettext as _
31 from collections import defaultdict
29 from collections import defaultdict
32
30
33 from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
31 from tg.i18n import ugettext as _
32
34 from kallithea.lib import helpers as h
33 from kallithea.lib import helpers as h
35 from kallithea.model.db import ChangesetComment, User, \
34 from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
36 PullRequest, Repository
35 from kallithea.model.db import ChangesetComment, PullRequest, Repository, User
36 from kallithea.model.meta import Session
37 from kallithea.model.notification import NotificationModel
37 from kallithea.model.notification import NotificationModel
38 from kallithea.model.meta import Session
38
39
39
40 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
41
41
@@ -25,40 +25,37 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import collections
29 import datetime
30 import functools
31 import hashlib
32 import logging
28 import os
33 import os
29 import time
34 import time
30 import logging
31 import datetime
32 import traceback
35 import traceback
33 import hashlib
36
34 import collections
37 import ipaddr
35 import functools
36
37 import sqlalchemy
38 import sqlalchemy
39 from beaker.cache import cache_region, region_invalidate
38 from sqlalchemy import *
40 from sqlalchemy import *
39 from sqlalchemy.ext.hybrid import hybrid_property
41 from sqlalchemy.ext.hybrid import hybrid_property
40 from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
42 from sqlalchemy.orm import class_mapper, joinedload, relationship, validates
41 from beaker.cache import cache_region, region_invalidate
43 from tg.i18n import lazy_ugettext as _
42 from webob.exc import HTTPNotFound
44 from webob.exc import HTTPNotFound
43 import ipaddr
44
45 from tg.i18n import lazy_ugettext as _
46
45
47 import kallithea
46 import kallithea
47 from kallithea.lib.caching_query import FromCache
48 from kallithea.lib.compat import json
48 from kallithea.lib.exceptions import DefaultUserException
49 from kallithea.lib.exceptions import DefaultUserException
50 from kallithea.lib.utils2 import (
51 Optional, aslist, get_changeset_safe, get_clone_url, remove_prefix, safe_int, safe_str, safe_unicode, str2bool, time_to_datetime, urlreadable)
49 from kallithea.lib.vcs import get_backend
52 from kallithea.lib.vcs import get_backend
53 from kallithea.lib.vcs.backends.base import EmptyChangeset
50 from kallithea.lib.vcs.utils.helpers import get_scm
54 from kallithea.lib.vcs.utils.helpers import get_scm
51 from kallithea.lib.vcs.utils.lazy import LazyProperty
55 from kallithea.lib.vcs.utils.lazy import LazyProperty
52 from kallithea.lib.vcs.backends.base import EmptyChangeset
53
54 from kallithea.lib.utils2 import str2bool, safe_str, get_changeset_safe, \
55 safe_unicode, remove_prefix, time_to_datetime, aslist, Optional, safe_int, \
56 get_clone_url, urlreadable
57 from kallithea.lib.compat import json
58 from kallithea.lib.caching_query import FromCache
59
60 from kallithea.model.meta import Base, Session
56 from kallithea.model.meta import Base, Session
61
57
58
62 URL_SEP = '/'
59 URL_SEP = '/'
63 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
64
61
@@ -37,12 +37,12 b' import logging'
37
37
38 import formencode
38 import formencode
39 from formencode import All
39 from formencode import All
40
41 from tg.i18n import ugettext as _
40 from tg.i18n import ugettext as _
42
41
43 from kallithea import BACKENDS
42 from kallithea import BACKENDS
44 from kallithea.model import validators as v
43 from kallithea.model import validators as v
45
44
45
46 log = logging.getLogger(__name__)
46 log = logging.getLogger(__name__)
47
47
48
48
@@ -25,20 +25,20 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import logging
28 import os
29 import os
29 import random
30 import random
31 import shutil
30 import time
32 import time
31 import logging
32 import traceback
33 import traceback
33 import shutil
34
34
35 from kallithea.lib.utils2 import safe_unicode, safe_int, \
36 time_to_datetime, AttributeDict
37 from kallithea.lib.compat import json
35 from kallithea.lib.compat import json
36 from kallithea.lib.utils2 import AttributeDict, safe_int, safe_unicode, time_to_datetime
38 from kallithea.model.db import Gist, Session, User
37 from kallithea.model.db import Gist, Session, User
39 from kallithea.model.repo import RepoModel
38 from kallithea.model.repo import RepoModel
40 from kallithea.model.scm import ScmModel
39 from kallithea.model.scm import ScmModel
41
40
41
42 log = logging.getLogger(__name__)
42 log = logging.getLogger(__name__)
43
43
44 GIST_STORE_LOC = '.rc_gist_store'
44 GIST_STORE_LOC = '.rc_gist_store'
@@ -14,9 +14,9 b''
14 """
14 """
15 SQLAlchemy Metadata and Session object
15 SQLAlchemy Metadata and Session object
16 """
16 """
17 from beaker import cache
17 from sqlalchemy.ext.declarative import declarative_base
18 from sqlalchemy.ext.declarative import declarative_base
18 from sqlalchemy.orm import scoped_session, sessionmaker
19 from sqlalchemy.orm import scoped_session, sessionmaker
19 from beaker import cache
20
20
21 from kallithea.lib import caching_query
21 from kallithea.lib import caching_query
22
22
@@ -30,9 +30,10 b' import datetime'
30 import logging
30 import logging
31 import traceback
31 import traceback
32
32
33 from tg import tmpl_context as c, app_globals
33 from sqlalchemy.orm import joinedload, subqueryload
34 from tg import app_globals
35 from tg import tmpl_context as c
34 from tg.i18n import ugettext as _
36 from tg.i18n import ugettext as _
35 from sqlalchemy.orm import joinedload, subqueryload
36
37
37 import kallithea
38 import kallithea
38 from kallithea.lib import helpers as h
39 from kallithea.lib import helpers as h
@@ -40,6 +41,7 b' from kallithea.lib.utils2 import safe_un'
40 from kallithea.model.db import User
41 from kallithea.model.db import User
41 from kallithea.model.meta import Session
42 from kallithea.model.meta import Session
42
43
44
43 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
44
46
45
47
@@ -31,9 +31,9 b' import traceback'
31
31
32 from sqlalchemy.exc import DatabaseError
32 from sqlalchemy.exc import DatabaseError
33
33
34 from kallithea.model.db import Permission, Session, User, \
35 UserToPerm, UserRepoToPerm, UserRepoGroupToPerm, UserUserGroupToPerm
36 from kallithea.lib.utils2 import str2bool
34 from kallithea.lib.utils2 import str2bool
35 from kallithea.model.db import Permission, Session, User, UserRepoGroupToPerm, UserRepoToPerm, UserToPerm, UserUserGroupToPerm
36
37
37
38 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
39
39
@@ -25,21 +25,19 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import datetime
28 import logging
29 import logging
29 import datetime
30 import re
30 import re
31
31
32 from sqlalchemy.orm import joinedload
32 from tg import request
33 from tg import request
33 from tg.i18n import ugettext as _
34 from tg.i18n import ugettext as _
34
35
35 from sqlalchemy.orm import joinedload
36 from kallithea.lib import helpers as h
36
37 from kallithea.lib.utils2 import extract_mentioned_users, safe_str, safe_unicode
38 from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, User
37 from kallithea.model.meta import Session
39 from kallithea.model.meta import Session
38 from kallithea.lib import helpers as h
39 from kallithea.model.db import PullRequest, PullRequestReviewer, \
40 ChangesetStatus, User
41 from kallithea.model.notification import NotificationModel
40 from kallithea.model.notification import NotificationModel
42 from kallithea.lib.utils2 import extract_mentioned_users, safe_str, safe_unicode
43
41
44
42
45 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
@@ -26,30 +26,28 b' Original author and date, and relevant c'
26
26
27 """
27 """
28
28
29 import logging
29 import os
30 import os
30 import shutil
31 import shutil
31 import logging
32 import traceback
32 import traceback
33 from datetime import datetime
33 from datetime import datetime
34
34 from sqlalchemy.orm import subqueryload
35 from sqlalchemy.orm import subqueryload
35
36
36 import kallithea.lib.utils2
37 import kallithea.lib.utils2
37 from kallithea.lib.utils import make_ui, is_valid_repo_uri
38 from kallithea.lib.vcs.backends import get_backend
39 from kallithea.lib.utils2 import LazyProperty, safe_str, safe_unicode, \
40 remove_prefix, obfuscate_url_pw, get_current_authuser
41 from kallithea.lib.caching_query import FromCache
42 from kallithea.lib.hooks import log_delete_repository
43
44 from kallithea.model.db import Repository, UserRepoToPerm, UserGroupRepoToPerm, \
45 UserRepoGroupToPerm, UserGroupRepoGroupToPerm, User, Permission, Session, \
46 Statistics, UserGroup, Ui, RepoGroup, RepositoryField
47
48 from kallithea.lib import helpers as h
38 from kallithea.lib import helpers as h
49 from kallithea.lib.auth import HasRepoPermissionLevel, HasUserGroupPermissionLevel
39 from kallithea.lib.auth import HasRepoPermissionLevel, HasUserGroupPermissionLevel
40 from kallithea.lib.caching_query import FromCache
50 from kallithea.lib.exceptions import AttachedForksError
41 from kallithea.lib.exceptions import AttachedForksError
42 from kallithea.lib.hooks import log_delete_repository
43 from kallithea.lib.utils import is_valid_repo_uri, make_ui
44 from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str, safe_unicode
45 from kallithea.lib.vcs.backends import get_backend
46 from kallithea.model.db import (
47 Permission, RepoGroup, Repository, RepositoryField, Session, Statistics, Ui, User, UserGroup, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserRepoGroupToPerm, UserRepoToPerm)
51 from kallithea.model.scm import UserGroupList
48 from kallithea.model.scm import UserGroupList
52
49
50
53 log = logging.getLogger(__name__)
51 log = logging.getLogger(__name__)
54
52
55
53
@@ -26,17 +26,16 b' Original author and date, and relevant c'
26 """
26 """
27
27
28
28
29 import datetime
30 import logging
29 import os
31 import os
30 import logging
32 import shutil
31 import traceback
33 import traceback
32 import shutil
33 import datetime
34
34
35 import kallithea.lib.utils2
35 import kallithea.lib.utils2
36 from kallithea.lib.utils2 import LazyProperty
36 from kallithea.lib.utils2 import LazyProperty
37 from kallithea.model.db import Permission, RepoGroup, Repository, Session, Ui, User, UserGroup, UserGroupRepoGroupToPerm, UserRepoGroupToPerm
37
38
38 from kallithea.model.db import RepoGroup, Session, Ui, UserRepoGroupToPerm, \
39 User, Permission, UserGroupRepoGroupToPerm, UserGroup, Repository
40
39
41 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
42
41
@@ -24,8 +24,9 b' Original author and date, and relevant c'
24 """
24 """
25
25
26 import logging
26 import logging
27 from kallithea.model.db import User, UserRepoToPerm, UserGroupRepoToPerm, \
27
28 Permission, Repository, Session
28 from kallithea.model.db import Permission, Repository, Session, User, UserGroupRepoToPerm, UserRepoToPerm
29
29
30
30 log = logging.getLogger(__name__)
31 log = logging.getLogger(__name__)
31
32
@@ -25,37 +25,34 b' Original author and date, and relevant c'
25 :license: GPLv3, see LICENSE.md for more details.
25 :license: GPLv3, see LICENSE.md for more details.
26 """
26 """
27
27
28 import cStringIO
29 import logging
28 import os
30 import os
29 import sys
30 import posixpath
31 import posixpath
31 import re
32 import re
33 import sys
32 import time
34 import time
33 import traceback
35 import traceback
34 import logging
36
35 import cStringIO
36 import pkg_resources
37 import pkg_resources
37
38 from sqlalchemy import func
38 from sqlalchemy import func
39 from tg.i18n import ugettext as _
39 from tg.i18n import ugettext as _
40
40
41 import kallithea
41 import kallithea
42 from kallithea.lib.vcs import get_backend
43 from kallithea.lib.vcs.exceptions import RepositoryError
44 from kallithea.lib.vcs.utils.lazy import LazyProperty
45 from kallithea.lib.vcs.nodes import FileNode
46 from kallithea.lib.vcs.backends.base import EmptyChangeset
47
48 from kallithea import BACKENDS
42 from kallithea import BACKENDS
49 from kallithea.lib import helpers as h
43 from kallithea.lib import helpers as h
44 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoPermissionLevel, HasUserGroupPermissionLevel
45 from kallithea.lib.exceptions import IMCCommitError, NonRelativePathError
46 from kallithea.lib.hooks import process_pushed_raw_ids
47 from kallithea.lib.utils import action_logger, get_filesystem_repos, make_ui
50 from kallithea.lib.utils2 import safe_str, safe_unicode, set_hook_environment
48 from kallithea.lib.utils2 import safe_str, safe_unicode, set_hook_environment
51 from kallithea.lib.auth import HasRepoPermissionLevel, HasRepoGroupPermissionLevel, \
49 from kallithea.lib.vcs import get_backend
52 HasUserGroupPermissionLevel, HasPermissionAny, HasPermissionAny
50 from kallithea.lib.vcs.backends.base import EmptyChangeset
53 from kallithea.lib.utils import get_filesystem_repos, make_ui, \
51 from kallithea.lib.vcs.exceptions import RepositoryError
54 action_logger
52 from kallithea.lib.vcs.nodes import FileNode
55 from kallithea.model.db import Repository, Session, Ui, CacheInvalidation, \
53 from kallithea.lib.vcs.utils.lazy import LazyProperty
56 UserFollowing, UserLog, User, RepoGroup, PullRequest
54 from kallithea.model.db import CacheInvalidation, PullRequest, RepoGroup, Repository, Session, Ui, User, UserFollowing, UserLog
57 from kallithea.lib.hooks import process_pushed_raw_ids
55
58 from kallithea.lib.exceptions import NonRelativePathError, IMCCommitError
59
56
60 log = logging.getLogger(__name__)
57 log = logging.getLogger(__name__)
61
58
@@ -19,19 +19,20 b' SSH key model for Kallithea'
19
19
20 """
20 """
21
21
22 import errno
22 import logging
23 import logging
23 import os
24 import os
24 import stat
25 import stat
25 import tempfile
26 import tempfile
26 import errno
27
27
28 from tg import config
28 from tg import config
29 from tg.i18n import ugettext as _
29 from tg.i18n import ugettext as _
30
30
31 from kallithea.lib import ssh
31 from kallithea.lib.utils2 import safe_str, str2bool
32 from kallithea.lib.utils2 import safe_str, str2bool
32 from kallithea.model.db import UserSshKeys, User
33 from kallithea.model.db import User, UserSshKeys
33 from kallithea.model.meta import Session
34 from kallithea.model.meta import Session
34 from kallithea.lib import ssh
35
35
36
36 log = logging.getLogger(__name__)
37 log = logging.getLogger(__name__)
37
38
@@ -32,17 +32,14 b' import logging'
32 import time
32 import time
33 import traceback
33 import traceback
34
34
35 from sqlalchemy.exc import DatabaseError
35 from tg import config
36 from tg import config
36 from tg.i18n import ugettext as _
37 from tg.i18n import ugettext as _
37
38
38 from sqlalchemy.exc import DatabaseError
39
40 from kallithea.lib.utils2 import safe_str, generate_api_key, get_current_authuser
41 from kallithea.lib.caching_query import FromCache
39 from kallithea.lib.caching_query import FromCache
42 from kallithea.model.db import Permission, User, UserToPerm, \
40 from kallithea.lib.exceptions import DefaultUserException, UserOwnsReposException
43 UserEmailMap, UserIpMap
41 from kallithea.lib.utils2 import generate_api_key, get_current_authuser, safe_str
44 from kallithea.lib.exceptions import DefaultUserException, \
42 from kallithea.model.db import Permission, User, UserEmailMap, UserIpMap, UserToPerm
45 UserOwnsReposException
46 from kallithea.model.meta import Session
43 from kallithea.model.meta import Session
47
44
48
45
@@ -27,11 +27,10 b' Original author and date, and relevant c'
27 import logging
27 import logging
28 import traceback
28 import traceback
29
29
30 from kallithea.model.db import Session, UserGroupMember, UserGroup, \
30 from kallithea.lib.exceptions import RepoGroupAssignmentError, UserGroupsAssignedException
31 UserGroupRepoToPerm, Permission, UserGroupToPerm, User, UserUserGroupToPerm, \
31 from kallithea.model.db import (
32 UserGroupUserGroupToPerm
32 Permission, Session, User, UserGroup, UserGroupMember, UserGroupRepoToPerm, UserGroupToPerm, UserGroupUserGroupToPerm, UserUserGroupToPerm)
33 from kallithea.lib.exceptions import UserGroupsAssignedException, \
33
34 RepoGroupAssignmentError
35
34
36 log = logging.getLogger(__name__)
35 log = logging.getLogger(__name__)
37
36
@@ -15,28 +15,26 b''
15 Set of generic validators
15 Set of generic validators
16 """
16 """
17
17
18 import logging
18 import os
19 import os
19 import re
20 import re
20 import formencode
21 import logging
22 from collections import defaultdict
21 from collections import defaultdict
23
22
24 from tg.i18n import ugettext as _
23 import formencode
24 import ipaddr
25 import sqlalchemy
26 from formencode.validators import CIDR, Bool, Email, FancyValidator, Int, IPAddress, NotEmpty, Number, OneOf, Regex, Set, String, StringBoolean, UnicodeString
25 from sqlalchemy import func
27 from sqlalchemy import func
26 import sqlalchemy
28 from tg.i18n import ugettext as _
27 import ipaddr
28
29
29 from formencode.validators import (
30 from kallithea.config.routing import ADMIN_PREFIX
30 UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set,
31 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel
31 NotEmpty, IPAddress, CIDR, String, FancyValidator
32 )
33 from kallithea.lib.compat import OrderedSet
32 from kallithea.lib.compat import OrderedSet
33 from kallithea.lib.exceptions import LdapImportError
34 from kallithea.lib.utils import is_valid_repo_uri
34 from kallithea.lib.utils import is_valid_repo_uri
35 from kallithea.lib.utils2 import str2bool, aslist, repo_name_slug
35 from kallithea.lib.utils2 import aslist, repo_name_slug, str2bool
36 from kallithea.model.db import RepoGroup, Repository, UserGroup, User
36 from kallithea.model.db import RepoGroup, Repository, User, UserGroup
37 from kallithea.lib.exceptions import LdapImportError
37
38 from kallithea.config.routing import ADMIN_PREFIX
39 from kallithea.lib.auth import HasRepoGroupPermissionLevel, HasPermissionAny
40
38
41 # silence warnings and pylint
39 # silence warnings and pylint
42 UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set, \
40 UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set, \
@@ -20,6 +20,7 b' Refer to docs/contributing.rst for detai'
20
20
21 import pytest
21 import pytest
22
22
23
23 if getattr(pytest, 'register_assert_rewrite', None):
24 if getattr(pytest, 'register_assert_rewrite', None):
24 # make sure that all asserts under kallithea/tests benefit from advanced
25 # make sure that all asserts under kallithea/tests benefit from advanced
25 # assert reporting with pytest-3.0.0+, including api/api_base.py,
26 # assert reporting with pytest-3.0.0+, including api/api_base.py,
@@ -18,25 +18,25 b' Tests for the JSON-RPC web api.'
18
18
19 import os
19 import os
20 import random
20 import random
21 import mock
22 import re
21 import re
23
22
23 import mock
24 import pytest
24 import pytest
25
25
26 from kallithea.lib.auth import AuthUser
27 from kallithea.lib.compat import json
28 from kallithea.lib.utils2 import time_to_datetime
29 from kallithea.model.changeset_status import ChangesetStatusModel
30 from kallithea.model.db import ChangesetStatus, PullRequest, RepoGroup, Repository, Setting, Ui, User
31 from kallithea.model.gist import GistModel
32 from kallithea.model.meta import Session
33 from kallithea.model.repo import RepoModel
34 from kallithea.model.repo_group import RepoGroupModel
35 from kallithea.model.scm import ScmModel
36 from kallithea.model.user import UserModel
37 from kallithea.model.user_group import UserGroupModel
26 from kallithea.tests.base import *
38 from kallithea.tests.base import *
27 from kallithea.tests.fixture import Fixture
39 from kallithea.tests.fixture import Fixture
28 from kallithea.lib.compat import json
29 from kallithea.lib.auth import AuthUser
30 from kallithea.model.user import UserModel
31 from kallithea.model.user_group import UserGroupModel
32 from kallithea.model.repo import RepoModel
33 from kallithea.model.repo_group import RepoGroupModel
34 from kallithea.model.meta import Session
35 from kallithea.model.scm import ScmModel
36 from kallithea.model.gist import GistModel
37 from kallithea.model.changeset_status import ChangesetStatusModel
38 from kallithea.model.db import Repository, User, Setting, Ui, PullRequest, ChangesetStatus, RepoGroup
39 from kallithea.lib.utils2 import time_to_datetime
40
40
41
41
42 API_URL = '/_admin/api'
42 API_URL = '/_admin/api'
@@ -12,8 +12,8 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 from kallithea.tests.base import TestController, GIT_REPO, GIT_TEST_REVISION
16 from kallithea.tests.api.api_base import _BaseTestApi
15 from kallithea.tests.api.api_base import _BaseTestApi
16 from kallithea.tests.base import GIT_REPO, GIT_TEST_REVISION, TestController
17
17
18
18
19 class TestGitApi(_BaseTestApi, TestController):
19 class TestGitApi(_BaseTestApi, TestController):
@@ -12,8 +12,8 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 from kallithea.tests.base import TestController, HG_REPO, HG_TEST_REVISION
16 from kallithea.tests.api.api_base import _BaseTestApi
15 from kallithea.tests.api.api_base import _BaseTestApi
16 from kallithea.tests.base import HG_REPO, HG_TEST_REVISION, TestController
17
17
18
18
19 class TestHgApi(_BaseTestApi, TestController):
19 class TestHgApi(_BaseTestApi, TestController):
@@ -15,18 +15,18 b''
15 import datetime
15 import datetime
16 import logging
16 import logging
17 import os
17 import os
18 import pytest
19 import re
18 import re
20 import tempfile
19 import tempfile
21 import time
20 import time
22
21
22 import pytest
23 from tg import config
23 from tg import config
24 from webtest import TestApp
24 from webtest import TestApp
25
25
26 from kallithea import model
26 from kallithea import model
27 from kallithea.lib.utils2 import safe_str
27 from kallithea.model.db import User
28 from kallithea.model.db import User
28 from kallithea.model.meta import Session
29 from kallithea.model.meta import Session
29 from kallithea.lib.utils2 import safe_str
30
30
31
31
32 log = logging.getLogger(__name__)
32 log = logging.getLogger(__name__)
@@ -1,28 +1,26 b''
1 import logging
1 import os
2 import os
2 import re
3 import re
3 import sys
4 import sys
4 import logging
5 import pkg_resources
6 import time
5 import time
7
6
8 import formencode
7 import formencode
9 from paste.deploy import loadwsgi
8 import pkg_resources
10 from routes.util import URLGenerator
11 import pytest
9 import pytest
10 from paste.deploy import loadwsgi
12 from pytest_localserver.http import WSGIServer
11 from pytest_localserver.http import WSGIServer
12 from routes.util import URLGenerator
13 from tg.util.webtest import test_context
13
14
15 import kallithea.tests.base # FIXME: needed for setting testapp instance!!!
14 from kallithea.controllers.root import RootController
16 from kallithea.controllers.root import RootController
15 from kallithea.lib import inifile
17 from kallithea.lib import inifile
16 from kallithea.lib.utils import repo2db_mapper
18 from kallithea.lib.utils import repo2db_mapper
17 from kallithea.model.user import UserModel
19 from kallithea.model.db import Setting, User, UserIpMap
18 from kallithea.model.meta import Session
20 from kallithea.model.meta import Session
19 from kallithea.model.db import Setting, User, UserIpMap
20 from kallithea.model.scm import ScmModel
21 from kallithea.model.scm import ScmModel
21 from kallithea.tests.base import invalidate_all_caches, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, \
22 from kallithea.model.user import UserModel
22 TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
23 from kallithea.tests.base import TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, invalidate_all_caches
23 import kallithea.tests.base # FIXME: needed for setting testapp instance!!!
24
25 from tg.util.webtest import test_context
26
24
27
25
28 def pytest_configure():
26 def pytest_configure():
@@ -26,23 +26,23 b' import mock'
26 from tg import request
26 from tg import request
27 from tg.util.webtest import test_context
27 from tg.util.webtest import test_context
28
28
29 from kallithea.model.db import Repository, User, RepoGroup, UserGroup, Gist, ChangesetStatus
30 from kallithea.model.meta import Session
31 from kallithea.model.repo import RepoModel
32 from kallithea.model.user import UserModel
33 from kallithea.model.repo_group import RepoGroupModel
34 from kallithea.model.user_group import UserGroupModel
35 from kallithea.model.gist import GistModel
36 from kallithea.model.scm import ScmModel
37 from kallithea.model.comment import ChangesetCommentsModel
38 from kallithea.model.changeset_status import ChangesetStatusModel
39 from kallithea.model.pull_request import CreatePullRequestAction#, CreatePullRequestIterationAction, PullRequestModel
40 from kallithea.lib import helpers
29 from kallithea.lib import helpers
41 from kallithea.lib.auth import AuthUser
30 from kallithea.lib.auth import AuthUser
42 from kallithea.lib.db_manage import DbManage
31 from kallithea.lib.db_manage import DbManage
43 from kallithea.lib.vcs.backends.base import EmptyChangeset
32 from kallithea.lib.vcs.backends.base import EmptyChangeset
44 from kallithea.tests.base import invalidate_all_caches, GIT_REPO, HG_REPO, \
33 from kallithea.model.changeset_status import ChangesetStatusModel
45 TESTS_TMP_PATH, TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN, TEST_USER_ADMIN_EMAIL, IP_ADDR
34 from kallithea.model.comment import ChangesetCommentsModel
35 from kallithea.model.db import ChangesetStatus, Gist, RepoGroup, Repository, User, UserGroup
36 from kallithea.model.gist import GistModel
37 from kallithea.model.meta import Session
38 from kallithea.model.pull_request import CreatePullRequestAction # , CreatePullRequestIterationAction, PullRequestModel
39 from kallithea.model.repo import RepoModel
40 from kallithea.model.repo_group import RepoGroupModel
41 from kallithea.model.scm import ScmModel
42 from kallithea.model.user import UserModel
43 from kallithea.model.user_group import UserGroupModel
44 from kallithea.tests.base import (
45 GIT_REPO, HG_REPO, IP_ADDR, TEST_USER_ADMIN_EMAIL, TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, invalidate_all_caches)
46
46
47
47
48 log = logging.getLogger(__name__)
48 log = logging.getLogger(__name__)
@@ -1,11 +1,13 b''
1 import os
2 import csv
1 import csv
3 import datetime
2 import datetime
4 from kallithea.tests.base import *
3 import os
4 from os.path import dirname
5
6 from kallithea.lib.utils2 import safe_unicode
5 from kallithea.model.db import UserLog
7 from kallithea.model.db import UserLog
6 from kallithea.model.meta import Session
8 from kallithea.model.meta import Session
7 from kallithea.lib.utils2 import safe_unicode
9 from kallithea.tests.base import *
8 from os.path import dirname
10
9
11
10 FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures')
12 FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures')
11
13
@@ -1,5 +1,5 b''
1 from kallithea.model.db import Setting
1 from kallithea.tests.base import *
2 from kallithea.tests.base import *
2 from kallithea.model.db import Setting
3
3
4
4
5 class TestAuthSettingsController(TestController):
5 class TestAuthSettingsController(TestController):
@@ -1,5 +1,5 b''
1 from kallithea.model.db import Setting
1 from kallithea.tests.base import *
2 from kallithea.tests.base import *
2 from kallithea.model.db import Setting
3
3
4
4
5 class TestDefaultsController(TestController):
5 class TestDefaultsController(TestController):
@@ -1,7 +1,7 b''
1 from kallithea.tests.base import *
1 from kallithea.model.db import Gist, User
2 from kallithea.model.gist import GistModel
2 from kallithea.model.gist import GistModel
3 from kallithea.model.meta import Session
3 from kallithea.model.meta import Session
4 from kallithea.model.db import User, Gist
4 from kallithea.tests.base import *
5
5
6
6
7 def _create_gist(f_name, content='some gist', lifetime=-1,
7 def _create_gist(f_name, content='some gist', lifetime=-1,
@@ -1,12 +1,12 b''
1 import time
1 import time
2
2
3 from tg.util.webtest import test_context
4
3 from kallithea.model.db import User, UserIpMap
5 from kallithea.model.db import User, UserIpMap
6 from kallithea.model.meta import Session
4 from kallithea.model.user import UserModel
7 from kallithea.model.user import UserModel
5 from kallithea.model.meta import Session
6 from kallithea.tests.base import *
8 from kallithea.tests.base import *
7
9
8 from tg.util.webtest import test_context
9
10
10
11 class TestAdminPermissionsController(TestController):
11 class TestAdminPermissionsController(TestController):
12
12
@@ -1,23 +1,23 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 import os
3 import os
4 import mock
5 import urllib
4 import urllib
6
5
6 import mock
7 import pytest
7 import pytest
8 from sqlalchemy import func
8 from sqlalchemy import func
9
9
10 from kallithea.lib import vcs
10 from kallithea.lib import vcs
11 from kallithea.lib.utils2 import safe_str, safe_unicode
11 from kallithea.lib.utils2 import safe_str, safe_unicode
12 from kallithea.model.db import Repository, RepoGroup, UserRepoToPerm, User, \
12 from kallithea.model.db import Permission, RepoGroup, Repository, Ui, User, UserRepoToPerm
13 Permission, Ui
13 from kallithea.model.meta import Base, Session
14 from kallithea.model.repo import RepoModel
15 from kallithea.model.repo_group import RepoGroupModel
14 from kallithea.model.user import UserModel
16 from kallithea.model.user import UserModel
15 from kallithea.tests.base import *
17 from kallithea.tests.base import *
16 from kallithea.model.repo_group import RepoGroupModel
17 from kallithea.model.repo import RepoModel
18 from kallithea.model.meta import Session, Base
19 from kallithea.tests.fixture import Fixture, error_function
18 from kallithea.tests.fixture import Fixture, error_function
20
19
20
21 fixture = Fixture()
21 fixture = Fixture()
22
22
23
23
@@ -4,6 +4,7 b' from kallithea.model.db import Setting, '
4 from kallithea.tests.base import *
4 from kallithea.tests.base import *
5 from kallithea.tests.fixture import Fixture
5 from kallithea.tests.fixture import Fixture
6
6
7
7 fixture = Fixture()
8 fixture = Fixture()
8
9
9
10
@@ -1,7 +1,8 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 from kallithea.model.db import Permission, UserGroup, UserGroupToPerm
3 from kallithea.model.meta import Session
2 from kallithea.tests.base import *
4 from kallithea.tests.base import *
3 from kallithea.model.db import UserGroup, UserGroupToPerm, Permission
5
4 from kallithea.model.meta import Session
5
6
6 TEST_USER_GROUP = u'admins_test'
7 TEST_USER_GROUP = u'admins_test'
7
8
@@ -12,21 +12,21 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import pytest
15 from sqlalchemy.orm.exc import NoResultFound, ObjectDeletedError
16 from sqlalchemy.orm.exc import NoResultFound, ObjectDeletedError
17 from tg.util.webtest import test_context
18 from webob.exc import HTTPNotFound
16
19
17 import pytest
20 from kallithea.controllers.admin.users import UsersController
21 from kallithea.lib import helpers as h
22 from kallithea.lib.auth import check_password
23 from kallithea.model import validators
24 from kallithea.model.db import Permission, RepoGroup, User, UserApiKeys, UserIpMap, UserSshKeys
25 from kallithea.model.meta import Session
26 from kallithea.model.user import UserModel
18 from kallithea.tests.base import *
27 from kallithea.tests.base import *
19 from kallithea.tests.fixture import Fixture
28 from kallithea.tests.fixture import Fixture
20 from kallithea.controllers.admin.users import UsersController
21 from kallithea.model.db import User, Permission, UserIpMap, UserApiKeys, RepoGroup, UserSshKeys
22 from kallithea.lib.auth import check_password
23 from kallithea.model.user import UserModel
24 from kallithea.model import validators
25 from kallithea.lib import helpers as h
26 from kallithea.model.meta import Session
27 from webob.exc import HTTPNotFound
28
29
29 from tg.util.webtest import test_context
30
30
31 fixture = Fixture()
31 fixture = Fixture()
32
32
@@ -1,5 +1,6 b''
1 from kallithea.tests.base import *
1 from kallithea.tests.base import *
2
2
3
3 class TestChangesetController(TestController):
4 class TestChangesetController(TestController):
4
5
5 def test_index(self):
6 def test_index(self):
@@ -1,9 +1,9 b''
1 import re
1 import re
2
2
3 from kallithea.tests.base import *
4 from kallithea.model.changeset_status import ChangesetStatusModel
3 from kallithea.model.changeset_status import ChangesetStatusModel
5 from kallithea.model.db import ChangesetComment, PullRequest
4 from kallithea.model.db import ChangesetComment, PullRequest
6 from kallithea.model.meta import Session
5 from kallithea.model.meta import Session
6 from kallithea.tests.base import *
7
7
8
8
9 class TestChangeSetCommentsController(TestController):
9 class TestChangeSetCommentsController(TestController):
@@ -1,9 +1,10 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 from kallithea.tests.base import *
2 from kallithea.model.meta import Session
3 from kallithea.model.repo import RepoModel
3 from kallithea.model.repo import RepoModel
4 from kallithea.model.meta import Session
4 from kallithea.tests.base import *
5 from kallithea.tests.fixture import Fixture
5 from kallithea.tests.fixture import Fixture
6
6
7
7 fixture = Fixture()
8 fixture = Fixture()
8
9
9
10
@@ -1,6 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 from kallithea.tests.base import *
2 from kallithea.tests.base import *
3
3
4
4 class TestCompareController(TestController):
5 class TestCompareController(TestController):
5
6
6 def test_compare_tag_hg(self):
7 def test_compare_tag_hg(self):
@@ -1,5 +1,6 b''
1 from kallithea.tests.base import *
1 from kallithea.tests.base import *
2
2
3
3 class TestFeedController(TestController):
4 class TestFeedController(TestController):
4
5
5 def test_rss(self):
6 def test_rss(self):
@@ -1,12 +1,14 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 import mimetypes
2 import os
3 import os
3 import posixpath
4 import posixpath
4 import mimetypes
5
5 from kallithea.tests.base import *
6 from kallithea.model.db import Repository
6 from kallithea.model.db import Repository
7 from kallithea.model.meta import Session
7 from kallithea.model.meta import Session
8 from kallithea.tests.base import *
8 from kallithea.tests.fixture import Fixture
9 from kallithea.tests.fixture import Fixture
9
10
11
10 fixture = Fixture()
12 fixture = Fixture()
11
13
12 ARCHIVE_SPECS = {
14 ARCHIVE_SPECS = {
@@ -1,16 +1,16 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 import unittest
3 import urllib
4 import urllib
4 import unittest
5
5
6 from kallithea.lib.utils2 import safe_str, safe_unicode
7 from kallithea.model.db import Repository, User
8 from kallithea.model.meta import Session
9 from kallithea.model.repo import RepoModel
10 from kallithea.model.user import UserModel
6 from kallithea.tests.base import *
11 from kallithea.tests.base import *
7 from kallithea.tests.fixture import Fixture
12 from kallithea.tests.fixture import Fixture
8
13
9 from kallithea.lib.utils2 import safe_str, safe_unicode
10 from kallithea.model.db import Repository, User
11 from kallithea.model.repo import RepoModel
12 from kallithea.model.user import UserModel
13 from kallithea.model.meta import Session
14
14
15 fixture = Fixture()
15 fixture = Fixture()
16
16
@@ -1,12 +1,12 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 import json
2 import json
3
3
4 from kallithea.model.db import Repository
5 from kallithea.model.meta import Session
6 from kallithea.model.repo import RepoModel
7 from kallithea.model.repo_group import RepoGroupModel
4 from kallithea.tests.base import *
8 from kallithea.tests.base import *
5 from kallithea.tests.fixture import Fixture
9 from kallithea.tests.fixture import Fixture
6 from kallithea.model.meta import Session
7 from kallithea.model.db import Repository
8 from kallithea.model.repo import RepoModel
9 from kallithea.model.repo_group import RepoGroupModel
10
10
11
11
12 fixture = Fixture()
12 fixture = Fixture()
@@ -1,5 +1,6 b''
1 import datetime
2
1 from kallithea.tests.base import *
3 from kallithea.tests.base import *
2 import datetime
3
4
4
5
5 class TestJournalController(TestController):
6 class TestJournalController(TestController):
@@ -4,19 +4,19 b' import time'
4 import urlparse
4 import urlparse
5
5
6 import mock
6 import mock
7 from tg.util.webtest import test_context
7
8
8 from kallithea.tests.base import *
9 from kallithea.lib import helpers as h
9 from kallithea.tests.fixture import Fixture
10 from kallithea.lib.auth import check_password
10 from kallithea.lib.utils2 import generate_api_key
11 from kallithea.lib.utils2 import generate_api_key
11 from kallithea.lib.auth import check_password
12 from kallithea.model import validators
12 from kallithea.lib import helpers as h
13 from kallithea.model.api_key import ApiKeyModel
13 from kallithea.model.api_key import ApiKeyModel
14 from kallithea.model import validators
15 from kallithea.model.db import User
14 from kallithea.model.db import User
16 from kallithea.model.meta import Session
15 from kallithea.model.meta import Session
17 from kallithea.model.user import UserModel
16 from kallithea.model.user import UserModel
17 from kallithea.tests.base import *
18 from kallithea.tests.fixture import Fixture
18
19
19 from tg.util.webtest import test_context
20
20
21 fixture = Fixture()
21 fixture = Fixture()
22
22
@@ -1,13 +1,14 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 from kallithea.model.db import User, UserFollowing, Repository, UserApiKeys, UserSshKeys
3 from tg.util.webtest import test_context
4
5 from kallithea.lib import helpers as h
6 from kallithea.model.db import Repository, User, UserApiKeys, UserFollowing, UserSshKeys
7 from kallithea.model.meta import Session
8 from kallithea.model.user import UserModel
4 from kallithea.tests.base import *
9 from kallithea.tests.base import *
5 from kallithea.tests.fixture import Fixture
10 from kallithea.tests.fixture import Fixture
6 from kallithea.lib import helpers as h
7 from kallithea.model.user import UserModel
8 from kallithea.model.meta import Session
9
11
10 from tg.util.webtest import test_context
11
12
12 fixture = Fixture()
13 fixture = Fixture()
13
14
@@ -1,14 +1,14 b''
1 import re
1 import re
2
2 import pytest
3 import pytest
3
4 from tg.util.webtest import test_context
4 from tg.util.webtest import test_context
5
5
6 from kallithea.controllers.pullrequests import PullrequestsController
7 from kallithea.model.db import PullRequest, User
8 from kallithea.model.meta import Session
6 from kallithea.tests.base import *
9 from kallithea.tests.base import *
7 from kallithea.tests.fixture import Fixture
10 from kallithea.tests.fixture import Fixture
8 from kallithea.model.db import PullRequest, User
9 from kallithea.model.meta import Session
10
11
11 from kallithea.controllers.pullrequests import PullrequestsController
12
12
13 fixture = Fixture()
13 fixture = Fixture()
14
14
@@ -1,5 +1,7 b''
1 import os
2
1 import mock
3 import mock
2 import os
4
3 from kallithea.tests.base import *
5 from kallithea.tests.base import *
4
6
5
7
@@ -6,7 +6,8 b' from kallithea.model.meta import Session'
6 from kallithea.model.repo import RepoModel
6 from kallithea.model.repo import RepoModel
7 from kallithea.model.repo_group import RepoGroupModel
7 from kallithea.model.repo_group import RepoGroupModel
8 from kallithea.tests.base import *
8 from kallithea.tests.base import *
9 from kallithea.tests.fixture import create_test_index, Fixture
9 from kallithea.tests.fixture import Fixture, create_test_index
10
10
11
11 fixture = Fixture()
12 fixture = Fixture()
12
13
@@ -12,14 +12,15 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
14
15 import pytest
16
17 from kallithea.model.db import Repository
18 from kallithea.model.meta import Session
19 from kallithea.model.repo import RepoModel
20 from kallithea.model.scm import ScmModel
15 from kallithea.tests.base import *
21 from kallithea.tests.base import *
16 from kallithea.tests.fixture import Fixture
22 from kallithea.tests.fixture import Fixture
17 from kallithea.model.db import Repository
18 from kallithea.model.repo import RepoModel
19 from kallithea.model.meta import Session
20 from kallithea.model.scm import ScmModel
21
23
22 import pytest
23
24
24 fixture = Fixture()
25 fixture = Fixture()
25
26
@@ -1,14 +1,12 b''
1 from kallithea.lib.auth import AuthUser
2 from kallithea.model.db import RepoGroup, Repository, User
3 from kallithea.model.meta import Session
4 from kallithea.model.repo import RepoModel
5 from kallithea.model.repo_group import RepoGroupModel
6 from kallithea.model.user import UserModel
1 from kallithea.tests.base import *
7 from kallithea.tests.base import *
2 from kallithea.tests.fixture import Fixture
8 from kallithea.tests.fixture import Fixture
3
9
4 from kallithea.model.repo_group import RepoGroupModel
5 from kallithea.model.repo import RepoModel
6 from kallithea.model.db import RepoGroup, Repository, User
7 from kallithea.model.user import UserModel
8
9 from kallithea.lib.auth import AuthUser
10 from kallithea.model.meta import Session
11
12
10
13 fixture = Fixture()
11 fixture = Fixture()
14
12
@@ -1,6 +1,6 b''
1 from kallithea.tests.base import *
2 from kallithea.model.changeset_status import ChangesetStatusModel
1 from kallithea.model.changeset_status import ChangesetStatusModel
3 from kallithea.model.db import ChangesetStatus as CS
2 from kallithea.model.db import ChangesetStatus as CS
3 from kallithea.tests.base import *
4
4
5
5
6 class CSM(object): # ChangesetStatusMock
6 class CSM(object): # ChangesetStatusMock
@@ -1,9 +1,10 b''
1 from kallithea.tests.base import *
1 import pytest
2 from tg.util.webtest import test_context
3
2 from kallithea.model.comment import ChangesetCommentsModel
4 from kallithea.model.comment import ChangesetCommentsModel
3 from kallithea.model.db import Repository
5 from kallithea.model.db import Repository
6 from kallithea.tests.base import *
4
7
5 import pytest
6 from tg.util.webtest import test_context
7
8
8 class TestComments(TestController):
9 class TestComments(TestController):
9
10
@@ -1,8 +1,8 b''
1 from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, COPIED_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE, DiffProcessor
1 from kallithea.tests.base import *
2 from kallithea.tests.base import *
2 from kallithea.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \
3 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE
4 from kallithea.tests.fixture import Fixture
3 from kallithea.tests.fixture import Fixture
5
4
5
6 fixture = Fixture()
6 fixture = Fixture()
7
7
8
8
@@ -3,18 +3,16 b' import re'
3
3
4 import mock
4 import mock
5 import routes.util
5 import routes.util
6
6 from tg.util.webtest import test_context
7 from kallithea.tests.base import *
8 from kallithea.lib import helpers as h
9 from kallithea.model.db import User
10 from kallithea.model.user import UserModel
11 from kallithea.model.meta import Session
12 from kallithea.model.notification import NotificationModel, EmailNotificationModel
13
7
14 import kallithea.lib.celerylib
8 import kallithea.lib.celerylib
15 import kallithea.lib.celerylib.tasks
9 import kallithea.lib.celerylib.tasks
16
10 from kallithea.lib import helpers as h
17 from tg.util.webtest import test_context
11 from kallithea.model.db import User
12 from kallithea.model.meta import Session
13 from kallithea.model.notification import EmailNotificationModel, NotificationModel
14 from kallithea.model.user import UserModel
15 from kallithea.tests.base import *
18
16
19
17
20 class TestNotifications(TestController):
18 class TestNotifications(TestController):
@@ -1,15 +1,13 b''
1 from kallithea.lib.auth import AuthUser
2 from kallithea.model.db import Permission, RepoGroup, User, UserGroupRepoGroupToPerm, UserToPerm
3 from kallithea.model.meta import Session
4 from kallithea.model.permission import PermissionModel
5 from kallithea.model.repo import RepoModel
6 from kallithea.model.repo_group import RepoGroupModel
7 from kallithea.model.user import UserModel
8 from kallithea.model.user_group import UserGroupModel
1 from kallithea.tests.base import *
9 from kallithea.tests.base import *
2 from kallithea.tests.fixture import Fixture
10 from kallithea.tests.fixture import Fixture
3 from kallithea.model.repo_group import RepoGroupModel
4 from kallithea.model.repo import RepoModel
5 from kallithea.model.db import RepoGroup, User, UserGroupRepoGroupToPerm, \
6 Permission, UserToPerm
7 from kallithea.model.user import UserModel
8
9 from kallithea.model.meta import Session
10 from kallithea.model.user_group import UserGroupModel
11 from kallithea.lib.auth import AuthUser
12 from kallithea.model.permission import PermissionModel
13
11
14
12
15 fixture = Fixture()
13 fixture = Fixture()
@@ -1,15 +1,15 b''
1 import os
1 import os
2
2 import pytest
3 import pytest
3 from sqlalchemy.exc import IntegrityError
4 from sqlalchemy.exc import IntegrityError
4
5
6 from kallithea.model.db import RepoGroup
7 from kallithea.model.meta import Session
8 from kallithea.model.repo import RepoModel
9 from kallithea.model.repo_group import RepoGroupModel
5 from kallithea.tests.base import *
10 from kallithea.tests.base import *
6 from kallithea.tests.fixture import Fixture
11 from kallithea.tests.fixture import Fixture
7
12
8 from kallithea.model.repo_group import RepoGroupModel
9 from kallithea.model.repo import RepoModel
10 from kallithea.model.db import RepoGroup
11 from kallithea.model.meta import Session
12
13
13
14 fixture = Fixture()
14 fixture = Fixture()
15
15
@@ -1,11 +1,12 b''
1 import pytest
1 import pytest
2 from kallithea.tests.base import *
3
2
3 from kallithea.lib.exceptions import AttachedForksError
4 from kallithea.model.db import Repository
4 from kallithea.model.meta import Session
5 from kallithea.model.meta import Session
6 from kallithea.model.repo import RepoModel
7 from kallithea.tests.base import *
5 from kallithea.tests.fixture import Fixture
8 from kallithea.tests.fixture import Fixture
6 from kallithea.model.repo import RepoModel
9
7 from kallithea.model.db import Repository
8 from kallithea.lib.exceptions import AttachedForksError
9
10
10 fixture = Fixture()
11 fixture = Fixture()
11
12
@@ -1,5 +1,5 b''
1 from kallithea.model.db import Setting
1 from kallithea.model.meta import Session
2 from kallithea.model.meta import Session
2 from kallithea.model.db import Setting
3
3
4
4
5 name = 'spam-setting-name'
5 name = 'spam-setting-name'
@@ -1,13 +1,12 b''
1 import functools
1 import functools
2
2
3 from kallithea.model.db import RepoGroup
4 from kallithea.model.meta import Session
3 from kallithea.model.repo_group import RepoGroupModel
5 from kallithea.model.repo_group import RepoGroupModel
4 from kallithea.model.db import RepoGroup
5
6 from kallithea.model.meta import Session
7 from kallithea.tests.models.common import _create_project_tree, check_tree_perms, \
8 _get_perms, _check_expected_count, expected_count, _destroy_project_tree
9 from kallithea.model.user_group import UserGroupModel
6 from kallithea.model.user_group import UserGroupModel
10 from kallithea.tests.fixture import Fixture
7 from kallithea.tests.fixture import Fixture
8 from kallithea.tests.models.common import _check_expected_count, _create_project_tree, _destroy_project_tree, _get_perms, check_tree_perms, expected_count
9
11
10
12 fixture = Fixture()
11 fixture = Fixture()
13
12
@@ -1,11 +1,9 b''
1 from kallithea.model.db import User, UserGroup
1 from kallithea.model.db import User, UserGroup
2
2 from kallithea.model.meta import Session
3 from kallithea.model.user_group import UserGroupModel
3 from kallithea.tests.base import *
4 from kallithea.tests.base import *
4 from kallithea.tests.fixture import Fixture
5 from kallithea.tests.fixture import Fixture
5
6
6 from kallithea.model.user_group import UserGroupModel
7 from kallithea.model.meta import Session
8
9
7
10 fixture = Fixture()
8 fixture = Fixture()
11
9
@@ -1,11 +1,9 b''
1 import functools
1 import functools
2
2
3 from kallithea.model.db import RepoGroup, Repository, User
4 from kallithea.model.meta import Session
3 from kallithea.model.repo_group import RepoGroupModel
5 from kallithea.model.repo_group import RepoGroupModel
4 from kallithea.model.db import RepoGroup, Repository, User
6 from kallithea.tests.models.common import _check_expected_count, _create_project_tree, _destroy_project_tree, _get_perms, check_tree_perms, expected_count
5
6 from kallithea.model.meta import Session
7 from kallithea.tests.models.common import _create_project_tree, check_tree_perms, \
8 _get_perms, _check_expected_count, expected_count, _destroy_project_tree
9
7
10
8
11 test_u1_id = None
9 test_u1_id = None
@@ -1,8 +1,8 b''
1 from kallithea.model.db import UserSshKeys
1 from kallithea.model.db import UserSshKeys
2
3 from kallithea.tests.base import TestController
2 from kallithea.tests.base import TestController
4 from kallithea.tests.fixture import Fixture
3 from kallithea.tests.fixture import Fixture
5
4
5
6 fixture = Fixture()
6 fixture = Fixture()
7
7
8 public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost'
8 public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost'
@@ -1,13 +1,13 b''
1 import pytest
1 import pytest
2 from kallithea.tests.base import *
3
2
4 from kallithea.model.db import User, UserGroup, UserGroupMember, UserEmailMap, \
3 from kallithea.model.db import Permission, User, UserEmailMap, UserGroup, UserGroupMember
5 Permission
4 from kallithea.model.meta import Session
6 from kallithea.model.user import UserModel
5 from kallithea.model.user import UserModel
7 from kallithea.model.meta import Session
8 from kallithea.model.user_group import UserGroupModel
6 from kallithea.model.user_group import UserGroupModel
7 from kallithea.tests.base import *
9 from kallithea.tests.fixture import Fixture
8 from kallithea.tests.fixture import Fixture
10
9
10
11 fixture = Fixture()
11 fixture = Fixture()
12
12
13
13
@@ -1,8 +1,10 b''
1 import uuid
2
3 import pytest
4
1 from kallithea.lib.auth_modules import auth_ldap, authenticate
5 from kallithea.lib.auth_modules import auth_ldap, authenticate
2 from kallithea.model.db import Setting, User
6 from kallithea.model.db import Setting, User
3 from kallithea.model.meta import Session
7 from kallithea.model.meta import Session
4 import uuid
5 import pytest
6
8
7
9
8 @pytest.fixture
10 @pytest.fixture
@@ -27,11 +27,14 b' Original author and date, and relevant c'
27
27
28 import datetime
28 import datetime
29 import hashlib
29 import hashlib
30
30 import mock
31 import mock
31 from kallithea.tests.base import *
32 from tg.util.webtest import test_context
33
32 from kallithea.lib.utils2 import AttributeDict
34 from kallithea.lib.utils2 import AttributeDict
33 from kallithea.model.db import Repository
35 from kallithea.model.db import Repository
34 from tg.util.webtest import test_context
36 from kallithea.tests.base import *
37
35
38
36 proto = 'http'
39 proto = 'http'
37 TEST_URLS = [
40 TEST_URLS = [
@@ -1,8 +1,8 b''
1 import mock
1 import mock
2
2
3 import kallithea
3 import kallithea
4 from kallithea.model.db import User
4 from kallithea.tests.base import *
5 from kallithea.tests.base import *
5 from kallithea.model.db import User
6
6
7
7
8 class smtplib_mock(object):
8 class smtplib_mock(object):
@@ -2,15 +2,14 b''
2 import formencode
2 import formencode
3 import pytest
3 import pytest
4
4
5 from kallithea.tests.base import *
6
7 from kallithea.model import validators as v
5 from kallithea.model import validators as v
8 from kallithea.model.user_group import UserGroupModel
9
10 from kallithea.model.meta import Session
6 from kallithea.model.meta import Session
11 from kallithea.model.repo_group import RepoGroupModel
7 from kallithea.model.repo_group import RepoGroupModel
8 from kallithea.model.user_group import UserGroupModel
9 from kallithea.tests.base import *
12 from kallithea.tests.fixture import Fixture
10 from kallithea.tests.fixture import Fixture
13
11
12
14 fixture = Fixture()
13 fixture = Fixture()
15
14
16
15
@@ -25,25 +25,26 b' Original author and date, and relevant c'
25
25
26 """
26 """
27
27
28 import json
28 import os
29 import os
29 import re
30 import re
30 import tempfile
31 import tempfile
31 import time
32 import time
32 import urllib2
33 import urllib2
33 import json
34 from subprocess import PIPE, Popen
34 from tempfile import _RandomNameSequence
35 from tempfile import _RandomNameSequence
35 from subprocess import Popen, PIPE
36
36
37 import pytest
37 import pytest
38
38
39 from kallithea import CONFIG
40 from kallithea.model.db import CacheInvalidation, Repository, Ui, User, UserIpMap, UserLog
41 from kallithea.model.meta import Session
42 from kallithea.model.repo import RepoModel
43 from kallithea.model.ssh_key import SshKeyModel
44 from kallithea.model.user import UserModel
39 from kallithea.tests.base import *
45 from kallithea.tests.base import *
40 from kallithea.tests.fixture import Fixture
46 from kallithea.tests.fixture import Fixture
41 from kallithea.model.db import User, Repository, UserIpMap, CacheInvalidation, Ui, UserLog
47
42 from kallithea.model.meta import Session
43 from kallithea.model.repo import RepoModel
44 from kallithea.model.user import UserModel
45 from kallithea.model.ssh_key import SshKeyModel
46 from kallithea import CONFIG
47
48
48 DEBUG = True
49 DEBUG = True
49 HOST = '127.0.0.1:4999' # test host
50 HOST = '127.0.0.1:4999' # test host
@@ -17,6 +17,7 b' import pytest'
17 from kallithea.model.db import Repository
17 from kallithea.model.db import Repository
18 from kallithea.tests.base import *
18 from kallithea.tests.base import *
19
19
20
20 @pytest.mark.skipif("not os.environ.has_key('TEST_PERFORMANCE')", reason="skipping performance tests, set TEST_PERFORMANCE in environment if desired")
21 @pytest.mark.skipif("not os.environ.has_key('TEST_PERFORMANCE')", reason="skipping performance tests, set TEST_PERFORMANCE in environment if desired")
21 class TestVCSPerformance(TestController):
22 class TestVCSPerformance(TestController):
22
23
@@ -26,25 +26,25 b' Original author and date, and relevant c'
26
26
27 """
27 """
28
28
29 import logging
29 import os
30 import os
31 import shutil
30 import sys
32 import sys
31 import shutil
32 import logging
33 import tempfile
33 import tempfile
34 from os.path import dirname
34 from os.path import dirname
35 from subprocess import Popen, PIPE
35 from subprocess import PIPE, Popen
36
36
37 from paste.deploy import appconfig
37 from paste.deploy import appconfig
38 from sqlalchemy import engine_from_config
38 from sqlalchemy import engine_from_config
39
39
40 from kallithea.config.environment import load_environment
41 from kallithea.lib.auth import get_crypt_password
40 from kallithea.lib.utils import setup_cache_regions
42 from kallithea.lib.utils import setup_cache_regions
41 from kallithea.model.base import init_model
42 from kallithea.model import meta
43 from kallithea.model import meta
43 from kallithea.model.db import User, Repository, Ui
44 from kallithea.model.base import init_model
44 from kallithea.lib.auth import get_crypt_password
45 from kallithea.model.db import Repository, Ui, User
46 from kallithea.tests.base import HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
45
47
46 from kallithea.tests.base import HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
47 from kallithea.config.environment import load_environment
48
48
49 rel_path = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
49 rel_path = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
50 conf = appconfig('config:development.ini', relative_to=rel_path)
50 conf = appconfig('config:development.ini', relative_to=rel_path)
@@ -32,21 +32,23 b' Original author and date, and relevant c'
32
32
33
33
34 import cookielib
34 import cookielib
35 import urllib
36 import urllib2
37 import time
38 import os
35 import os
39 import sys
36 import sys
40 import tempfile
37 import tempfile
38 import time
39 import urllib
40 import urllib2
41 from os.path import dirname
41 from os.path import dirname
42
42
43 from kallithea.lib import vcs
44 from kallithea.lib.compat import OrderedSet
45 from kallithea.lib.vcs.exceptions import RepositoryError
46
47
43 __here__ = os.path.abspath(__file__)
48 __here__ = os.path.abspath(__file__)
44 __root__ = dirname(dirname(dirname(__here__)))
49 __root__ = dirname(dirname(dirname(__here__)))
45 sys.path.append(__root__)
50 sys.path.append(__root__)
46
51
47 from kallithea.lib import vcs
48 from kallithea.lib.compat import OrderedSet
49 from kallithea.lib.vcs.exceptions import RepositoryError
50
52
51 PASES = 3
53 PASES = 3
52 HOST = 'http://127.0.0.1'
54 HOST = 'http://127.0.0.1'
@@ -22,7 +22,7 b' at ``test_hg`` module.'
22 import os
22 import os
23 import shutil
23 import shutil
24
24
25 from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO, TESTS_TMP_PATH
25 from kallithea.tests.base import GIT_REMOTE_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, TEST_HG_REPO, TESTS_TMP_PATH
26 from kallithea.tests.vcs.utils import SCMFetcher
26 from kallithea.tests.vcs.utils import SCMFetcher
27
27
28
28
@@ -1,14 +1,14 b''
1 """
1 """
2 Module providing backend independent mixin class.
2 Module providing backend independent mixin class.
3 """
3 """
4 import datetime
4 import os
5 import os
5 import time
6 import time
6 import datetime
7
7 import pytest
8 import pytest
8
9
9 from kallithea.lib import vcs
10 from kallithea.lib import vcs
10 from kallithea.lib.vcs.nodes import FileNode
11 from kallithea.lib.vcs.nodes import FileNode
11
12 from kallithea.tests.vcs.conf import get_new_dir
12 from kallithea.tests.vcs.conf import get_new_dir
13
13
14
14
@@ -8,12 +8,8 b' import uuid'
8 # module. Some of these configuration options are subsequently
8 # module. Some of these configuration options are subsequently
9 # consumed by the VCS test module.
9 # consumed by the VCS test module.
10 from kallithea.tests.base import (
10 from kallithea.tests.base import (
11 TESTS_TMP_PATH,
11 GIT_REMOTE_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TEST_HG_REPO, TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL, TESTS_TMP_PATH)
12 TEST_HG_REPO, HG_REMOTE_REPO,
12
13 TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL,
14 TEST_GIT_REPO, GIT_REMOTE_REPO,
15 TEST_GIT_REPO_CLONE,
16 )
17
13
18 __all__ = (
14 __all__ = (
19 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO',
15 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO',
@@ -1,15 +1,14 b''
1 import datetime
1 import os
2 import os
3 import StringIO
2 import tarfile
4 import tarfile
5 import tempfile
3 import zipfile
6 import zipfile
4 import datetime
5 import tempfile
6 import StringIO
7
7
8 import pytest
8 import pytest
9
9
10 from kallithea.lib.vcs.exceptions import VCSError
10 from kallithea.lib.vcs.exceptions import VCSError
11 from kallithea.lib.vcs.nodes import FileNode
11 from kallithea.lib.vcs.nodes import FileNode
12
13 from kallithea.tests.vcs.base import _BackendTestMixin
12 from kallithea.tests.vcs.base import _BackendTestMixin
14 from kallithea.tests.vcs.conf import TESTS_TMP_PATH
13 from kallithea.tests.vcs.conf import TESTS_TMP_PATH
15
14
@@ -1,7 +1,7 b''
1 import datetime
1 import datetime
2
2 from kallithea.lib import vcs
3 from kallithea.lib import vcs
3 from kallithea.lib.vcs.nodes import FileNode
4 from kallithea.lib.vcs.nodes import FileNode
4
5 from kallithea.tests.vcs.base import _BackendTestMixin
5 from kallithea.tests.vcs.base import _BackendTestMixin
6
6
7
7
@@ -1,22 +1,14 b''
1 # encoding: utf-8
1 # encoding: utf-8
2
2
3 import datetime
3 import time
4 import time
4 import datetime
5
5
6 import pytest
6 import pytest
7
7
8 from kallithea.lib import vcs
8 from kallithea.lib import vcs
9
10 from kallithea.lib.vcs.backends.base import BaseChangeset
9 from kallithea.lib.vcs.backends.base import BaseChangeset
11 from kallithea.lib.vcs.nodes import (
10 from kallithea.lib.vcs.exceptions import BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError
12 FileNode, AddedFileNodesGenerator,
11 from kallithea.lib.vcs.nodes import AddedFileNodesGenerator, ChangedFileNodesGenerator, FileNode, RemovedFileNodesGenerator
13 ChangedFileNodesGenerator, RemovedFileNodesGenerator
14 )
15 from kallithea.lib.vcs.exceptions import (
16 BranchDoesNotExistError, ChangesetDoesNotExistError,
17 RepositoryError, EmptyRepositoryError
18 )
19
20 from kallithea.tests.vcs.base import _BackendTestMixin
12 from kallithea.tests.vcs.base import _BackendTestMixin
21 from kallithea.tests.vcs.conf import get_new_dir
13 from kallithea.tests.vcs.conf import get_new_dir
22
14
@@ -1,7 +1,7 b''
1 import datetime
1 import datetime
2
2
3 from kallithea.lib.vcs.nodes import FileNode
3 from kallithea.tests.vcs.base import _BackendTestMixin
4 from kallithea.tests.vcs.base import _BackendTestMixin
4 from kallithea.lib.vcs.nodes import FileNode
5
5
6
6
7 class GetitemTestCaseMixin(_BackendTestMixin):
7 class GetitemTestCaseMixin(_BackendTestMixin):
@@ -1,7 +1,6 b''
1 import datetime
1 import datetime
2
2
3 from kallithea.lib.vcs.nodes import FileNode
3 from kallithea.lib.vcs.nodes import FileNode
4
5 from kallithea.tests.vcs.base import _BackendTestMixin
4 from kallithea.tests.vcs.base import _BackendTestMixin
6
5
7
6
@@ -1,16 +1,15 b''
1 import datetime
1 import os
2 import os
2 import sys
3 import sys
3 import mock
4 import datetime
5 import urllib2
4 import urllib2
6
5
6 import mock
7 import pytest
7 import pytest
8
8
9 from kallithea.lib.vcs.backends.git import GitRepository, GitChangeset
9 from kallithea.lib.vcs.backends.git import GitChangeset, GitRepository
10 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
10 from kallithea.lib.vcs.exceptions import NodeDoesNotExistError, RepositoryError, VCSError
11 from kallithea.lib.vcs.nodes import NodeKind, FileNode, DirNode, NodeState
11 from kallithea.lib.vcs.nodes import DirNode, FileNode, NodeKind, NodeState
12 from kallithea.model.scm import ScmModel
12 from kallithea.model.scm import ScmModel
13
14 from kallithea.tests.vcs.base import _BackendTestMixin
13 from kallithea.tests.vcs.base import _BackendTestMixin
15 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir
14 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_GIT_REPO_CLONE, TESTS_TMP_PATH, get_new_dir
16
15
@@ -1,15 +1,13 b''
1 import os
1 import os
2
2
3 import mock
3 import pytest
4 import pytest
4 import mock
5
5
6 from kallithea.lib.utils2 import safe_str
6 from kallithea.lib.utils2 import safe_str
7 from kallithea.lib.vcs.backends.hg import MercurialRepository, MercurialChangeset
7 from kallithea.lib.vcs.backends.hg import MercurialChangeset, MercurialRepository
8 from kallithea.lib.vcs.exceptions import RepositoryError, VCSError, NodeDoesNotExistError
8 from kallithea.lib.vcs.exceptions import NodeDoesNotExistError, RepositoryError, VCSError
9 from kallithea.lib.vcs.nodes import NodeKind, NodeState
9 from kallithea.lib.vcs.nodes import NodeKind, NodeState
10
10 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, TEST_HG_REPO_PULL, TESTS_TMP_PATH
11 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \
12 TEST_HG_REPO_PULL, TESTS_TMP_PATH
13
11
14
12
15 class TestMercurialRepository(object):
13 class TestMercurialRepository(object):
@@ -3,23 +3,16 b''
3 Tests so called "in memory changesets" commit API of vcs.
3 Tests so called "in memory changesets" commit API of vcs.
4 """
4 """
5
5
6 import datetime
6 import time
7 import time
7 import datetime
8
8
9 import pytest
9 import pytest
10
10
11 from kallithea.lib import vcs
11 from kallithea.lib import vcs
12 from kallithea.lib.vcs.exceptions import EmptyRepositoryError
12 from kallithea.lib.vcs.exceptions import (
13 from kallithea.lib.vcs.exceptions import NodeAlreadyAddedError
13 EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError)
14 from kallithea.lib.vcs.exceptions import NodeAlreadyExistsError
14 from kallithea.lib.vcs.nodes import DirNode, FileNode
15 from kallithea.lib.vcs.exceptions import NodeAlreadyRemovedError
16 from kallithea.lib.vcs.exceptions import NodeAlreadyChangedError
17 from kallithea.lib.vcs.exceptions import NodeDoesNotExistError
18 from kallithea.lib.vcs.exceptions import NodeNotChangedError
19 from kallithea.lib.vcs.nodes import DirNode
20 from kallithea.lib.vcs.nodes import FileNode
21 from kallithea.lib.vcs.utils import safe_unicode
15 from kallithea.lib.vcs.utils import safe_unicode
22
23 from kallithea.tests.vcs.base import _BackendTestMixin
16 from kallithea.tests.vcs.base import _BackendTestMixin
24
17
25
18
@@ -1,13 +1,9 b''
1 import mimetypes
1 import stat
2 import stat
2 import mimetypes
3
3
4 import pytest
4 import pytest
5
5
6 from kallithea.lib.vcs.nodes import DirNode
6 from kallithea.lib.vcs.nodes import DirNode, FileNode, Node, NodeError, NodeKind
7 from kallithea.lib.vcs.nodes import FileNode
8 from kallithea.lib.vcs.nodes import Node
9 from kallithea.lib.vcs.nodes import NodeError
10 from kallithea.lib.vcs.nodes import NodeKind
11
7
12
8
13 class TestNodeBasic(object):
9 class TestNodeBasic(object):
@@ -2,11 +2,10 b' import datetime'
2
2
3 import pytest
3 import pytest
4
4
5 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
5 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.nodes import FileNode
6 from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError
7 from kallithea.tests.vcs import TEST_USER_CONFIG_FILE
7
8 from kallithea.tests.vcs.base import _BackendTestMixin
8 from kallithea.tests.vcs.base import _BackendTestMixin
9 from kallithea.tests.vcs import TEST_USER_CONFIG_FILE
10
9
11
10
12 class RepositoryBaseTest(_BackendTestMixin):
11 class RepositoryBaseTest(_BackendTestMixin):
@@ -1,8 +1,6 b''
1 import pytest
1 import pytest
2
2
3 from kallithea.lib.vcs.exceptions import TagAlreadyExistError
3 from kallithea.lib.vcs.exceptions import TagAlreadyExistError, TagDoesNotExistError
4 from kallithea.lib.vcs.exceptions import TagDoesNotExistError
5
6 from kallithea.tests.vcs.base import _BackendTestMixin
4 from kallithea.tests.vcs.base import _BackendTestMixin
7
5
8
6
@@ -1,24 +1,18 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 import datetime
3 import os
4 import os
4 import mock
5 import shutil
5 import time
6 import time
6 import shutil
7 import datetime
8
7
8 import mock
9 import pytest
9 import pytest
10
10
11 from kallithea.lib.vcs.utils.paths import get_dirs_for_path
11 from kallithea.lib.vcs.exceptions import VCSError
12 from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs
13 from kallithea.lib.vcs.utils.helpers import get_scm
14 from kallithea.lib.vcs.utils.helpers import get_scms_for_path
15 from kallithea.lib.vcs.utils.helpers import parse_changesets
16 from kallithea.lib.vcs.utils.helpers import parse_datetime
17 from kallithea.lib.vcs.utils import author_email, author_name
12 from kallithea.lib.vcs.utils import author_email, author_name
18 from kallithea.lib.vcs.utils.paths import get_user_home
13 from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs, get_scm, get_scms_for_path, parse_changesets, parse_datetime
19 from kallithea.lib.vcs.exceptions import VCSError
14 from kallithea.lib.vcs.utils.paths import get_dirs_for_path, get_user_home
20
15 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_HG_REPO, TESTS_TMP_PATH
21 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
22
16
23
17
24 class TestPaths(object):
18 class TestPaths(object):
@@ -4,10 +4,9 b' import shutil'
4 import pytest
4 import pytest
5
5
6 from kallithea.lib.utils2 import safe_str
6 from kallithea.lib.utils2 import safe_str
7 from kallithea.lib.vcs import VCSError, get_repo, get_backend
7 from kallithea.lib.vcs import VCSError, get_backend, get_repo
8 from kallithea.lib.vcs.backends.hg import MercurialRepository
8 from kallithea.lib.vcs.backends.hg import MercurialRepository
9
9 from kallithea.tests.vcs.conf import TEST_GIT_REPO, TEST_HG_REPO, TESTS_TMP_PATH
10 from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_GIT_REPO, TESTS_TMP_PATH
11
10
12
11
13 class TestVCS(object):
12 class TestVCS(object):
@@ -3,7 +3,6 b' import datetime'
3 import pytest
3 import pytest
4
4
5 from kallithea.lib.vcs.nodes import FileNode
5 from kallithea.lib.vcs.nodes import FileNode
6
7 from kallithea.tests.vcs.base import _BackendTestMixin
6 from kallithea.tests.vcs.base import _BackendTestMixin
8
7
9
8
@@ -4,7 +4,6 b" functions here are crafted as we don't w"
4 """
4 """
5 import os
5 import os
6 import sys
6 import sys
7
8 from subprocess import Popen
7 from subprocess import Popen
9
8
10
9
@@ -7,6 +7,7 b' Consistent formatting of rst section tit'
7 import re
7 import re
8 import subprocess
8 import subprocess
9
9
10
10 spaces = [
11 spaces = [
11 (0, 1), # we assume this is a over-and-underlined header
12 (0, 1), # we assume this is a over-and-underlined header
12 (2, 1),
13 (2, 1),
@@ -7,6 +7,7 b' import re'
7
7
8 from kallithea.lib import inifile
8 from kallithea.lib import inifile
9
9
10
10 # files to be generated from the mako template
11 # files to be generated from the mako template
11 ini_files = [
12 ini_files = [
12 ('development.ini',
13 ('development.ini',
@@ -3,6 +3,7 b''
3 import re
3 import re
4 import sys
4 import sys
5
5
6
6 logre = r'''
7 logre = r'''
7 (log\.(?:error|info|warning|debug)
8 (log\.(?:error|info|warning|debug)
8 [(][ \n]*
9 [(][ \n]*
@@ -8,8 +8,10 b' commit counts in a given revision set.'
8 import argparse
8 import argparse
9 import os
9 import os
10 from collections import Counter
10 from collections import Counter
11
11 import contributor_data
12 import contributor_data
12
13
14
13 def main():
15 def main():
14
16
15 parser = argparse.ArgumentParser(description='Generate a list of committers and commit counts.')
17 parser = argparse.ArgumentParser(description='Generate a list of committers and commit counts.')
@@ -41,6 +41,7 b' contributor, the legal entity is given c'
41 import os
41 import os
42 import re
42 import re
43 from collections import defaultdict
43 from collections import defaultdict
44
44 import contributor_data
45 import contributor_data
45
46
46
47
@@ -1,8 +1,13 b''
1 #!/usr/bin/env python2
1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 import os
3 import os
4 import platform
4 import sys
5 import sys
5 import platform
6
7 import setuptools
8 # monkey patch setuptools to use distutils owner/group functionality
9 from setuptools.command import sdist
10
6
11
7 if sys.version_info < (2, 6) or sys.version_info >= (3,):
12 if sys.version_info < (2, 6) or sys.version_info >= (3,):
8 raise Exception('Kallithea requires python 2.7')
13 raise Exception('Kallithea requires python 2.7')
@@ -110,10 +115,7 b' except IOError as err:'
110 )
115 )
111 long_description = description
116 long_description = description
112
117
113 import setuptools
114
118
115 # monkey patch setuptools to use distutils owner/group functionality
116 from setuptools.command import sdist
117 sdist_org = sdist.sdist
119 sdist_org = sdist.sdist
118 class sdist_new(sdist_org):
120 class sdist_new(sdist_org):
119 def initialize_options(self):
121 def initialize_options(self):
General Comments 0
You need to be logged in to leave comments. Login now