From f2c5bfb6c6e7a1a02244d6840a7be0baea41fba7 Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Fri, 10 Mar 2023 10:08:05 +0100 Subject: [PATCH] vcs-connection: report problems more explicitly if connections are not established and we want to use it --- rhodecode/lib/vcs/connection.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/rhodecode/lib/vcs/connection.py b/rhodecode/lib/vcs/connection.py index 3fa1cfdb..cef83a74 100644 --- a/rhodecode/lib/vcs/connection.py +++ b/rhodecode/lib/vcs/connection.py @@ -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()