comparison kallithea/lib/vcs/backends/hg/inmemory.py @ 8728:f3fab7b124f2

imports: try to use global imports unless it is a layering violation To minimize the impact, do imports that violate the layering at runtime instead of at import time.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 01 Nov 2020 06:29:32 +0100
parents f9988201a3c4
children
comparison
equal deleted inserted replaced
8727:c98c7d4c9ec3 8728:f3fab7b124f2
4 import mercurial.node 4 import mercurial.node
5 5
6 from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset 6 from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset
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
10 from . import repository
9 11
10 12
11 class MercurialInMemoryChangeset(BaseInMemoryChangeset): 13 class MercurialInMemoryChangeset(BaseInMemoryChangeset):
12 14
13 def commit(self, message, author, parents=None, branch=None, date=None, 15 def commit(self, message, author, parents=None, branch=None, date=None,
33 if not isinstance(message, str): 35 if not isinstance(message, str):
34 raise RepositoryError('message must be a str - got %r' % type(message)) 36 raise RepositoryError('message must be a str - got %r' % type(message))
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 """ 45 """
45 Callback from Mercurial, returning ctx to commit for the given 46 Callback from Mercurial, returning ctx to commit for the given