vcs-connection: report problems more explicitly if connections are not established and we want to use it

This commit is contained in:
RhodeCode Admin 2023-03-10 10:08:05 +01:00
parent cb4c965e1a
commit f2c5bfb6c6

View file

@ -23,15 +23,23 @@ Holds connection for remote server.
"""
def _not_initialized(*args, **kwargs):
class NotInitializedConnection(object):
"""Placeholder for objects which have to be initialized first."""
raise Exception(
"rhodecode.lib.vcs is not yet initialized. "
"Make sure `vcs.server` is enabled in your configuration.")
def _raise_exc(self):
raise Exception(
"rhodecode.lib.vcs is not yet initialized. "
"Make sure `vcs.server` is enabled in your configuration.")
def __getattr__(self, item):
self._raise_exc()
def __call__(self, *args, **kwargs):
self._raise_exc()
# TODO: figure out a nice default value for these things
Service = _not_initialized
Service = NotInitializedConnection()
Git = _not_initialized
Hg = _not_initialized
Svn = _not_initialized
Git = NotInitializedConnection()
Hg = NotInitializedConnection()
Svn = NotInitializedConnection()