##// END OF EJS Templates
chore: updated release notes
chore: updated release notes

File last commit:

r5091:9ce86a18 default
r5470:c0ff589a default
Show More
__init__.py
93 lines | 3.2 KiB | text/x-python | PythonLexer
copyrights: updated for 2023
r5088 # Copyright (C) 2014-2023 RhodeCode GmbH
project: added all source files and assets
r1 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
"""
VCS Backends module
"""
backends: don't detect backends when initializing db based vcs-instance....
r1127 import os
Martin Bornhold
vcs: Refactor the get_repo function....
r483 import logging
vcs-lib: bulk of changes for python3 support
r5074 from rhodecode import typing
project: added all source files and assets
r1
from rhodecode.lib.vcs.conf import settings
from rhodecode.lib.vcs.exceptions import VCSError
from rhodecode.lib.vcs.utils.helpers import get_scm
from rhodecode.lib.vcs.utils.imports import import_class
Martin Bornhold
vcs: Refactor the get_repo function....
r483 log = logging.getLogger(__name__)
vcs-lib: bulk of changes for python3 support
r5074 def get_vcs_instance(repo_path, *args, **kwargs) -> typing.VCSRepo | None:
project: added all source files and assets
r1 """
Martin Bornhold
vcs: Refactor the get_repo function....
r483 Given a path to a repository an instance of the corresponding vcs backend
repository class is created and returned. If no repository can be found
for the path it returns None. Arguments and keyword arguments are passed
to the vcs backend repository class.
project: added all source files and assets
r1 """
backends: fix potential unicode problems on debug logging.
r1146 from rhodecode.lib.utils2 import safe_str
backends: don't detect backends when initializing db based vcs-instance....
r1127 explicit_vcs_alias = kwargs.pop('_vcs_alias', None)
project: added all source files and assets
r1 try:
backends: fix potential unicode problems on debug logging.
r1146 vcs_alias = safe_str(explicit_vcs_alias or get_scm(repo_path)[0])
Martin Bornhold
vcs: Refactor the get_repo function....
r483 log.debug(
backends: fix potential unicode problems on debug logging.
r1146 'Creating instance of %s repository from %s', vcs_alias,
safe_str(repo_path))
Martin Bornhold
vcs: Refactor the get_repo function....
r483 backend = get_backend(vcs_alias)
backends: don't detect backends when initializing db based vcs-instance....
r1127
if explicit_vcs_alias:
vcs-lib: bulk of changes for python3 support
r5074 # do final verification of existence of the path, this does the
backends: don't detect backends when initializing db based vcs-instance....
r1127 # same as get_scm() call which we skip in explicit_vcs_alias
if not os.path.isdir(repo_path):
vcs-lib: bulk of changes for python3 support
r5074 raise VCSError(f"Given path {repo_path} is not a directory")
project: added all source files and assets
r1 except VCSError:
Martin Bornhold
vcs: Refactor the get_repo function....
r483 log.exception(
'Perhaps this repository is in db and not in '
'filesystem run rescan repositories with '
'"destroy old data" option from admin panel')
return None
project: added all source files and assets
r1
Martin Bornhold
vcs: Refactor the get_repo function....
r483 return backend(repo_path=repo_path, *args, **kwargs)
project: added all source files and assets
r1
vcs-lib: bulk of changes for python3 support
r5074 def get_backend(alias) -> typing.VCSRepoClass:
project: added all source files and assets
r1 """
Returns ``Repository`` class identified by the given alias or raises
VCSError if alias is not recognized or backend class cannot be imported.
"""
if alias not in settings.BACKENDS:
raise VCSError(
vcs-lib: bulk of changes for python3 support
r5074 f"Given alias '{alias}' is not recognized! "
f"Allowed aliases:{settings.BACKENDS.keys()}")
project: added all source files and assets
r1 backend_path = settings.BACKENDS[alias]
klass = import_class(backend_path)
return klass
def get_supported_backends():
"""
Returns list of aliases of supported backends.
"""
return settings.BACKENDS.keys()
system-info: fetch vcs settings from vcsserver. Fixes #4276...
r1111
system-info: expose workers of vcsserver in system info data.
r1465 def get_vcsserver_service_data():
system-info: fetch vcs settings from vcsserver. Fixes #4276...
r1111 from rhodecode.lib.vcs import connection
system-info: expose workers of vcsserver in system info data.
r1465 return connection.Service.get_vcsserver_service_data()
system-info: fetch vcs settings from vcsserver. Fixes #4276...
r1111