##// END OF EJS Templates
vcs: also register a global config for vcs_handler....
marcink -
r2404:b82a3082 default
parent child Browse files
Show More
@@ -34,6 +34,7 b' from paste.httpheaders import REMOTE_USE'
34 34 # TODO(marcink): check if we should use webob.exc here ?
35 35 from pyramid.httpexceptions import (
36 36 HTTPNotFound, HTTPForbidden, HTTPNotAcceptable, HTTPInternalServerError)
37 from zope.cachedescriptors.property import Lazy as LazyProperty
37 38
38 39 import rhodecode
39 40 from rhodecode.authentication.base import (
@@ -121,12 +122,28 b' class SimpleVCS(object):'
121 122 auth_ret_code_detection)
122 123 self.ip_addr = '0.0.0.0'
123 124
125 @LazyProperty
126 def global_vcs_config(self):
127 try:
128 return VcsSettingsModel().get_ui_settings_as_config_obj()
129 except Exception:
130 return base.Config()
131
124 132 @property
125 133 def base_path(self):
126 settings_path = self.repo_vcs_config.get(*VcsSettingsModel.PATH_SETTING)
134 settings_path = self.repo_vcs_config.get(
135 *VcsSettingsModel.PATH_SETTING)
136
137 if not settings_path:
138 settings_path = self.global_vcs_config.get(
139 *VcsSettingsModel.PATH_SETTING)
140
127 141 if not settings_path:
128 142 # try, maybe we passed in explicitly as config option
129 143 settings_path = self.config.get('base_path')
144
145 if not settings_path:
146 raise ValueError('FATAL: base_path is empty')
130 147 return settings_path
131 148
132 149 def set_repo_names(self, environ):
@@ -48,6 +48,7 b' def test_is_hg_no_cmd():'
48 48
49 49 def test_is_hg_empty_cmd():
50 50 environ = {
51 'REQUEST_METHOD': 'GET',
51 52 'PATH_INFO': svn_repo_path,
52 53 'QUERY_STRING': 'cmd=',
53 54 'HTTP_ACCEPT': 'application/mercurial'
@@ -57,6 +58,7 b' def test_is_hg_empty_cmd():'
57 58
58 59 def test_is_svn_returns_true_if_subversion_is_in_a_dav_header():
59 60 environ = {
61 'REQUEST_METHOD': 'GET',
60 62 'PATH_INFO': svn_repo_path,
61 63 'HTTP_DAV': 'http://subversion.tigris.org/xmlns/dav/svn/log-revprops'
62 64 }
@@ -65,6 +67,7 b' def test_is_svn_returns_true_if_subversi'
65 67
66 68 def test_is_svn_returns_false_if_subversion_is_not_in_a_dav_header():
67 69 environ = {
70 'REQUEST_METHOD': 'GET',
68 71 'PATH_INFO': svn_repo_path,
69 72 'HTTP_DAV': 'http://stuff.tigris.org/xmlns/dav/svn/log-revprops'
70 73 }
@@ -73,6 +76,7 b' def test_is_svn_returns_false_if_subvers'
73 76
74 77 def test_is_svn_returns_false_if_no_dav_header():
75 78 environ = {
79 'REQUEST_METHOD': 'GET',
76 80 'PATH_INFO': svn_repo_path,
77 81 }
78 82 assert vcs.is_svn(environ) is False
@@ -85,6 +89,14 b' def test_is_svn_returns_true_if_magic_pa'
85 89 assert vcs.is_svn(environ)
86 90
87 91
92 def test_is_svn_returns_true_if_propfind():
93 environ = {
94 'REQUEST_METHOD': 'PROPFIND',
95 'PATH_INFO': svn_repo_path,
96 }
97 assert vcs.is_svn(environ) is True
98
99
88 100 def test_is_svn_allows_to_configure_the_magic_path(monkeypatch):
89 101 """
90 102 This is intended as a fallback in case someone has configured his
@@ -93,6 +105,7 b' def test_is_svn_allows_to_configure_the_'
93 105 monkeypatch.setitem(
94 106 rhodecode.CONFIG, 'rhodecode_subversion_magic_path', '/!my-magic')
95 107 environ = {
108 'REQUEST_METHOD': 'POST',
96 109 'PATH_INFO': '/stub-repository/!my-magic/rev/4',
97 110 }
98 111 assert vcs.is_svn(environ)
General Comments 0
You need to be logged in to leave comments. Login now