Show More
@@ -36,7 +36,7 b' from webob import Request, Response, exc' | |||||
36 |
|
36 | |||
37 | import kallithea |
|
37 | import kallithea | |
38 | from kallithea.lib.utils2 import ascii_bytes |
|
38 | from kallithea.lib.utils2 import ascii_bytes | |
39 | from kallithea.lib.vcs import subprocessio |
|
39 | from kallithea.lib.vcs import get_repo, subprocessio | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | log = logging.getLogger(__name__) |
|
42 | log = logging.getLogger(__name__) | |
@@ -170,8 +170,6 b' class GitRepository(object):' | |||||
170 | if git_command in ['git-receive-pack']: |
|
170 | if git_command in ['git-receive-pack']: | |
171 | # updating refs manually after each push. |
|
171 | # updating refs manually after each push. | |
172 | # Needed for pre-1.7.0.4 git clients using regular HTTP mode. |
|
172 | # Needed for pre-1.7.0.4 git clients using regular HTTP mode. | |
173 |
|
||||
174 | from kallithea.lib.vcs import get_repo |
|
|||
175 | repo = get_repo(self.content_path) |
|
173 | repo = get_repo(self.content_path) | |
176 | if repo: |
|
174 | if repo: | |
177 | update_server_info(repo._repo) |
|
175 | update_server_info(repo._repo) |
@@ -35,6 +35,7 b' from tg import tmpl_context as c' | |||||
35 | from tg.i18n import ugettext as _ |
|
35 | from tg.i18n import ugettext as _ | |
36 | from webob.exc import HTTPFound |
|
36 | from webob.exc import HTTPFound | |
37 |
|
37 | |||
|
38 | import kallithea | |||
38 | from kallithea.lib import webutils |
|
39 | from kallithea.lib import webutils | |
39 | from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired |
|
40 | from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired | |
40 | from kallithea.lib.base import BaseController, render |
|
41 | from kallithea.lib.base import BaseController, render | |
@@ -309,7 +310,6 b' class SettingsController(BaseController)' | |||||
309 | defaults = db.Setting.get_app_settings() |
|
310 | defaults = db.Setting.get_app_settings() | |
310 | defaults.update(self._get_hg_ui_settings()) |
|
311 | defaults.update(self._get_hg_ui_settings()) | |
311 |
|
312 | |||
312 | import kallithea |
|
|||
313 | c.ini = kallithea.CONFIG |
|
313 | c.ini = kallithea.CONFIG | |
314 |
|
314 | |||
315 | return htmlfill.render( |
|
315 | return htmlfill.render( | |
@@ -399,7 +399,6 b' class SettingsController(BaseController)' | |||||
399 | defaults = db.Setting.get_app_settings() |
|
399 | defaults = db.Setting.get_app_settings() | |
400 | defaults.update(self._get_hg_ui_settings()) |
|
400 | defaults.update(self._get_hg_ui_settings()) | |
401 |
|
401 | |||
402 | import kallithea |
|
|||
403 | c.ini = kallithea.CONFIG |
|
402 | c.ini = kallithea.CONFIG | |
404 | server_info = db.Setting.get_server_info() |
|
403 | server_info = db.Setting.get_server_info() | |
405 | for key, val in server_info.items(): |
|
404 | for key, val in server_info.items(): |
@@ -40,6 +40,7 b' from kallithea.lib import webutils' | |||||
40 | from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator |
|
40 | from kallithea.lib.auth import AuthUser, HasPermissionAnyDecorator | |
41 | from kallithea.lib.base import BaseController, log_in_user, render |
|
41 | from kallithea.lib.base import BaseController, log_in_user, render | |
42 | from kallithea.lib.exceptions import UserCreationError |
|
42 | from kallithea.lib.exceptions import UserCreationError | |
|
43 | from kallithea.lib.recaptcha import submit | |||
43 | from kallithea.lib.webutils import url |
|
44 | from kallithea.lib.webutils import url | |
44 | from kallithea.model import db, meta |
|
45 | from kallithea.model import db, meta | |
45 | from kallithea.model.forms import LoginForm, PasswordResetConfirmationForm, PasswordResetRequestForm, RegisterForm |
|
46 | from kallithea.model.forms import LoginForm, PasswordResetConfirmationForm, PasswordResetRequestForm, RegisterForm | |
@@ -132,7 +133,6 b' class LoginController(BaseController):' | |||||
132 | form_result['active'] = c.auto_active |
|
133 | form_result['active'] = c.auto_active | |
133 |
|
134 | |||
134 | if c.captcha_active: |
|
135 | if c.captcha_active: | |
135 | from kallithea.lib.recaptcha import submit |
|
|||
136 | response = submit(request.POST.get('g-recaptcha-response'), |
|
136 | response = submit(request.POST.get('g-recaptcha-response'), | |
137 | private_key=captcha_private_key, |
|
137 | private_key=captcha_private_key, | |
138 | remoteip=request.ip_addr) |
|
138 | remoteip=request.ip_addr) | |
@@ -177,7 +177,6 b' class LoginController(BaseController):' | |||||
177 | try: |
|
177 | try: | |
178 | form_result = password_reset_form.to_python(dict(request.POST)) |
|
178 | form_result = password_reset_form.to_python(dict(request.POST)) | |
179 | if c.captcha_active: |
|
179 | if c.captcha_active: | |
180 | from kallithea.lib.recaptcha import submit |
|
|||
181 | response = submit(request.POST.get('g-recaptcha-response'), |
|
180 | response = submit(request.POST.get('g-recaptcha-response'), | |
182 | private_key=captcha_private_key, |
|
181 | private_key=captcha_private_key, | |
183 | remoteip=request.ip_addr) |
|
182 | remoteip=request.ip_addr) |
@@ -22,6 +22,7 b' refer to the routes manual at http://rou' | |||||
22 | import routes |
|
22 | import routes | |
23 |
|
23 | |||
24 | import kallithea |
|
24 | import kallithea | |
|
25 | from kallithea.lib.utils import is_valid_repo, is_valid_repo_group | |||
25 | from kallithea.lib.utils2 import safe_str |
|
26 | from kallithea.lib.utils2 import safe_str | |
26 |
|
27 | |||
27 |
|
28 | |||
@@ -50,8 +51,6 b' def make_map(config):' | |||||
50 | rmap.minimization = False |
|
51 | rmap.minimization = False | |
51 | rmap.explicit = False |
|
52 | rmap.explicit = False | |
52 |
|
53 | |||
53 | from kallithea.lib.utils import is_valid_repo, is_valid_repo_group |
|
|||
54 |
|
||||
55 | def check_repo(environ, match_dict): |
|
54 | def check_repo(environ, match_dict): | |
56 | """ |
|
55 | """ | |
57 | Check for valid repository for proper 404 handling. |
|
56 | Check for valid repository for proper 404 handling. |
@@ -27,6 +27,7 b' import urllib.parse' | |||||
27 | from beaker.cache import cache_region |
|
27 | from beaker.cache import cache_region | |
28 | from pygments import highlight as code_highlight |
|
28 | from pygments import highlight as code_highlight | |
29 | from pygments.formatters.html import HtmlFormatter |
|
29 | from pygments.formatters.html import HtmlFormatter | |
|
30 | from tg import tmpl_context as c | |||
30 | from tg.i18n import ugettext as _ |
|
31 | from tg.i18n import ugettext as _ | |
31 |
|
32 | |||
32 | import kallithea |
|
33 | import kallithea | |
@@ -771,7 +772,6 b" def gravatar_div(email_address, cls='', " | |||||
771 | and '_' changed to '-' and be used as attributes on the div. The default |
|
772 | and '_' changed to '-' and be used as attributes on the div. The default | |
772 | class is 'gravatar'. |
|
773 | class is 'gravatar'. | |
773 | """ |
|
774 | """ | |
774 | from tg import tmpl_context as c |
|
|||
775 | if not c.visual.use_gravatar: |
|
775 | if not c.visual.use_gravatar: | |
776 | return '' |
|
776 | return '' | |
777 | if 'div_class' not in div_attributes: |
|
777 | if 'div_class' not in div_attributes: | |
@@ -793,7 +793,6 b" def gravatar(email_address, cls='', size" | |||||
793 | empty then we fallback to using an icon. |
|
793 | empty then we fallback to using an icon. | |
794 |
|
794 | |||
795 | """ |
|
795 | """ | |
796 | from tg import tmpl_context as c |
|
|||
797 | if not c.visual.use_gravatar: |
|
796 | if not c.visual.use_gravatar: | |
798 | return '' |
|
797 | return '' | |
799 |
|
798 | |||
@@ -815,8 +814,6 b" def gravatar(email_address, cls='', size" | |||||
815 |
|
814 | |||
816 |
|
815 | |||
817 | def gravatar_url(email_address, size=30, default=''): |
|
816 | def gravatar_url(email_address, size=30, default=''): | |
818 | from tg import tmpl_context as c |
|
|||
819 |
|
||||
820 | if not c.visual.use_gravatar: |
|
817 | if not c.visual.use_gravatar: | |
821 | return "" |
|
818 | return "" | |
822 |
|
819 |
@@ -30,6 +30,7 b' import sys' | |||||
30 | import time |
|
30 | import time | |
31 |
|
31 | |||
32 | import mercurial.scmutil |
|
32 | import mercurial.scmutil | |
|
33 | import paste.deploy | |||
33 |
|
34 | |||
34 | import kallithea |
|
35 | import kallithea | |
35 | from kallithea.lib import webutils |
|
36 | from kallithea.lib import webutils | |
@@ -301,8 +302,6 b' def _hook_environment(repo_path):' | |||||
301 | they thus need enough info to be able to create an app environment and |
|
302 | they thus need enough info to be able to create an app environment and | |
302 | connect to the database. |
|
303 | connect to the database. | |
303 | """ |
|
304 | """ | |
304 | import paste.deploy |
|
|||
305 |
|
||||
306 | import kallithea.config.application |
|
305 | import kallithea.config.application | |
307 |
|
306 | |||
308 | extras = get_hook_environment() |
|
307 | extras = get_hook_environment() |
@@ -39,6 +39,7 b' import urlobject' | |||||
39 | from dateutil import relativedelta |
|
39 | from dateutil import relativedelta | |
40 | from sqlalchemy.engine import url as sa_url |
|
40 | from sqlalchemy.engine import url as sa_url | |
41 | from sqlalchemy.exc import ArgumentError |
|
41 | from sqlalchemy.exc import ArgumentError | |
|
42 | from tg import tmpl_context | |||
42 | from tg.i18n import ugettext as _ |
|
43 | from tg.i18n import ugettext as _ | |
43 | from tg.i18n import ungettext |
|
44 | from tg.i18n import ungettext | |
44 | from tg.support.converters import asbool, aslist |
|
45 | from tg.support.converters import asbool, aslist | |
@@ -491,7 +492,6 b' def get_current_authuser():' | |||||
491 | Gets kallithea user from threadlocal tmpl_context variable if it's |
|
492 | Gets kallithea user from threadlocal tmpl_context variable if it's | |
492 | defined, else returns None. |
|
493 | defined, else returns None. | |
493 | """ |
|
494 | """ | |
494 | from tg import tmpl_context |
|
|||
495 | try: |
|
495 | try: | |
496 | return getattr(tmpl_context, 'authuser', None) |
|
496 | return getattr(tmpl_context, 'authuser', None) | |
497 | except TypeError: # No object (name: context) has been registered for this thread |
|
497 | except TypeError: # No object (name: context) has been registered for this thread |
@@ -9,6 +9,8 b' from kallithea.lib.vcs.backends.base imp' | |||||
9 | from kallithea.lib.vcs.exceptions import RepositoryError |
|
9 | from kallithea.lib.vcs.exceptions import RepositoryError | |
10 | from kallithea.lib.vcs.utils import ascii_str, safe_bytes |
|
10 | from kallithea.lib.vcs.utils import ascii_str, safe_bytes | |
11 |
|
11 | |||
|
12 | from . import repository | |||
|
13 | ||||
12 |
|
14 | |||
13 | class GitInMemoryChangeset(BaseInMemoryChangeset): |
|
15 | class GitInMemoryChangeset(BaseInMemoryChangeset): | |
14 |
|
16 | |||
@@ -32,9 +34,8 b' class GitInMemoryChangeset(BaseInMemoryC' | |||||
32 | """ |
|
34 | """ | |
33 | self.check_integrity(parents) |
|
35 | self.check_integrity(parents) | |
34 |
|
36 | |||
35 | from .repository import GitRepository |
|
|||
36 | if branch is None: |
|
37 | if branch is None: | |
37 | branch = GitRepository.DEFAULT_BRANCH_NAME |
|
38 | branch = repository.GitRepository.DEFAULT_BRANCH_NAME | |
38 |
|
39 | |||
39 | repo = self.repository._repo |
|
40 | repo = self.repository._repo | |
40 | object_store = repo.object_store |
|
41 | object_store = repo.object_store |
@@ -36,9 +36,7 b' from kallithea.lib.vcs.utils.helpers imp' | |||||
36 | from kallithea.lib.vcs.utils.lazy import LazyProperty |
|
36 | from kallithea.lib.vcs.utils.lazy import LazyProperty | |
37 | from kallithea.lib.vcs.utils.paths import abspath, get_user_home |
|
37 | from kallithea.lib.vcs.utils.paths import abspath, get_user_home | |
38 |
|
38 | |||
39 | from .changeset import GitChangeset |
|
39 | from . import changeset, inmemory, workdir | |
40 | from .inmemory import GitInMemoryChangeset |
|
|||
41 | from .workdir import GitWorkdir |
|
|||
42 |
|
40 | |||
43 |
|
41 | |||
44 | SHA_PATTERN = re.compile(r'^([0-9a-fA-F]{12}|[0-9a-fA-F]{40})$') |
|
42 | SHA_PATTERN = re.compile(r'^([0-9a-fA-F]{12}|[0-9a-fA-F]{40})$') | |
@@ -467,9 +465,9 b' class GitRepository(BaseRepository):' | |||||
467 | Returns ``GitChangeset`` object representing commit from git repository |
|
465 | Returns ``GitChangeset`` object representing commit from git repository | |
468 | at the given revision or head (most recent commit) if None given. |
|
466 | at the given revision or head (most recent commit) if None given. | |
469 | """ |
|
467 | """ | |
470 | if isinstance(revision, GitChangeset): |
|
468 | if isinstance(revision, changeset.GitChangeset): | |
471 | return revision |
|
469 | return revision | |
472 | return GitChangeset(repository=self, revision=self._get_revision(revision)) |
|
470 | return changeset.GitChangeset(repository=self, revision=self._get_revision(revision)) | |
473 |
|
471 | |||
474 | def get_changesets(self, start=None, end=None, start_date=None, |
|
472 | def get_changesets(self, start=None, end=None, start_date=None, | |
475 | end_date=None, branch_name=None, reverse=False, max_revisions=None): |
|
473 | end_date=None, branch_name=None, reverse=False, max_revisions=None): | |
@@ -669,7 +667,7 b' class GitRepository(BaseRepository):' | |||||
669 | """ |
|
667 | """ | |
670 | Returns ``GitInMemoryChangeset`` object for this repository. |
|
668 | Returns ``GitInMemoryChangeset`` object for this repository. | |
671 | """ |
|
669 | """ | |
672 | return GitInMemoryChangeset(self) |
|
670 | return inmemory.GitInMemoryChangeset(self) | |
673 |
|
671 | |||
674 | def clone(self, url, update_after_clone=True, bare=False): |
|
672 | def clone(self, url, update_after_clone=True, bare=False): | |
675 | """ |
|
673 | """ | |
@@ -728,7 +726,7 b' class GitRepository(BaseRepository):' | |||||
728 | """ |
|
726 | """ | |
729 | Returns ``Workdir`` instance for this repository. |
|
727 | Returns ``Workdir`` instance for this repository. | |
730 | """ |
|
728 | """ | |
731 | return GitWorkdir(self) |
|
729 | return workdir.GitWorkdir(self) | |
732 |
|
730 | |||
733 | def get_config_value(self, section, name, config_file=None): |
|
731 | def get_config_value(self, section, name, config_file=None): | |
734 | """ |
|
732 | """ |
@@ -7,6 +7,8 b' from kallithea.lib.vcs.backends.base imp' | |||||
7 | from kallithea.lib.vcs.exceptions import RepositoryError |
|
7 | from kallithea.lib.vcs.exceptions import RepositoryError | |
8 | from kallithea.lib.vcs.utils import ascii_str, safe_bytes, safe_str |
|
8 | from kallithea.lib.vcs.utils import ascii_str, safe_bytes, safe_str | |
9 |
|
9 | |||
|
10 | from . import repository | |||
|
11 | ||||
10 |
|
12 | |||
11 | class MercurialInMemoryChangeset(BaseInMemoryChangeset): |
|
13 | class MercurialInMemoryChangeset(BaseInMemoryChangeset): | |
12 |
|
14 | |||
@@ -35,9 +37,8 b' class MercurialInMemoryChangeset(BaseInM' | |||||
35 | if not isinstance(author, str): |
|
37 | if not isinstance(author, str): | |
36 | raise RepositoryError('author must be a str - got %r' % type(author)) |
|
38 | raise RepositoryError('author must be a str - got %r' % type(author)) | |
37 |
|
39 | |||
38 | from .repository import MercurialRepository |
|
|||
39 | if branch is None: |
|
40 | if branch is None: | |
40 | branch = MercurialRepository.DEFAULT_BRANCH_NAME |
|
41 | branch = repository.MercurialRepository.DEFAULT_BRANCH_NAME | |
41 | kwargs[b'branch'] = safe_bytes(branch) |
|
42 | kwargs[b'branch'] = safe_bytes(branch) | |
42 |
|
43 | |||
43 | def filectxfn(_repo, memctx, bytes_path): |
|
44 | def filectxfn(_repo, memctx, bytes_path): |
@@ -44,9 +44,7 b' from kallithea.lib.vcs.utils.helpers imp' | |||||
44 | from kallithea.lib.vcs.utils.lazy import LazyProperty |
|
44 | from kallithea.lib.vcs.utils.lazy import LazyProperty | |
45 | from kallithea.lib.vcs.utils.paths import abspath |
|
45 | from kallithea.lib.vcs.utils.paths import abspath | |
46 |
|
46 | |||
47 | from .changeset import MercurialChangeset |
|
47 | from . import changeset, inmemory, workdir | |
48 | from .inmemory import MercurialInMemoryChangeset |
|
|||
49 | from .workdir import MercurialWorkdir |
|
|||
50 |
|
48 | |||
51 |
|
49 | |||
52 | log = logging.getLogger(__name__) |
|
50 | log = logging.getLogger(__name__) | |
@@ -380,7 +378,7 b' class MercurialRepository(BaseRepository' | |||||
380 |
|
378 | |||
381 | @LazyProperty |
|
379 | @LazyProperty | |
382 | def in_memory_changeset(self): |
|
380 | def in_memory_changeset(self): | |
383 | return MercurialInMemoryChangeset(self) |
|
381 | return inmemory.MercurialInMemoryChangeset(self) | |
384 |
|
382 | |||
385 | @LazyProperty |
|
383 | @LazyProperty | |
386 | def description(self): |
|
384 | def description(self): | |
@@ -490,7 +488,7 b' class MercurialRepository(BaseRepository' | |||||
490 | Returns ``MercurialChangeset`` object representing repository's |
|
488 | Returns ``MercurialChangeset`` object representing repository's | |
491 | changeset at the given ``revision``. |
|
489 | changeset at the given ``revision``. | |
492 | """ |
|
490 | """ | |
493 | return MercurialChangeset(repository=self, revision=self._get_revision(revision)) |
|
491 | return changeset.MercurialChangeset(repository=self, revision=self._get_revision(revision)) | |
494 |
|
492 | |||
495 | def get_changesets(self, start=None, end=None, start_date=None, |
|
493 | def get_changesets(self, start=None, end=None, start_date=None, | |
496 | end_date=None, branch_name=None, reverse=False, max_revisions=None): |
|
494 | end_date=None, branch_name=None, reverse=False, max_revisions=None): | |
@@ -616,7 +614,7 b' class MercurialRepository(BaseRepository' | |||||
616 | """ |
|
614 | """ | |
617 | Returns ``Workdir`` instance for this repository. |
|
615 | Returns ``Workdir`` instance for this repository. | |
618 | """ |
|
616 | """ | |
619 | return MercurialWorkdir(self) |
|
617 | return workdir.MercurialWorkdir(self) | |
620 |
|
618 | |||
621 | def get_config_value(self, section, name=None, config_file=None): |
|
619 | def get_config_value(self, section, name=None, config_file=None): | |
622 | """ |
|
620 | """ |
@@ -14,6 +14,7 b' from pygments import highlight' | |||||
14 | from pygments.formatters import TerminalFormatter |
|
14 | from pygments.formatters import TerminalFormatter | |
15 | from pygments.lexers import ClassNotFound, guess_lexer_for_filename |
|
15 | from pygments.lexers import ClassNotFound, guess_lexer_for_filename | |
16 |
|
16 | |||
|
17 | from kallithea.lib.vcs import backends | |||
17 | from kallithea.lib.vcs.exceptions import RepositoryError, VCSError |
|
18 | from kallithea.lib.vcs.exceptions import RepositoryError, VCSError | |
18 | from kallithea.lib.vcs.utils import safe_str |
|
19 | from kallithea.lib.vcs.utils import safe_str | |
19 | from kallithea.lib.vcs.utils.paths import abspath |
|
20 | from kallithea.lib.vcs.utils.paths import abspath | |
@@ -71,7 +72,6 b' def get_scms_for_path(path):' | |||||
71 |
|
72 | |||
72 | :raises VCSError: if given ``path`` is not a directory |
|
73 | :raises VCSError: if given ``path`` is not a directory | |
73 | """ |
|
74 | """ | |
74 | from kallithea.lib.vcs.backends import get_backend |
|
|||
75 | if hasattr(path, '__call__'): |
|
75 | if hasattr(path, '__call__'): | |
76 | path = path() |
|
76 | path = path() | |
77 | if not os.path.isdir(path): |
|
77 | if not os.path.isdir(path): | |
@@ -91,7 +91,7 b' def get_scms_for_path(path):' | |||||
91 | # We still need to check if it's not bare repository as |
|
91 | # We still need to check if it's not bare repository as | |
92 | # bare repos don't have working directories |
|
92 | # bare repos don't have working directories | |
93 | try: |
|
93 | try: | |
94 | get_backend(key)(path) |
|
94 | backends.get_backend(key)(path) | |
95 | result.append(key) |
|
95 | result.append(key) | |
96 | continue |
|
96 | continue | |
97 | except RepositoryError: |
|
97 | except RepositoryError: |
@@ -37,6 +37,7 b' import traceback' | |||||
37 |
|
37 | |||
38 | import ipaddr |
|
38 | import ipaddr | |
39 | import sqlalchemy |
|
39 | import sqlalchemy | |
|
40 | import urlobject | |||
40 | from sqlalchemy import Boolean, Column, DateTime, Float, ForeignKey, Index, Integer, LargeBinary, String, Unicode, UnicodeText, UniqueConstraint |
|
41 | from sqlalchemy import Boolean, Column, DateTime, Float, ForeignKey, Index, Integer, LargeBinary, String, Unicode, UnicodeText, UniqueConstraint | |
41 | from sqlalchemy.ext.hybrid import hybrid_property |
|
42 | from sqlalchemy.ext.hybrid import hybrid_property | |
42 | from sqlalchemy.orm import class_mapper, joinedload, relationship, validates |
|
43 | from sqlalchemy.orm import class_mapper, joinedload, relationship, validates | |
@@ -48,7 +49,7 b' from kallithea.lib import ext_json, ssh,' | |||||
48 | from kallithea.lib.exceptions import DefaultUserException |
|
49 | from kallithea.lib.exceptions import DefaultUserException | |
49 | from kallithea.lib.utils2 import asbool, ascii_bytes, aslist, get_changeset_safe, get_clone_url, remove_prefix, safe_bytes, safe_int, safe_str, urlreadable |
|
50 | from kallithea.lib.utils2 import asbool, ascii_bytes, aslist, get_changeset_safe, get_clone_url, remove_prefix, safe_bytes, safe_int, safe_str, urlreadable | |
50 | from kallithea.lib.vcs import get_backend, get_repo |
|
51 | from kallithea.lib.vcs import get_backend, get_repo | |
51 | from kallithea.lib.vcs.backends.base import EmptyChangeset |
|
52 | from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset | |
52 | from kallithea.lib.vcs.utils import author_email, author_name |
|
53 | from kallithea.lib.vcs.utils import author_email, author_name | |
53 | from kallithea.lib.vcs.utils.helpers import get_scm |
|
54 | from kallithea.lib.vcs.utils.helpers import get_scm | |
54 | from kallithea.model import meta |
|
55 | from kallithea.model import meta | |
@@ -1171,7 +1172,6 b' class Repository(meta.Base, BaseDbModel)' | |||||
1171 | def clone_uri_hidden(self): |
|
1172 | def clone_uri_hidden(self): | |
1172 | clone_uri = self.clone_uri |
|
1173 | clone_uri = self.clone_uri | |
1173 | if clone_uri: |
|
1174 | if clone_uri: | |
1174 | import urlobject |
|
|||
1175 | url_obj = urlobject.URLObject(self.clone_uri) |
|
1175 | url_obj = urlobject.URLObject(self.clone_uri) | |
1176 | if url_obj.password: |
|
1176 | if url_obj.password: | |
1177 | clone_uri = url_obj.with_password('*****') |
|
1177 | clone_uri = url_obj.with_password('*****') | |
@@ -1226,7 +1226,6 b' class Repository(meta.Base, BaseDbModel)' | |||||
1226 |
|
1226 | |||
1227 | :param cs_cache: |
|
1227 | :param cs_cache: | |
1228 | """ |
|
1228 | """ | |
1229 | from kallithea.lib.vcs.backends.base import BaseChangeset |
|
|||
1230 | if cs_cache is None: |
|
1229 | if cs_cache is None: | |
1231 | cs_cache = EmptyChangeset() |
|
1230 | cs_cache = EmptyChangeset() | |
1232 | # use no-cache version here |
|
1231 | # use no-cache version here |
@@ -39,7 +39,7 b' from tg.i18n import ugettext as _' | |||||
39 | from kallithea.lib import webutils |
|
39 | from kallithea.lib import webutils | |
40 | from kallithea.lib.exceptions import DefaultUserException, UserOwnsReposException |
|
40 | from kallithea.lib.exceptions import DefaultUserException, UserOwnsReposException | |
41 | from kallithea.lib.utils2 import generate_api_key, get_current_authuser |
|
41 | from kallithea.lib.utils2 import generate_api_key, get_current_authuser | |
42 | from kallithea.model import db, meta |
|
42 | from kallithea.model import db, forms, meta | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | log = logging.getLogger(__name__) |
|
45 | log = logging.getLogger(__name__) | |
@@ -451,7 +451,6 b' class UserModel(object):' | |||||
451 | :param user: |
|
451 | :param user: | |
452 | :param email: |
|
452 | :param email: | |
453 | """ |
|
453 | """ | |
454 | from kallithea.model import forms |
|
|||
455 | form = forms.UserExtraEmailForm()() |
|
454 | form = forms.UserExtraEmailForm()() | |
456 | data = form.to_python(dict(email=email)) |
|
455 | data = form.to_python(dict(email=email)) | |
457 | user = db.User.guess_instance(user) |
|
456 | user = db.User.guess_instance(user) | |
@@ -481,7 +480,6 b' class UserModel(object):' | |||||
481 | :param user: |
|
480 | :param user: | |
482 | :param ip: |
|
481 | :param ip: | |
483 | """ |
|
482 | """ | |
484 | from kallithea.model import forms |
|
|||
485 | form = forms.UserExtraIpForm()() |
|
483 | form = forms.UserExtraIpForm()() | |
486 | data = form.to_python(dict(ip=ip)) |
|
484 | data = form.to_python(dict(ip=ip)) | |
487 | user = db.User.guess_instance(user) |
|
485 | user = db.User.guess_instance(user) |
@@ -28,7 +28,7 b' from sqlalchemy import func' | |||||
28 | from tg.i18n import ugettext as _ |
|
28 | from tg.i18n import ugettext as _ | |
29 |
|
29 | |||
30 | import kallithea |
|
30 | import kallithea | |
31 | from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel |
|
31 | from kallithea.lib import auth | |
32 | from kallithea.lib.compat import OrderedSet |
|
32 | from kallithea.lib.compat import OrderedSet | |
33 | from kallithea.lib.exceptions import InvalidCloneUriException, LdapImportError |
|
33 | from kallithea.lib.exceptions import InvalidCloneUriException, LdapImportError | |
34 | from kallithea.lib.utils import is_valid_repo_uri |
|
34 | from kallithea.lib.utils import is_valid_repo_uri | |
@@ -455,12 +455,12 b' def CanWriteGroup(old_data=None):' | |||||
455 | gr_name = gr.group_name if gr is not None else None # None means ROOT location |
|
455 | gr_name = gr.group_name if gr is not None else None # None means ROOT location | |
456 |
|
456 | |||
457 | # create repositories with write permission on group is set to true |
|
457 | # create repositories with write permission on group is set to true | |
458 | group_admin = HasRepoGroupPermissionLevel('admin')(gr_name, |
|
458 | group_admin = auth.HasRepoGroupPermissionLevel('admin')(gr_name, | |
459 | 'can write into group validator') |
|
459 | 'can write into group validator') | |
460 | group_write = HasRepoGroupPermissionLevel('write')(gr_name, |
|
460 | group_write = auth.HasRepoGroupPermissionLevel('write')(gr_name, | |
461 | 'can write into group validator') |
|
461 | 'can write into group validator') | |
462 | forbidden = not (group_admin or group_write) |
|
462 | forbidden = not (group_admin or group_write) | |
463 | can_create_repos = HasPermissionAny('hg.admin', 'hg.create.repository') |
|
463 | can_create_repos = auth.HasPermissionAny('hg.admin', 'hg.create.repository') | |
464 | gid = (old_data['repo_group'].get('group_id') |
|
464 | gid = (old_data['repo_group'].get('group_id') | |
465 | if (old_data and 'repo_group' in old_data) else None) |
|
465 | if (old_data and 'repo_group' in old_data) else None) | |
466 | value_changed = gid != value |
|
466 | value_changed = gid != value | |
@@ -508,7 +508,7 b' def CanCreateGroup(can_create_in_root=Fa' | |||||
508 | return |
|
508 | return | |
509 |
|
509 | |||
510 | forbidden_in_root = gr is None and not can_create_in_root |
|
510 | forbidden_in_root = gr is None and not can_create_in_root | |
511 | forbidden = not HasRepoGroupPermissionLevel('admin')(gr_name, 'can create group validator') |
|
511 | forbidden = not auth.HasRepoGroupPermissionLevel('admin')(gr_name, 'can create group validator') | |
512 | if forbidden_in_root or forbidden: |
|
512 | if forbidden_in_root or forbidden: | |
513 | msg = self.message('permission_denied', state) |
|
513 | msg = self.message('permission_denied', state) | |
514 | raise formencode.Invalid(msg, value, state, |
|
514 | raise formencode.Invalid(msg, value, state, |
@@ -19,6 +19,7 b' Tests for the JSON-RPC web api.' | |||||
19 | import os |
|
19 | import os | |
20 | import random |
|
20 | import random | |
21 | import re |
|
21 | import re | |
|
22 | import string | |||
22 |
|
23 | |||
23 | import mock |
|
24 | import mock | |
24 | import pytest |
|
25 | import pytest | |
@@ -177,7 +178,6 b' class _BaseTestApi(object):' | |||||
177 | assert response.status == '200 OK' |
|
178 | assert response.status == '200 OK' | |
178 |
|
179 | |||
179 | def test_api_args_different_args(self): |
|
180 | def test_api_args_different_args(self): | |
180 | import string |
|
|||
181 | expected = { |
|
181 | expected = { | |
182 | 'ascii_letters': string.ascii_letters, |
|
182 | 'ascii_letters': string.ascii_letters, | |
183 | 'ws': string.whitespace, |
|
183 | 'ws': string.whitespace, |
@@ -20,6 +20,7 b' import tempfile' | |||||
20 | import time |
|
20 | import time | |
21 |
|
21 | |||
22 | import pytest |
|
22 | import pytest | |
|
23 | from beaker.cache import cache_managers | |||
23 | from webtest import TestApp |
|
24 | from webtest import TestApp | |
24 |
|
25 | |||
25 | from kallithea.lib.utils2 import ascii_str |
|
26 | from kallithea.lib.utils2 import ascii_str | |
@@ -126,7 +127,6 b' def invalidate_all_caches():' | |||||
126 | effect immediately. |
|
127 | effect immediately. | |
127 | Note: Any use of this function is probably a workaround - it should be |
|
128 | Note: Any use of this function is probably a workaround - it should be | |
128 | replaced with a more specific cache invalidation in code or test.""" |
|
129 | replaced with a more specific cache invalidation in code or test.""" | |
129 | from beaker.cache import cache_managers |
|
|||
130 | for cache in cache_managers.values(): |
|
130 | for cache in cache_managers.values(): | |
131 | cache.clear() |
|
131 | cache.clear() | |
132 |
|
132 |
@@ -19,6 +19,7 b' from kallithea.model import db, meta' | |||||
19 | from kallithea.model.scm import ScmModel |
|
19 | from kallithea.model.scm import ScmModel | |
20 | from kallithea.model.user import UserModel |
|
20 | from kallithea.model.user import UserModel | |
21 | from kallithea.tests.base import TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, invalidate_all_caches |
|
21 | from kallithea.tests.base import TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, invalidate_all_caches | |
|
22 | from kallithea.tests.fixture import create_test_env, create_test_index | |||
22 |
|
23 | |||
23 |
|
24 | |||
24 | def pytest_configure(): |
|
25 | def pytest_configure(): | |
@@ -69,7 +70,6 b' def pytest_configure():' | |||||
69 | inifile.create(test_ini_file, None, ini_settings) |
|
70 | inifile.create(test_ini_file, None, ini_settings) | |
70 |
|
71 | |||
71 | context = loadwsgi.loadcontext(loadwsgi.APP, 'config:%s' % test_ini_file) |
|
72 | context = loadwsgi.loadcontext(loadwsgi.APP, 'config:%s' % test_ini_file) | |
72 | from kallithea.tests.fixture import create_test_env, create_test_index |
|
|||
73 |
|
73 | |||
74 | # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and test repos |
|
74 | # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and test repos | |
75 | if not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)): |
|
75 | if not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)): |
@@ -27,6 +27,8 b' from tg.util.webtest import test_context' | |||||
27 |
|
27 | |||
28 | from kallithea.lib.auth import AuthUser |
|
28 | from kallithea.lib.auth import AuthUser | |
29 | from kallithea.lib.db_manage import DbManage |
|
29 | from kallithea.lib.db_manage import DbManage | |
|
30 | from kallithea.lib.indexers.daemon import WhooshIndexingDaemon | |||
|
31 | from kallithea.lib.pidlock import DaemonLock | |||
30 | from kallithea.lib.vcs.backends.base import EmptyChangeset |
|
32 | from kallithea.lib.vcs.backends.base import EmptyChangeset | |
31 | from kallithea.model import db, meta |
|
33 | from kallithea.model import db, meta | |
32 | from kallithea.model.changeset_status import ChangesetStatusModel |
|
34 | from kallithea.model.changeset_status import ChangesetStatusModel | |
@@ -41,6 +43,7 b' from kallithea.model.user_group import U' | |||||
41 | from kallithea.tests.base import (GIT_REPO, HG_REPO, IP_ADDR, TEST_USER_ADMIN_EMAIL, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR2_EMAIL, |
|
43 | from kallithea.tests.base import (GIT_REPO, HG_REPO, IP_ADDR, TEST_USER_ADMIN_EMAIL, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR2_EMAIL, | |
42 | TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, |
|
44 | TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, | |
43 | TESTS_TMP_PATH, invalidate_all_caches) |
|
45 | TESTS_TMP_PATH, invalidate_all_caches) | |
|
46 | from kallithea.tests.vcs import setup_package | |||
44 |
|
47 | |||
45 |
|
48 | |||
46 | log = logging.getLogger(__name__) |
|
49 | log = logging.getLogger(__name__) | |
@@ -404,7 +407,6 b' def create_test_env(repos_test_path, con' | |||||
404 | tar.close() |
|
407 | tar.close() | |
405 |
|
408 | |||
406 | # LOAD VCS test stuff |
|
409 | # LOAD VCS test stuff | |
407 | from kallithea.tests.vcs import setup_package |
|
|||
408 | setup_package() |
|
410 | setup_package() | |
409 |
|
411 | |||
410 |
|
412 | |||
@@ -413,9 +415,6 b' def create_test_index(repo_location, con' | |||||
413 | Makes default test index |
|
415 | Makes default test index | |
414 | """ |
|
416 | """ | |
415 |
|
417 | |||
416 | from kallithea.lib.indexers.daemon import WhooshIndexingDaemon |
|
|||
417 | from kallithea.lib.pidlock import DaemonLock |
|
|||
418 |
|
||||
419 | index_location = os.path.join(config['index_dir']) |
|
418 | index_location = os.path.join(config['index_dir']) | |
420 | if not os.path.exists(index_location): |
|
419 | if not os.path.exists(index_location): | |
421 | os.makedirs(index_location) |
|
420 | os.makedirs(index_location) |
@@ -3,7 +3,7 b'' | |||||
3 | from tg.util.webtest import test_context |
|
3 | from tg.util.webtest import test_context | |
4 |
|
4 | |||
5 | from kallithea.lib import webutils |
|
5 | from kallithea.lib import webutils | |
6 | from kallithea.model import db, meta |
|
6 | from kallithea.model import db, meta, validators | |
7 | from kallithea.model.user import UserModel |
|
7 | from kallithea.model.user import UserModel | |
8 | from kallithea.tests import base |
|
8 | from kallithea.tests import base | |
9 | from kallithea.tests.fixture import Fixture |
|
9 | from kallithea.tests.fixture import Fixture | |
@@ -182,7 +182,6 b' class TestMyAccountController(base.TestC' | |||||
182 | _session_csrf_secret_token=self.session_csrf_secret_token())) |
|
182 | _session_csrf_secret_token=self.session_csrf_secret_token())) | |
183 |
|
183 | |||
184 | response.mustcontain('An email address must contain a single @') |
|
184 | response.mustcontain('An email address must contain a single @') | |
185 | from kallithea.model import validators |
|
|||
186 | with test_context(self.app): |
|
185 | with test_context(self.app): | |
187 | msg = validators.ValidUsername(edit=False, old_data={}) \ |
|
186 | msg = validators.ValidUsername(edit=False, old_data={}) \ | |
188 | ._messages['username_exists'] |
|
187 | ._messages['username_exists'] |
@@ -27,13 +27,17 b' Original author and date, and relevant c' | |||||
27 |
|
27 | |||
28 | import datetime |
|
28 | import datetime | |
29 | import hashlib |
|
29 | import hashlib | |
|
30 | import re | |||
30 |
|
31 | |||
31 | import mock |
|
32 | import mock | |
|
33 | import routes | |||
|
34 | from dateutil import relativedelta | |||
|
35 | from tg import request | |||
32 | from tg.util.webtest import test_context |
|
36 | from tg.util.webtest import test_context | |
33 |
|
37 | |||
34 | import kallithea.lib.helpers as h |
|
38 | import kallithea.lib.helpers as h | |
35 | from kallithea.lib import webutils |
|
39 | from kallithea.lib import webutils | |
36 | from kallithea.lib.utils2 import AttributeDict, safe_bytes |
|
40 | from kallithea.lib.utils2 import AttributeDict, get_clone_url, safe_bytes | |
37 | from kallithea.model import db |
|
41 | from kallithea.model import db | |
38 | from kallithea.tests import base |
|
42 | from kallithea.tests import base | |
39 |
|
43 | |||
@@ -138,8 +142,6 b' class TestLibs(base.TestController):' | |||||
138 | (dict(years= -3, months= -2), '3 years and 2 months ago'), |
|
142 | (dict(years= -3, months= -2), '3 years and 2 months ago'), | |
139 | ]) |
|
143 | ]) | |
140 | def test_age(self, age_args, expected): |
|
144 | def test_age(self, age_args, expected): | |
141 | from dateutil import relativedelta |
|
|||
142 |
|
||||
143 | from kallithea.lib.utils2 import age |
|
145 | from kallithea.lib.utils2 import age | |
144 | with test_context(self.app): |
|
146 | with test_context(self.app): | |
145 | n = datetime.datetime(year=2012, month=5, day=17) |
|
147 | n = datetime.datetime(year=2012, month=5, day=17) | |
@@ -164,8 +166,6 b' class TestLibs(base.TestController):' | |||||
164 | (dict(years= -4, months= -8), '5 years ago'), |
|
166 | (dict(years= -4, months= -8), '5 years ago'), | |
165 | ]) |
|
167 | ]) | |
166 | def test_age_short(self, age_args, expected): |
|
168 | def test_age_short(self, age_args, expected): | |
167 | from dateutil import relativedelta |
|
|||
168 |
|
||||
169 | from kallithea.lib.utils2 import age |
|
169 | from kallithea.lib.utils2 import age | |
170 | with test_context(self.app): |
|
170 | with test_context(self.app): | |
171 | n = datetime.datetime(year=2012, month=5, day=17) |
|
171 | n = datetime.datetime(year=2012, month=5, day=17) | |
@@ -184,8 +184,6 b' class TestLibs(base.TestController):' | |||||
184 | (dict(years=1, months=1), 'in 1 year and 1 month') |
|
184 | (dict(years=1, months=1), 'in 1 year and 1 month') | |
185 | ]) |
|
185 | ]) | |
186 | def test_age_in_future(self, age_args, expected): |
|
186 | def test_age_in_future(self, age_args, expected): | |
187 | from dateutil import relativedelta |
|
|||
188 |
|
||||
189 | from kallithea.lib.utils2 import age |
|
187 | from kallithea.lib.utils2 import age | |
190 | with test_context(self.app): |
|
188 | with test_context(self.app): | |
191 | n = datetime.datetime(year=2012, month=5, day=17) |
|
189 | n = datetime.datetime(year=2012, month=5, day=17) | |
@@ -221,31 +219,30 b' class TestLibs(base.TestController):' | |||||
221 |
|
219 | |||
222 | with mock.patch('kallithea.lib.webutils.url.current', lambda *a, **b: 'https://example.com'): |
|
220 | with mock.patch('kallithea.lib.webutils.url.current', lambda *a, **b: 'https://example.com'): | |
223 | fake = fake_tmpl_context(_url='http://example.com/{email}') |
|
221 | fake = fake_tmpl_context(_url='http://example.com/{email}') | |
224 |
with mock.patch(' |
|
222 | with mock.patch('kallithea.lib.helpers.c', fake): | |
225 | from kallithea.lib.webutils import url |
|
223 | assert webutils.url.current() == 'https://example.com' | |
226 | assert url.current() == 'https://example.com' |
|
|||
227 | grav = h.gravatar_url(email_address='test@example.com', size=24) |
|
224 | grav = h.gravatar_url(email_address='test@example.com', size=24) | |
228 | assert grav == 'http://example.com/test@example.com' |
|
225 | assert grav == 'http://example.com/test@example.com' | |
229 |
|
226 | |||
230 | fake = fake_tmpl_context(_url='http://example.com/{email}') |
|
227 | fake = fake_tmpl_context(_url='http://example.com/{email}') | |
231 |
with mock.patch(' |
|
228 | with mock.patch('kallithea.lib.helpers.c', fake): | |
232 | grav = h.gravatar_url(email_address='test@example.com', size=24) |
|
229 | grav = h.gravatar_url(email_address='test@example.com', size=24) | |
233 | assert grav == 'http://example.com/test@example.com' |
|
230 | assert grav == 'http://example.com/test@example.com' | |
234 |
|
231 | |||
235 | fake = fake_tmpl_context(_url='http://example.com/{md5email}') |
|
232 | fake = fake_tmpl_context(_url='http://example.com/{md5email}') | |
236 |
with mock.patch(' |
|
233 | with mock.patch('kallithea.lib.helpers.c', fake): | |
237 | em = 'test@example.com' |
|
234 | em = 'test@example.com' | |
238 | grav = h.gravatar_url(email_address=em, size=24) |
|
235 | grav = h.gravatar_url(email_address=em, size=24) | |
239 | assert grav == 'http://example.com/%s' % (_md5(em)) |
|
236 | assert grav == 'http://example.com/%s' % (_md5(em)) | |
240 |
|
237 | |||
241 | fake = fake_tmpl_context(_url='http://example.com/{md5email}/{size}') |
|
238 | fake = fake_tmpl_context(_url='http://example.com/{md5email}/{size}') | |
242 |
with mock.patch(' |
|
239 | with mock.patch('kallithea.lib.helpers.c', fake): | |
243 | em = 'test@example.com' |
|
240 | em = 'test@example.com' | |
244 | grav = h.gravatar_url(email_address=em, size=24) |
|
241 | grav = h.gravatar_url(email_address=em, size=24) | |
245 | assert grav == 'http://example.com/%s/%s' % (_md5(em), 24) |
|
242 | assert grav == 'http://example.com/%s/%s' % (_md5(em), 24) | |
246 |
|
243 | |||
247 | fake = fake_tmpl_context(_url='{scheme}://{netloc}/{md5email}/{size}') |
|
244 | fake = fake_tmpl_context(_url='{scheme}://{netloc}/{md5email}/{size}') | |
248 |
with mock.patch(' |
|
245 | with mock.patch('kallithea.lib.helpers.c', fake): | |
249 | em = 'test@example.com' |
|
246 | em = 'test@example.com' | |
250 | grav = h.gravatar_url(email_address=em, size=24) |
|
247 | grav = h.gravatar_url(email_address=em, size=24) | |
251 | assert grav == 'https://example.com/%s/%s' % (_md5(em), 24) |
|
248 | assert grav == 'https://example.com/%s/%s' % (_md5(em), 24) | |
@@ -267,7 +264,6 b' class TestLibs(base.TestController):' | |||||
267 | ('https://proxy1.example.com/{user}/{repo}', 'group/repo1', 'username', '', 'https://proxy1.example.com/username/group/repo1'), |
|
264 | ('https://proxy1.example.com/{user}/{repo}', 'group/repo1', 'username', '', 'https://proxy1.example.com/username/group/repo1'), | |
268 | ]) |
|
265 | ]) | |
269 | def test_clone_url_generator(self, clone_uri_tmpl, repo_name, username, prefix, expected): |
|
266 | def test_clone_url_generator(self, clone_uri_tmpl, repo_name, username, prefix, expected): | |
270 | from kallithea.lib.utils2 import get_clone_url |
|
|||
271 | clone_url = get_clone_url(clone_uri_tmpl=clone_uri_tmpl, prefix_url='http://vps1:8000' + prefix, |
|
267 | clone_url = get_clone_url(clone_uri_tmpl=clone_uri_tmpl, prefix_url='http://vps1:8000' + prefix, | |
272 | repo_name=repo_name, repo_id=23, username=username) |
|
268 | repo_name=repo_name, repo_id=23, username=username) | |
273 | assert clone_url == expected |
|
269 | assert clone_url == expected | |
@@ -278,8 +274,6 b' class TestLibs(base.TestController):' | |||||
278 |
|
274 | |||
279 | :param text: |
|
275 | :param text: | |
280 | """ |
|
276 | """ | |
281 | import re |
|
|||
282 |
|
||||
283 | # quickly change expected url[] into a link |
|
277 | # quickly change expected url[] into a link | |
284 | url_pattern = re.compile(r'(?:url\[)(.+?)(?:\])') |
|
278 | url_pattern = re.compile(r'(?:url\[)(.+?)(?:\])') | |
285 |
|
279 | |||
@@ -553,9 +547,6 b' class TestLibs(base.TestController):' | |||||
553 | ]) |
|
547 | ]) | |
554 | def test_canonical_url(self, canonical, test, expected): |
|
548 | def test_canonical_url(self, canonical, test, expected): | |
555 | # setup url(), used by canonical_url |
|
549 | # setup url(), used by canonical_url | |
556 | import routes |
|
|||
557 | from tg import request |
|
|||
558 |
|
||||
559 | m = routes.Mapper() |
|
550 | m = routes.Mapper() | |
560 | m.connect('about', '/about-page') |
|
551 | m.connect('about', '/about-page') | |
561 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) |
|
552 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) | |
@@ -575,9 +566,6 b' class TestLibs(base.TestController):' | |||||
575 | ('http://www.example.org/kallithea/repos/', 'www.example.org'), |
|
566 | ('http://www.example.org/kallithea/repos/', 'www.example.org'), | |
576 | ]) |
|
567 | ]) | |
577 | def test_canonical_hostname(self, canonical, expected): |
|
568 | def test_canonical_hostname(self, canonical, expected): | |
578 | import routes |
|
|||
579 | from tg import request |
|
|||
580 |
|
||||
581 | # setup url(), used by canonical_hostname |
|
569 | # setup url(), used by canonical_hostname | |
582 | m = routes.Mapper() |
|
570 | m = routes.Mapper() | |
583 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) |
|
571 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) |
@@ -14,6 +14,7 b'' | |||||
14 |
|
14 | |||
15 | import pytest |
|
15 | import pytest | |
16 |
|
16 | |||
|
17 | from kallithea.lib.graphmod import graph_data | |||
17 | from kallithea.model import db |
|
18 | from kallithea.model import db | |
18 | from kallithea.tests import base |
|
19 | from kallithea.tests import base | |
19 |
|
20 | |||
@@ -23,7 +24,6 b' class TestVCSPerformance(base.TestContro' | |||||
23 |
|
24 | |||
24 | def graphmod(self, repo): |
|
25 | def graphmod(self, repo): | |
25 | """ Simple test for running the graph_data function for profiling/testing performance. """ |
|
26 | """ Simple test for running the graph_data function for profiling/testing performance. """ | |
26 | from kallithea.lib.graphmod import graph_data |
|
|||
27 | dbr = db.Repository.get_by_repo_name(repo) |
|
27 | dbr = db.Repository.get_by_repo_name(repo) | |
28 | scm_inst = dbr.scm_instance |
|
28 | scm_inst = dbr.scm_instance | |
29 | collection = scm_inst.get_changesets(start=0, end=None, branch_name=None) |
|
29 | collection = scm_inst.get_changesets(start=0, end=None, branch_name=None) |
@@ -41,6 +41,7 b' import kallithea.config.application' | |||||
41 | from kallithea.lib.auth import get_crypt_password |
|
41 | from kallithea.lib.auth import get_crypt_password | |
42 | from kallithea.model import db, meta |
|
42 | from kallithea.model import db, meta | |
43 | from kallithea.model.base import init_model |
|
43 | from kallithea.model.base import init_model | |
|
44 | from kallithea.model.repo import RepoModel | |||
44 | from kallithea.tests.base import HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS |
|
45 | from kallithea.tests.base import HG_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS | |
45 |
|
46 | |||
46 |
|
47 | |||
@@ -114,7 +115,6 b' def create_test_user(force=True):' | |||||
114 |
|
115 | |||
115 | def create_test_repo(force=True): |
|
116 | def create_test_repo(force=True): | |
116 | print('creating test repo') |
|
117 | print('creating test repo') | |
117 | from kallithea.model.repo import RepoModel |
|
|||
118 | sa = get_session() |
|
118 | sa = get_session() | |
119 |
|
119 | |||
120 | user = sa.query(db.User).filter(db.User.username == USER).scalar() |
|
120 | user = sa.query(db.User).filter(db.User.username == USER).scalar() |
@@ -1,3 +1,4 b'' | |||||
|
1 | import copy | |||
1 | import datetime |
|
2 | import datetime | |
2 |
|
3 | |||
3 | import pytest |
|
4 | import pytest | |
@@ -31,7 +32,6 b' class RepositoryBaseTest(_BackendTestMix' | |||||
31 | assert self.repo == self.repo |
|
32 | assert self.repo == self.repo | |
32 |
|
33 | |||
33 | def test_repo_equality_broken_object(self): |
|
34 | def test_repo_equality_broken_object(self): | |
34 | import copy |
|
|||
35 | _repo = copy.copy(self.repo) |
|
35 | _repo = copy.copy(self.repo) | |
36 | delattr(_repo, 'path') |
|
36 | delattr(_repo, 'path') | |
37 | assert self.repo != _repo |
|
37 | assert self.repo != _repo |
@@ -2,6 +2,7 b' import datetime' | |||||
2 |
|
2 | |||
3 | import pytest |
|
3 | import pytest | |
4 |
|
4 | |||
|
5 | from kallithea.lib.vcs.exceptions import BranchDoesNotExistError | |||
5 | from kallithea.lib.vcs.nodes import FileNode |
|
6 | from kallithea.lib.vcs.nodes import FileNode | |
6 | from kallithea.tests.vcs.base import _BackendTestMixin |
|
7 | from kallithea.tests.vcs.base import _BackendTestMixin | |
7 |
|
8 | |||
@@ -67,8 +68,6 b' class WorkdirTestCaseMixin(_BackendTestM' | |||||
67 | assert self.repo.workdir.get_changeset() == old_head |
|
68 | assert self.repo.workdir.get_changeset() == old_head | |
68 |
|
69 | |||
69 | def test_checkout_branch(self): |
|
70 | def test_checkout_branch(self): | |
70 | from kallithea.lib.vcs.exceptions import BranchDoesNotExistError |
|
|||
71 |
|
||||
72 | # first, 'foobranch' does not exist. |
|
71 | # first, 'foobranch' does not exist. | |
73 | with pytest.raises(BranchDoesNotExistError): |
|
72 | with pytest.raises(BranchDoesNotExistError): | |
74 | self.repo.workdir.checkout_branch(branch='foobranch') |
|
73 | self.repo.workdir.checkout_branch(branch='foobranch') |
@@ -2,6 +2,7 b'' | |||||
2 | # -*- coding: utf-8 -*- |
|
2 | # -*- coding: utf-8 -*- | |
3 | import os |
|
3 | import os | |
4 | import platform |
|
4 | import platform | |
|
5 | import re | |||
5 | import sys |
|
6 | import sys | |
6 |
|
7 | |||
7 | import setuptools |
|
8 | import setuptools | |
@@ -17,7 +18,6 b' here = os.path.abspath(os.path.dirname(_' | |||||
17 |
|
18 | |||
18 |
|
19 | |||
19 | def _get_meta_var(name, data, callback_handler=None): |
|
20 | def _get_meta_var(name, data, callback_handler=None): | |
20 | import re |
|
|||
21 | matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data) |
|
21 | matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data) | |
22 | if matches: |
|
22 | if matches: | |
23 | s = eval(matches.groups()[0]) |
|
23 | s = eval(matches.groups()[0]) |
General Comments 0
You need to be logged in to leave comments.
Login now