diff --git a/rhodecode/lib/middleware/simplevcs.py b/rhodecode/lib/middleware/simplevcs.py --- a/rhodecode/lib/middleware/simplevcs.py +++ b/rhodecode/lib/middleware/simplevcs.py @@ -34,6 +34,7 @@ from paste.httpheaders import REMOTE_USE # TODO(marcink): check if we should use webob.exc here ? from pyramid.httpexceptions import ( HTTPNotFound, HTTPForbidden, HTTPNotAcceptable, HTTPInternalServerError) +from zope.cachedescriptors.property import Lazy as LazyProperty import rhodecode from rhodecode.authentication.base import ( @@ -121,12 +122,28 @@ class SimpleVCS(object): auth_ret_code_detection) self.ip_addr = '0.0.0.0' + @LazyProperty + def global_vcs_config(self): + try: + return VcsSettingsModel().get_ui_settings_as_config_obj() + except Exception: + return base.Config() + @property def base_path(self): - settings_path = self.repo_vcs_config.get(*VcsSettingsModel.PATH_SETTING) + settings_path = self.repo_vcs_config.get( + *VcsSettingsModel.PATH_SETTING) + + if not settings_path: + settings_path = self.global_vcs_config.get( + *VcsSettingsModel.PATH_SETTING) + if not settings_path: # try, maybe we passed in explicitly as config option settings_path = self.config.get('base_path') + + if not settings_path: + raise ValueError('FATAL: base_path is empty') return settings_path def set_repo_names(self, environ): diff --git a/rhodecode/tests/lib/middleware/test_vcs.py b/rhodecode/tests/lib/middleware/test_vcs.py --- a/rhodecode/tests/lib/middleware/test_vcs.py +++ b/rhodecode/tests/lib/middleware/test_vcs.py @@ -48,6 +48,7 @@ def test_is_hg_no_cmd(): def test_is_hg_empty_cmd(): environ = { + 'REQUEST_METHOD': 'GET', 'PATH_INFO': svn_repo_path, 'QUERY_STRING': 'cmd=', 'HTTP_ACCEPT': 'application/mercurial' @@ -57,6 +58,7 @@ def test_is_hg_empty_cmd(): def test_is_svn_returns_true_if_subversion_is_in_a_dav_header(): environ = { + 'REQUEST_METHOD': 'GET', 'PATH_INFO': svn_repo_path, 'HTTP_DAV': 'http://subversion.tigris.org/xmlns/dav/svn/log-revprops' } @@ -65,6 +67,7 @@ def test_is_svn_returns_true_if_subversi def test_is_svn_returns_false_if_subversion_is_not_in_a_dav_header(): environ = { + 'REQUEST_METHOD': 'GET', 'PATH_INFO': svn_repo_path, 'HTTP_DAV': 'http://stuff.tigris.org/xmlns/dav/svn/log-revprops' } @@ -73,6 +76,7 @@ def test_is_svn_returns_false_if_subvers def test_is_svn_returns_false_if_no_dav_header(): environ = { + 'REQUEST_METHOD': 'GET', 'PATH_INFO': svn_repo_path, } assert vcs.is_svn(environ) is False @@ -85,6 +89,14 @@ def test_is_svn_returns_true_if_magic_pa assert vcs.is_svn(environ) +def test_is_svn_returns_true_if_propfind(): + environ = { + 'REQUEST_METHOD': 'PROPFIND', + 'PATH_INFO': svn_repo_path, + } + assert vcs.is_svn(environ) is True + + def test_is_svn_allows_to_configure_the_magic_path(monkeypatch): """ This is intended as a fallback in case someone has configured his @@ -93,6 +105,7 @@ def test_is_svn_allows_to_configure_the_ monkeypatch.setitem( rhodecode.CONFIG, 'rhodecode_subversion_magic_path', '/!my-magic') environ = { + 'REQUEST_METHOD': 'POST', 'PATH_INFO': '/stub-repository/!my-magic/rev/4', } assert vcs.is_svn(environ)