Show More
@@ -30,7 +30,7 b' from vcsserver.lib.exc_tracking import f' | |||||
30 | log = logging.getLogger(__name__) |
|
30 | log = logging.getLogger(__name__) | |
31 |
|
31 | |||
32 |
|
32 | |||
33 |
class RepoFactory |
|
33 | class RepoFactory: | |
34 | """ |
|
34 | """ | |
35 | Utility to create instances of repository |
|
35 | Utility to create instances of repository | |
36 |
|
36 | |||
@@ -84,7 +84,7 b' def raise_from_original(new_type, org_ex' | |||||
84 | del exc_traceback |
|
84 | del exc_traceback | |
85 |
|
85 | |||
86 |
|
86 | |||
87 |
class ArchiveNode |
|
87 | class ArchiveNode: | |
88 | def __init__(self, path, mode, is_link, raw_bytes): |
|
88 | def __init__(self, path, mode, is_link, raw_bytes): | |
89 | self.path = path |
|
89 | self.path = path | |
90 | self.mode = mode |
|
90 | self.mode = mode | |
@@ -176,7 +176,7 b' def store_archive_in_cache(node_walker, ' | |||||
176 | return reader.name |
|
176 | return reader.name | |
177 |
|
177 | |||
178 |
|
178 | |||
179 |
class BinaryEnvelope |
|
179 | class BinaryEnvelope: | |
180 | def __init__(self, val): |
|
180 | def __init__(self, val): | |
181 | self.val = val |
|
181 | self.val = val | |
182 |
|
182 |
@@ -34,7 +34,7 b' set_keys = {' | |||||
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 |
|
36 | |||
37 |
class SettingsMaker |
|
37 | class SettingsMaker: | |
38 |
|
38 | |||
39 | def __init__(self, app_settings): |
|
39 | def __init__(self, app_settings): | |
40 | self.settings = app_settings |
|
40 | self.settings = app_settings |
@@ -12,7 +12,7 b' import logging' | |||||
12 | log = logging.getLogger(__name__) |
|
12 | log = logging.getLogger(__name__) | |
13 |
|
13 | |||
14 |
|
14 | |||
15 |
class EchoApp |
|
15 | class EchoApp: | |
16 |
|
16 | |||
17 | def __init__(self, repo_path, repo_name, config): |
|
17 | def __init__(self, repo_path, repo_name, config): | |
18 | self._repo_path = repo_path |
|
18 | self._repo_path = repo_path | |
@@ -28,7 +28,7 b' class EchoApp(object):' | |||||
28 | return [b"ECHO"] |
|
28 | return [b"ECHO"] | |
29 |
|
29 | |||
30 |
|
30 | |||
31 |
class EchoAppStream |
|
31 | class EchoAppStream: | |
32 |
|
32 | |||
33 | def __init__(self, repo_path, repo_name, config): |
|
33 | def __init__(self, repo_path, repo_name, config): | |
34 | self._repo_path = repo_path |
|
34 | self._repo_path = repo_path |
@@ -15,7 +15,7 b' from vcsserver import wsgi_app_caller' | |||||
15 | log = logging.getLogger(__name__) |
|
15 | log = logging.getLogger(__name__) | |
16 |
|
16 | |||
17 |
|
17 | |||
18 |
class GitRemoteWsgi |
|
18 | class GitRemoteWsgi: | |
19 | def handle(self, environ, input_data, *args, **kwargs): |
|
19 | def handle(self, environ, input_data, *args, **kwargs): | |
20 | app = wsgi_app_caller.WSGIAppCaller( |
|
20 | app = wsgi_app_caller.WSGIAppCaller( | |
21 | create_echo_wsgi_app(*args, **kwargs)) |
|
21 | create_echo_wsgi_app(*args, **kwargs)) | |
@@ -23,7 +23,7 b' class GitRemoteWsgi(object):' | |||||
23 | return app.handle(environ, input_data) |
|
23 | return app.handle(environ, input_data) | |
24 |
|
24 | |||
25 |
|
25 | |||
26 |
class HgRemoteWsgi |
|
26 | class HgRemoteWsgi: | |
27 | def handle(self, environ, input_data, *args, **kwargs): |
|
27 | def handle(self, environ, input_data, *args, **kwargs): | |
28 | app = wsgi_app_caller.WSGIAppCaller( |
|
28 | app = wsgi_app_caller.WSGIAppCaller( | |
29 | create_echo_wsgi_app(*args, **kwargs)) |
|
29 | create_echo_wsgi_app(*args, **kwargs)) |
@@ -47,7 +47,7 b' def write_response_error(http_exception,' | |||||
47 | return _exception |
|
47 | return _exception | |
48 |
|
48 | |||
49 |
|
49 | |||
50 |
class AuthHeaderRequired |
|
50 | class AuthHeaderRequired: | |
51 | """ |
|
51 | """ | |
52 | Decorator to check if request has proper auth-header |
|
52 | Decorator to check if request has proper auth-header | |
53 | """ |
|
53 | """ | |
@@ -94,7 +94,7 b' def lfs_objects_batch(request):' | |||||
94 | if operation not in ('download', 'upload'): |
|
94 | if operation not in ('download', 'upload'): | |
95 | log.debug('LFS: unsupported operation:%s', operation) |
|
95 | log.debug('LFS: unsupported operation:%s', operation) | |
96 | return write_response_error( |
|
96 | return write_response_error( | |
97 |
HTTPBadRequest, 'unsupported operation mode: ` |
|
97 | HTTPBadRequest, f'unsupported operation mode: `{operation}`') | |
98 |
|
98 | |||
99 | if 'objects' not in data: |
|
99 | if 'objects' not in data: | |
100 | log.debug('LFS: missing objects data') |
|
100 | log.debug('LFS: missing objects data') | |
@@ -178,7 +178,7 b' def lfs_objects_oid_download(request):' | |||||
178 | if not store.has_oid(): |
|
178 | if not store.has_oid(): | |
179 | log.debug('LFS: oid %s does not exists in store', oid) |
|
179 | log.debug('LFS: oid %s does not exists in store', oid) | |
180 | return write_response_error( |
|
180 | return write_response_error( | |
181 |
HTTPNotFound, 'requested file with oid ` |
|
181 | HTTPNotFound, f'requested file with oid `{oid}` not found in store') | |
182 |
|
182 | |||
183 | # TODO(marcink): support range header ? |
|
183 | # TODO(marcink): support range header ? | |
184 | # Range: bytes=0-, `bytes=(\d+)\-.*` |
|
184 | # Range: bytes=0-, `bytes=(\d+)\-.*` | |
@@ -207,7 +207,7 b' def lfs_objects_verify(request):' | |||||
207 | if not store.has_oid(): |
|
207 | if not store.has_oid(): | |
208 | log.debug('LFS: oid %s does not exists in store', oid) |
|
208 | log.debug('LFS: oid %s does not exists in store', oid) | |
209 | return write_response_error( |
|
209 | return write_response_error( | |
210 |
HTTPNotFound, 'oid ` |
|
210 | HTTPNotFound, f'oid `{oid}` does not exists in store') | |
211 |
|
211 | |||
212 | store_size = store.size_oid() |
|
212 | store_size = store.size_oid() | |
213 | if store_size != size: |
|
213 | if store_size != size: |
@@ -23,7 +23,7 b' from collections import OrderedDict' | |||||
23 | log = logging.getLogger(__name__) |
|
23 | log = logging.getLogger(__name__) | |
24 |
|
24 | |||
25 |
|
25 | |||
26 |
class OidHandler |
|
26 | class OidHandler: | |
27 |
|
27 | |||
28 | def __init__(self, store, repo_name, auth, oid, obj_size, obj_data, obj_href, |
|
28 | def __init__(self, store, repo_name, auth, oid, obj_size, obj_data, obj_href, | |
29 | obj_verify_href=None): |
|
29 | obj_verify_href=None): | |
@@ -113,7 +113,7 b' class OidHandler(object):' | |||||
113 | return handler(*args, **kwargs) |
|
113 | return handler(*args, **kwargs) | |
114 |
|
114 | |||
115 |
|
115 | |||
116 |
class LFSOidStore |
|
116 | class LFSOidStore: | |
117 |
|
117 | |||
118 | def __init__(self, oid, repo, store_location=None): |
|
118 | def __init__(self, oid, repo, store_location=None): | |
119 | self.oid = oid |
|
119 | self.oid = oid |
@@ -47,7 +47,7 b' def http_auth():' | |||||
47 | return {'HTTP_AUTHORIZATION': "Basic XXXXX"} |
|
47 | return {'HTTP_AUTHORIZATION': "Basic XXXXX"} | |
48 |
|
48 | |||
49 |
|
49 | |||
50 |
class TestLFSApplication |
|
50 | class TestLFSApplication: | |
51 |
|
51 | |||
52 | def test_app_wrong_path(self, git_lfs_app): |
|
52 | def test_app_wrong_path(self, git_lfs_app): | |
53 | git_lfs_app.get('/repo/info/lfs/xxx', status=404) |
|
53 | git_lfs_app.get('/repo/info/lfs/xxx', status=404) |
@@ -43,7 +43,7 b' def oid_handler(lfs_store):' | |||||
43 | return oid_handler |
|
43 | return oid_handler | |
44 |
|
44 | |||
45 |
|
45 | |||
46 |
class TestOidHandler |
|
46 | class TestOidHandler: | |
47 |
|
47 | |||
48 | @pytest.mark.parametrize('exec_action', [ |
|
48 | @pytest.mark.parametrize('exec_action', [ | |
49 | 'download', |
|
49 | 'download', | |
@@ -120,7 +120,7 b' class TestOidHandler(object):' | |||||
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 |
|
122 | |||
123 |
class TestLFSStore |
|
123 | class TestLFSStore: | |
124 | def test_write_oid(self, lfs_store): |
|
124 | def test_write_oid(self, lfs_store): | |
125 | oid_location = lfs_store.oid_path |
|
125 | oid_location = lfs_store.oid_path | |
126 |
|
126 |
@@ -62,7 +62,7 b' def install_git_hooks(repo_path, bare, e' | |||||
62 |
|
62 | |||
63 | for h_type, template in [('pre', tmpl_pre), ('post', tmpl_post)]: |
|
63 | for h_type, template in [('pre', tmpl_pre), ('post', tmpl_post)]: | |
64 | log.debug('Installing git hook in repo %s', repo_path) |
|
64 | log.debug('Installing git hook in repo %s', repo_path) | |
65 |
_hook_file = os.path.join(hooks_path, ' |
|
65 | _hook_file = os.path.join(hooks_path, f'{h_type}-receive') | |
66 | _rhodecode_hook = check_rhodecode_hook(_hook_file) |
|
66 | _rhodecode_hook = check_rhodecode_hook(_hook_file) | |
67 |
|
67 | |||
68 | if _rhodecode_hook or force_create: |
|
68 | if _rhodecode_hook or force_create: | |
@@ -114,7 +114,7 b' def install_svn_hooks(repo_path, executa' | |||||
114 |
|
114 | |||
115 | for h_type, template in [('pre', tmpl_pre), ('post', tmpl_post)]: |
|
115 | for h_type, template in [('pre', tmpl_pre), ('post', tmpl_post)]: | |
116 | log.debug('Installing svn hook in repo %s', repo_path) |
|
116 | log.debug('Installing svn hook in repo %s', repo_path) | |
117 |
_hook_file = os.path.join(hooks_path, ' |
|
117 | _hook_file = os.path.join(hooks_path, f'{h_type}-commit') | |
118 | _rhodecode_hook = check_rhodecode_hook(_hook_file) |
|
118 | _rhodecode_hook = check_rhodecode_hook(_hook_file) | |
119 |
|
119 | |||
120 | if _rhodecode_hook or force_create: |
|
120 | if _rhodecode_hook or force_create: |
@@ -40,7 +40,7 b' from vcsserver.remote.git_remote import ' | |||||
40 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
41 |
|
41 | |||
42 |
|
42 | |||
43 |
class HooksHttpClient |
|
43 | class HooksHttpClient: | |
44 | proto = 'msgpack.v1' |
|
44 | proto = 'msgpack.v1' | |
45 | connection = None |
|
45 | connection = None | |
46 |
|
46 | |||
@@ -88,7 +88,7 b' class HooksHttpClient(object):' | |||||
88 | return headers, msgpack.packb(data) |
|
88 | return headers, msgpack.packb(data) | |
89 |
|
89 | |||
90 |
|
90 | |||
91 |
class HooksDummyClient |
|
91 | class HooksDummyClient: | |
92 | def __init__(self, hooks_module): |
|
92 | def __init__(self, hooks_module): | |
93 | self._hooks_module = importlib.import_module(hooks_module) |
|
93 | self._hooks_module = importlib.import_module(hooks_module) | |
94 |
|
94 | |||
@@ -97,13 +97,13 b' class HooksDummyClient(object):' | |||||
97 | return getattr(hooks, hook_name)(extras) |
|
97 | return getattr(hooks, hook_name)(extras) | |
98 |
|
98 | |||
99 |
|
99 | |||
100 |
class HooksShadowRepoClient |
|
100 | class HooksShadowRepoClient: | |
101 |
|
101 | |||
102 | def __call__(self, hook_name, extras): |
|
102 | def __call__(self, hook_name, extras): | |
103 | return {'output': '', 'status': 0} |
|
103 | return {'output': '', 'status': 0} | |
104 |
|
104 | |||
105 |
|
105 | |||
106 |
class RemoteMessageWriter |
|
106 | class RemoteMessageWriter: | |
107 | """Writer base class.""" |
|
107 | """Writer base class.""" | |
108 | def write(self, message): |
|
108 | def write(self, message): | |
109 | raise NotImplementedError() |
|
109 | raise NotImplementedError() | |
@@ -627,7 +627,7 b' def git_post_receive(unused_repo_path, r' | |||||
627 |
|
627 | |||
628 | # delete branch case |
|
628 | # delete branch case | |
629 | elif push_ref['new_rev'] == empty_commit_id: |
|
629 | elif push_ref['new_rev'] == empty_commit_id: | |
630 |
git_revs.append('delete_branch=> |
|
630 | git_revs.append(f'delete_branch=>{push_ref["name"]}') | |
631 | else: |
|
631 | else: | |
632 | if push_ref['name'] not in branches: |
|
632 | if push_ref['name'] not in branches: | |
633 | branches.append(push_ref['name']) |
|
633 | branches.append(push_ref['name']) | |
@@ -659,7 +659,7 b' def git_post_receive(unused_repo_path, r' | |||||
659 | elif type_ == 'tags': |
|
659 | elif type_ == 'tags': | |
660 | if push_ref['name'] not in tags: |
|
660 | if push_ref['name'] not in tags: | |
661 | tags.append(push_ref['name']) |
|
661 | tags.append(push_ref['name']) | |
662 |
git_revs.append('tag=> |
|
662 | git_revs.append(f'tag=>{push_ref["name"]}') | |
663 |
|
663 | |||
664 | extras['hook_type'] = 'post_receive' |
|
664 | extras['hook_type'] = 'post_receive' | |
665 | extras['commit_ids'] = git_revs |
|
665 | extras['commit_ids'] = git_revs |
@@ -112,7 +112,7 b' def log_max_fd():' | |||||
112 | pass |
|
112 | pass | |
113 |
|
113 | |||
114 |
|
114 | |||
115 |
class VCS |
|
115 | class VCS: | |
116 | def __init__(self, locale_conf=None, cache_config=None): |
|
116 | def __init__(self, locale_conf=None, cache_config=None): | |
117 | self.locale = locale_conf |
|
117 | self.locale = locale_conf | |
118 | self.cache_config = cache_config |
|
118 | self.cache_config = cache_config | |
@@ -162,7 +162,7 b' class VCS(object):' | |||||
162 | log.exception('Cannot set locale, not configuring the locale system') |
|
162 | log.exception('Cannot set locale, not configuring the locale system') | |
163 |
|
163 | |||
164 |
|
164 | |||
165 |
class WsgiProxy |
|
165 | class WsgiProxy: | |
166 | def __init__(self, wsgi): |
|
166 | def __init__(self, wsgi): | |
167 | self.wsgi = wsgi |
|
167 | self.wsgi = wsgi | |
168 |
|
168 | |||
@@ -200,7 +200,7 b' def not_found(request):' | |||||
200 | return {'status': '404 NOT FOUND'} |
|
200 | return {'status': '404 NOT FOUND'} | |
201 |
|
201 | |||
202 |
|
202 | |||
203 |
class VCSViewPredicate |
|
203 | class VCSViewPredicate: | |
204 | def __init__(self, val, config): |
|
204 | def __init__(self, val, config): | |
205 | self.remotes = val |
|
205 | self.remotes = val | |
206 |
|
206 | |||
@@ -218,7 +218,7 b' class VCSViewPredicate(object):' | |||||
218 | return backend in self.remotes |
|
218 | return backend in self.remotes | |
219 |
|
219 | |||
220 |
|
220 | |||
221 |
class HTTPApplication |
|
221 | class HTTPApplication: | |
222 | ALLOWED_EXCEPTIONS = ('KeyError', 'URLError') |
|
222 | ALLOWED_EXCEPTIONS = ('KeyError', 'URLError') | |
223 |
|
223 | |||
224 | remote_wsgi = remote_wsgi |
|
224 | remote_wsgi = remote_wsgi | |
@@ -684,7 +684,7 b' class HTTPApplication(object):' | |||||
684 | raise exception |
|
684 | raise exception | |
685 |
|
685 | |||
686 |
|
686 | |||
687 |
class ResponseFilter |
|
687 | class ResponseFilter: | |
688 |
|
688 | |||
689 | def __init__(self, start_response): |
|
689 | def __init__(self, start_response): | |
690 | self._start_response = start_response |
|
690 | self._start_response = start_response |
@@ -102,7 +102,7 b' class NotExpirable(RuntimeError):' | |||||
102 | pass |
|
102 | pass | |
103 |
|
103 | |||
104 |
|
104 | |||
105 |
class Lock |
|
105 | class Lock: | |
106 | """ |
|
106 | """ | |
107 | A Lock context manager implemented via redis SETNX/BLPOP. |
|
107 | A Lock context manager implemented via redis SETNX/BLPOP. | |
108 | """ |
|
108 | """ |
@@ -29,7 +29,7 b' def normalize_tags(tag_list):' | |||||
29 | return _normalize_tags_with_cache(tuple(tag_list)) |
|
29 | return _normalize_tags_with_cache(tuple(tag_list)) | |
30 |
|
30 | |||
31 |
|
31 | |||
32 |
class StatsClientBase |
|
32 | class StatsClientBase: | |
33 | """A Base class for various statsd clients.""" |
|
33 | """A Base class for various statsd clients.""" | |
34 |
|
34 | |||
35 | def close(self): |
|
35 | def close(self): |
@@ -9,7 +9,7 b' def safe_wraps(wrapper, *args, **kwargs)' | |||||
9 | return functools.wraps(wrapper, *args, **kwargs) |
|
9 | return functools.wraps(wrapper, *args, **kwargs) | |
10 |
|
10 | |||
11 |
|
11 | |||
12 |
class Timer |
|
12 | class Timer: | |
13 | """A context manager/decorator for statsd.timing().""" |
|
13 | """A context manager/decorator for statsd.timing().""" | |
14 |
|
14 | |||
15 | def __init__(self, client, stat, rate=1, tags=None, use_decimals=True, auto_send=True): |
|
15 | def __init__(self, client, stat, rate=1, tags=None, use_decimals=True, auto_send=True): |
@@ -87,7 +87,7 b' class PickleSerializer:' | |||||
87 | ) |
|
87 | ) | |
88 |
|
88 | |||
89 |
|
89 | |||
90 |
class MsgPackSerializer |
|
90 | class MsgPackSerializer: | |
91 | serializer: None | Serializer = staticmethod( # type: ignore |
|
91 | serializer: None | Serializer = staticmethod( # type: ignore | |
92 | msgpack.packb |
|
92 | msgpack.packb | |
93 | ) |
|
93 | ) | |
@@ -223,7 +223,7 b' class RedisMsgPackBackend(MsgPackSeriali' | |||||
223 | def get_mutex_lock(client, lock_key, lock_timeout, auto_renewal=False): |
|
223 | def get_mutex_lock(client, lock_key, lock_timeout, auto_renewal=False): | |
224 | from vcsserver.lib._vendor import redis_lock |
|
224 | from vcsserver.lib._vendor import redis_lock | |
225 |
|
225 | |||
226 |
class _RedisLockWrapper |
|
226 | class _RedisLockWrapper: | |
227 | """LockWrapper for redis_lock""" |
|
227 | """LockWrapper for redis_lock""" | |
228 |
|
228 | |||
229 | @classmethod |
|
229 | @classmethod |
@@ -95,7 +95,7 b' def _create_auth_baton(pool):' | |||||
95 | return core.svn_auth_open(providers, pool) |
|
95 | return core.svn_auth_open(providers, pool) | |
96 |
|
96 | |||
97 |
|
97 | |||
98 |
class SubversionRepo |
|
98 | class SubversionRepo: | |
99 | """Wrapper for a Subversion repository. |
|
99 | """Wrapper for a Subversion repository. | |
100 |
|
100 | |||
101 | It uses the SWIG Python bindings, see above for requirements. |
|
101 | It uses the SWIG Python bindings, see above for requirements. | |
@@ -145,7 +145,7 b' class SubversionRepo(object):' | |||||
145 | raise SubversionConnectionException(msg) |
|
145 | raise SubversionConnectionException(msg) | |
146 |
|
146 | |||
147 |
|
147 | |||
148 |
class svnremoterepo |
|
148 | class svnremoterepo: | |
149 | """ the dumb wrapper for actual Subversion repositories """ |
|
149 | """ the dumb wrapper for actual Subversion repositories """ | |
150 |
|
150 | |||
151 | def __init__(self, username: bytes = b'', password: bytes = b'', svn_url: bytes = b''): |
|
151 | def __init__(self, username: bytes = b'', password: bytes = b'', svn_url: bytes = b''): |
@@ -33,7 +33,7 b' from vcsserver.str_utils import ascii_by' | |||||
33 | log = logging.getLogger(__name__) |
|
33 | log = logging.getLogger(__name__) | |
34 |
|
34 | |||
35 |
|
35 | |||
36 |
class FileWrapper |
|
36 | class FileWrapper: | |
37 | """File wrapper that ensures how much data is read from it.""" |
|
37 | """File wrapper that ensures how much data is read from it.""" | |
38 |
|
38 | |||
39 | def __init__(self, fd, content_length): |
|
39 | def __init__(self, fd, content_length): | |
@@ -61,7 +61,7 b' class FileWrapper(object):' | |||||
61 | ) |
|
61 | ) | |
62 |
|
62 | |||
63 |
|
63 | |||
64 |
class GitRepository |
|
64 | class GitRepository: | |
65 | """WSGI app for handling Git smart protocol endpoints.""" |
|
65 | """WSGI app for handling Git smart protocol endpoints.""" | |
66 |
|
66 | |||
67 | git_folder_signature = frozenset(('config', 'head', 'info', 'objects', 'refs')) |
|
67 | git_folder_signature = frozenset(('config', 'head', 'info', 'objects', 'refs')) |
@@ -482,7 +482,7 b' class GitRemote(RemoteBase):' | |||||
482 | o.addheaders = [('User-Agent', 'git/1.7.8.0')] # fake some git |
|
482 | o.addheaders = [('User-Agent', 'git/1.7.8.0')] # fake some git | |
483 |
|
483 | |||
484 | q = {"service": 'git-upload-pack'} |
|
484 | q = {"service": 'git-upload-pack'} | |
485 |
qs = '? |
|
485 | qs = f'?{urllib.parse.urlencode(q)}' | |
486 | cu = f"{test_uri}{qs}" |
|
486 | cu = f"{test_uri}{qs}" | |
487 | req = urllib.request.Request(cu, None, {}) |
|
487 | req = urllib.request.Request(cu, None, {}) | |
488 |
|
488 | |||
@@ -507,8 +507,7 b' class GitRemote(RemoteBase):' | |||||
507 | else: |
|
507 | else: | |
508 | e = None |
|
508 | e = None | |
509 | raise exceptions.URLError(e)( |
|
509 | raise exceptions.URLError(e)( | |
510 |
"url [ |
|
510 | f"url [{obfuscated_uri}] does not look like an hg repo org_exc: {e}") | |
511 | % (obfuscated_uri, e)) |
|
|||
512 |
|
511 | |||
513 | return True |
|
512 | return True | |
514 |
|
513 | |||
@@ -1184,7 +1183,7 b' class GitRemote(RemoteBase):' | |||||
1184 | """ |
|
1183 | """ | |
1185 |
|
1184 | |||
1186 | flags = [ |
|
1185 | flags = [ | |
1187 |
'-U |
|
1186 | f'-U{context}', '--patch', | |
1188 | '--binary', |
|
1187 | '--binary', | |
1189 | '--find-renames', |
|
1188 | '--find-renames', | |
1190 | '--no-indent-heuristic', |
|
1189 | '--no-indent-heuristic', |
@@ -333,7 +333,7 b' class HgRemote(RemoteBase):' | |||||
333 | result[attr] = method(wire, commit_id) |
|
333 | result[attr] = method(wire, commit_id) | |
334 | except KeyError as e: |
|
334 | except KeyError as e: | |
335 | raise exceptions.VcsException(e)( |
|
335 | raise exceptions.VcsException(e)( | |
336 |
'Unknown bulk attribute: " |
|
336 | f'Unknown bulk attribute: "{attr}"') | |
337 | return result |
|
337 | return result | |
338 |
|
338 | |||
339 | return _bulk_request(repo_id, commit_id, sorted(pre_load)) |
|
339 | return _bulk_request(repo_id, commit_id, sorted(pre_load)) | |
@@ -499,7 +499,7 b' class HgRemote(RemoteBase):' | |||||
499 |
|
499 | |||
500 | q = {"cmd": 'between'} |
|
500 | q = {"cmd": 'between'} | |
501 | q.update({'pairs': "{}-{}".format('0' * 40, '0' * 40)}) |
|
501 | q.update({'pairs': "{}-{}".format('0' * 40, '0' * 40)}) | |
502 |
qs = '? |
|
502 | qs = f'?{urllib.parse.urlencode(q)}' | |
503 | cu = f"{test_uri}{qs}" |
|
503 | cu = f"{test_uri}{qs}" | |
504 | req = urllib.request.Request(cu, None, {}) |
|
504 | req = urllib.request.Request(cu, None, {}) | |
505 |
|
505 | |||
@@ -528,8 +528,7 b' class HgRemote(RemoteBase):' | |||||
528 | log.warning("URL is not a valid Mercurial repository: %s", |
|
528 | log.warning("URL is not a valid Mercurial repository: %s", | |
529 | obfuscated_uri) |
|
529 | obfuscated_uri) | |
530 | raise exceptions.URLError(e)( |
|
530 | raise exceptions.URLError(e)( | |
531 |
"url [ |
|
531 | f"url [{obfuscated_uri}] does not look like an hg repo org_exc: {e}") | |
532 | % (obfuscated_uri, e)) |
|
|||
533 |
|
532 | |||
534 | log.info("URL is a valid Mercurial repository: %s", obfuscated_uri) |
|
533 | log.info("URL is a valid Mercurial repository: %s", obfuscated_uri) | |
535 | return True |
|
534 | return True |
@@ -203,7 +203,7 b' class SvnRemote(RemoteBase):' | |||||
203 | repo_path = wire['path'] |
|
203 | repo_path = wire['path'] | |
204 | if not self.is_path_valid_repository(wire, repo_path): |
|
204 | if not self.is_path_valid_repository(wire, repo_path): | |
205 | raise Exception( |
|
205 | raise Exception( | |
206 |
"Path |
|
206 | f"Path {repo_path} is not a valid Subversion repository.") | |
207 |
|
207 | |||
208 | cmd = ['svnadmin', 'info', repo_path] |
|
208 | cmd = ['svnadmin', 'info', repo_path] | |
209 | stdout, stderr = subprocessio.run_command(cmd) |
|
209 | stdout, stderr = subprocessio.run_command(cmd) | |
@@ -439,7 +439,7 b' class SvnRemote(RemoteBase):' | |||||
439 | repo_path = wire['path'] |
|
439 | repo_path = wire['path'] | |
440 | if not self.is_path_valid_repository(wire, repo_path): |
|
440 | if not self.is_path_valid_repository(wire, repo_path): | |
441 | raise Exception( |
|
441 | raise Exception( | |
442 |
"Path |
|
442 | f"Path {repo_path} is not a valid Subversion repository.") | |
443 |
|
443 | |||
444 | username, password, src_url = self.get_url_and_credentials(src_url) |
|
444 | username, password, src_url = self.get_url_and_credentials(src_url) | |
445 | rdump_cmd = ['svnrdump', 'dump', '--non-interactive', |
|
445 | rdump_cmd = ['svnrdump', 'dump', '--non-interactive', | |
@@ -477,8 +477,7 b' class SvnRemote(RemoteBase):' | |||||
477 | src_url, reason)) |
|
477 | src_url, reason)) | |
478 | if load.returncode != 0: |
|
478 | if load.returncode != 0: | |
479 | raise Exception( |
|
479 | raise Exception( | |
480 |
'Failed to load the dump of remote repository from |
|
480 | f'Failed to load the dump of remote repository from {src_url}.') | |
481 | (src_url, )) |
|
|||
482 |
|
481 | |||
483 | def commit(self, wire, message, author, timestamp, updated, removed): |
|
482 | def commit(self, wire, message, author, timestamp, updated, removed): | |
484 |
|
483 | |||
@@ -673,7 +672,7 b' class SvnRemote(RemoteBase):' | |||||
673 | file_walker, archive_name_key, kind, mtime, archive_at_path, archive_dir_name, commit_id, cache_config=cache_config) |
|
672 | file_walker, archive_name_key, kind, mtime, archive_at_path, archive_dir_name, commit_id, cache_config=cache_config) | |
674 |
|
673 | |||
675 |
|
674 | |||
676 |
class SvnDiffer |
|
675 | class SvnDiffer: | |
677 | """ |
|
676 | """ | |
678 | Utility to create diffs based on difflib and the Subversion api |
|
677 | Utility to create diffs based on difflib and the Subversion api | |
679 | """ |
|
678 | """ | |
@@ -865,7 +864,7 b' def authorization_callback_allow_all(roo' | |||||
865 | return True |
|
864 | return True | |
866 |
|
865 | |||
867 |
|
866 | |||
868 |
class TxnNodeProcessor |
|
867 | class TxnNodeProcessor: | |
869 | """ |
|
868 | """ | |
870 | Utility to process the change of one node within a transaction root. |
|
869 | Utility to process the change of one node within a transaction root. | |
871 |
|
870 |
@@ -18,7 +18,7 b'' | |||||
18 | from vcsserver import scm_app, wsgi_app_caller |
|
18 | from vcsserver import scm_app, wsgi_app_caller | |
19 |
|
19 | |||
20 |
|
20 | |||
21 |
class GitRemoteWsgi |
|
21 | class GitRemoteWsgi: | |
22 | def handle(self, environ, input_data, *args, **kwargs): |
|
22 | def handle(self, environ, input_data, *args, **kwargs): | |
23 | app = wsgi_app_caller.WSGIAppCaller( |
|
23 | app = wsgi_app_caller.WSGIAppCaller( | |
24 | scm_app.create_git_wsgi_app(*args, **kwargs)) |
|
24 | scm_app.create_git_wsgi_app(*args, **kwargs)) | |
@@ -26,7 +26,7 b' class GitRemoteWsgi(object):' | |||||
26 | return app.handle(environ, input_data) |
|
26 | return app.handle(environ, input_data) | |
27 |
|
27 | |||
28 |
|
28 | |||
29 |
class HgRemoteWsgi |
|
29 | class HgRemoteWsgi: | |
30 | def handle(self, environ, input_data, *args, **kwargs): |
|
30 | def handle(self, environ, input_data, *args, **kwargs): | |
31 | app = wsgi_app_caller.WSGIAppCaller( |
|
31 | app = wsgi_app_caller.WSGIAppCaller( | |
32 | scm_app.create_hg_wsgi_app(*args, **kwargs)) |
|
32 | scm_app.create_hg_wsgi_app(*args, **kwargs)) |
@@ -163,7 +163,7 b' def create_hg_wsgi_app(repo_path, repo_n' | |||||
163 | raise exceptions.RequirementException(e)(e) |
|
163 | raise exceptions.RequirementException(e)(e) | |
164 |
|
164 | |||
165 |
|
165 | |||
166 |
class GitHandler |
|
166 | class GitHandler: | |
167 | """ |
|
167 | """ | |
168 | Handler for Git operations like push/pull etc |
|
168 | Handler for Git operations like push/pull etc | |
169 | """ |
|
169 | """ | |
@@ -209,7 +209,7 b' def create_git_wsgi_app(repo_path, repo_' | |||||
209 | return app |
|
209 | return app | |
210 |
|
210 | |||
211 |
|
211 | |||
212 |
class GitLFSHandler |
|
212 | class GitLFSHandler: | |
213 | """ |
|
213 | """ | |
214 | Handler for Git LFS operations |
|
214 | Handler for Git LFS operations | |
215 | """ |
|
215 | """ |
@@ -24,7 +24,7 b' import time' | |||||
24 | log = logging.getLogger(__name__) |
|
24 | log = logging.getLogger(__name__) | |
25 |
|
25 | |||
26 |
|
26 | |||
27 |
class VcsServer |
|
27 | class VcsServer: | |
28 | """ |
|
28 | """ | |
29 | Exposed remote interface of the vcsserver itself. |
|
29 | Exposed remote interface of the vcsserver itself. | |
30 |
|
30 |
@@ -152,7 +152,7 b' class InputStreamChunker(threading.Threa' | |||||
152 | da.set() # for cases when done but there was no input. |
|
152 | da.set() # for cases when done but there was no input. | |
153 |
|
153 | |||
154 |
|
154 | |||
155 |
class BufferedGenerator |
|
155 | class BufferedGenerator: | |
156 | """ |
|
156 | """ | |
157 | Class behaves as a non-blocking, buffered pipe reader. |
|
157 | Class behaves as a non-blocking, buffered pipe reader. | |
158 | Reads chunks of data (through a thread) |
|
158 | Reads chunks of data (through a thread) | |
@@ -294,7 +294,7 b' class BufferedGenerator(object):' | |||||
294 | return self.data_queue[i] |
|
294 | return self.data_queue[i] | |
295 |
|
295 | |||
296 |
|
296 | |||
297 |
class SubprocessIOChunker |
|
297 | class SubprocessIOChunker: | |
298 | """ |
|
298 | """ | |
299 | Processor class wrapping handling of subprocess IO. |
|
299 | Processor class wrapping handling of subprocess IO. | |
300 |
|
300 |
@@ -21,7 +21,7 b' import tempfile' | |||||
21 | import configparser |
|
21 | import configparser | |
22 |
|
22 | |||
23 |
|
23 | |||
24 |
class ContextINI |
|
24 | class ContextINI: | |
25 | """ |
|
25 | """ | |
26 | Allows to create a new test.ini file as a copy of existing one with edited |
|
26 | Allows to create a new test.ini file as a copy of existing one with edited | |
27 | data. If existing file is not present, it creates a new one. Example usage:: |
|
27 | data. If existing file is not present, it creates a new one. Example usage:: |
@@ -47,7 +47,7 b' def test_discover_git_version(git_remote' | |||||
47 | assert version |
|
47 | assert version | |
48 |
|
48 | |||
49 |
|
49 | |||
50 |
class TestGitFetch |
|
50 | class TestGitFetch: | |
51 | def setup_method(self): |
|
51 | def setup_method(self): | |
52 | self.mock_repo = Mock() |
|
52 | self.mock_repo = Mock() | |
53 | factory = Mock() |
|
53 | factory = Mock() | |
@@ -99,7 +99,7 b' class TestGitFetch(object):' | |||||
99 | assert remote_refs == sample_refs |
|
99 | assert remote_refs == sample_refs | |
100 |
|
100 | |||
101 |
|
101 | |||
102 |
class TestReraiseSafeExceptions |
|
102 | class TestReraiseSafeExceptions: | |
103 |
|
103 | |||
104 | def test_method_decorated_with_reraise_safe_exceptions(self): |
|
104 | def test_method_decorated_with_reraise_safe_exceptions(self): | |
105 | factory = Mock() |
|
105 | factory = Mock() | |
@@ -134,7 +134,7 b' class TestReraiseSafeExceptions(object):' | |||||
134 | assert exc_info.value._vcs_kind == expected_type |
|
134 | assert exc_info.value._vcs_kind == expected_type | |
135 |
|
135 | |||
136 |
|
136 | |||
137 |
class TestDulwichRepoWrapper |
|
137 | class TestDulwichRepoWrapper: | |
138 | def test_calls_close_on_delete(self): |
|
138 | def test_calls_close_on_delete(self): | |
139 | isdir_patcher = patch('dulwich.repo.os.path.isdir', return_value=True) |
|
139 | isdir_patcher = patch('dulwich.repo.os.path.isdir', return_value=True) | |
140 | with patch.object(git_remote.Repo, 'close') as close_mock: |
|
140 | with patch.object(git_remote.Repo, 'close') as close_mock: | |
@@ -147,7 +147,7 b' class TestDulwichRepoWrapper(object):' | |||||
147 | close_mock.assert_called_once_with() |
|
147 | close_mock.assert_called_once_with() | |
148 |
|
148 | |||
149 |
|
149 | |||
150 |
class TestGitFactory |
|
150 | class TestGitFactory: | |
151 | def test_create_repo_returns_dulwich_wrapper(self): |
|
151 | def test_create_repo_returns_dulwich_wrapper(self): | |
152 |
|
152 | |||
153 | with patch('vcsserver.lib.rc_cache.region_meta.dogpile_cache_regions') as mock: |
|
153 | with patch('vcsserver.lib.rc_cache.region_meta.dogpile_cache_regions') as mock: |
@@ -27,7 +27,7 b' from vcsserver import exceptions, hgcomp' | |||||
27 | from vcsserver.remote import hg_remote |
|
27 | from vcsserver.remote import hg_remote | |
28 |
|
28 | |||
29 |
|
29 | |||
30 |
class TestDiff |
|
30 | class TestDiff: | |
31 | def test_raising_safe_exception_when_lookup_failed(self): |
|
31 | def test_raising_safe_exception_when_lookup_failed(self): | |
32 |
|
32 | |||
33 | factory = Mock() |
|
33 | factory = Mock() | |
@@ -44,7 +44,7 b' class TestDiff(object):' | |||||
44 | assert exc_info.value._vcs_kind == 'lookup' |
|
44 | assert exc_info.value._vcs_kind == 'lookup' | |
45 |
|
45 | |||
46 |
|
46 | |||
47 |
class TestReraiseSafeExceptions |
|
47 | class TestReraiseSafeExceptions: | |
48 | original_traceback = None |
|
48 | original_traceback = None | |
49 |
|
49 | |||
50 | def test_method_decorated_with_reraise_safe_exceptions(self): |
|
50 | def test_method_decorated_with_reraise_safe_exceptions(self): |
@@ -121,7 +121,7 b' def test_git_post_pull_is_disabled():' | |||||
121 | hooks.git_post_pull({'hooks': ['push']}) == hooks.HookResponse(0, '')) |
|
121 | hooks.git_post_pull({'hooks': ['push']}) == hooks.HookResponse(0, '')) | |
122 |
|
122 | |||
123 |
|
123 | |||
124 |
class TestGetHooksClient |
|
124 | class TestGetHooksClient: | |
125 |
|
125 | |||
126 | def test_returns_http_client_when_protocol_matches(self): |
|
126 | def test_returns_http_client_when_protocol_matches(self): | |
127 | hooks_uri = 'localhost:8000' |
|
127 | hooks_uri = 'localhost:8000' | |
@@ -146,7 +146,7 b' class TestGetHooksClient(object):' | |||||
146 | assert result._hooks_module == fake_module |
|
146 | assert result._hooks_module == fake_module | |
147 |
|
147 | |||
148 |
|
148 | |||
149 |
class TestHooksHttpClient |
|
149 | class TestHooksHttpClient: | |
150 | def test_init_sets_hooks_uri(self): |
|
150 | def test_init_sets_hooks_uri(self): | |
151 | uri = 'localhost:3000' |
|
151 | uri = 'localhost:3000' | |
152 | client = hooks.HooksHttpClient(uri) |
|
152 | client = hooks.HooksHttpClient(uri) | |
@@ -182,7 +182,7 b' class TestHooksHttpClient(object):' | |||||
182 | assert result == expected_result |
|
182 | assert result == expected_result | |
183 |
|
183 | |||
184 |
|
184 | |||
185 |
class TestHooksDummyClient |
|
185 | class TestHooksDummyClient: | |
186 | def test_init_imports_hooks_module(self): |
|
186 | def test_init_imports_hooks_module(self): | |
187 | hooks_module_name = 'rhodecode.fake.module' |
|
187 | hooks_module_name = 'rhodecode.fake.module' | |
188 | hooks_module = mock.MagicMock() |
|
188 | hooks_module = mock.MagicMock() | |
@@ -224,7 +224,7 b' class MirrorHttpHandler(BaseHTTPRequestH' | |||||
224 | self.wfile.write(body) |
|
224 | self.wfile.write(body) | |
225 |
|
225 | |||
226 |
|
226 | |||
227 |
class MirrorHttpServer |
|
227 | class MirrorHttpServer: | |
228 | ip_address = '127.0.0.1' |
|
228 | ip_address = '127.0.0.1' | |
229 | port = 0 |
|
229 | port = 0 | |
230 |
|
230 |
@@ -27,7 +27,7 b' from vcsserver.str_utils import safe_byt' | |||||
27 | from vcsserver.utils import AttributeDict |
|
27 | from vcsserver.utils import AttributeDict | |
28 |
|
28 | |||
29 |
|
29 | |||
30 |
class TestCheckRhodecodeHook |
|
30 | class TestCheckRhodecodeHook: | |
31 |
|
31 | |||
32 | def test_returns_false_when_hook_file_is_wrong_found(self, tmpdir): |
|
32 | def test_returns_false_when_hook_file_is_wrong_found(self, tmpdir): | |
33 | hook = os.path.join(str(tmpdir), 'fake_hook_file.py') |
|
33 | hook = os.path.join(str(tmpdir), 'fake_hook_file.py') | |
@@ -55,7 +55,7 b' class TestCheckRhodecodeHook(object):' | |||||
55 | assert result is expected_result |
|
55 | assert result is expected_result | |
56 |
|
56 | |||
57 |
|
57 | |||
58 |
class BaseInstallHooks |
|
58 | class BaseInstallHooks: | |
59 | HOOK_FILES = () |
|
59 | HOOK_FILES = () | |
60 |
|
60 | |||
61 | def _check_hook_file_mode(self, file_path): |
|
61 | def _check_hook_file_mode(self, file_path): |
@@ -72,7 +72,7 b' def test_invalid_endpoint_returns_403(py' | |||||
72 | def test_pre_pull_hook_fails_with_sideband(pygrack_app, sideband): |
|
72 | def test_pre_pull_hook_fails_with_sideband(pygrack_app, sideband): | |
73 | request = ''.join([ |
|
73 | request = ''.join([ | |
74 | '0054want 74730d410fcb6603ace96f1dc55ea6196122532d ', |
|
74 | '0054want 74730d410fcb6603ace96f1dc55ea6196122532d ', | |
75 |
'multi_ack |
|
75 | f'multi_ack {sideband} ofs-delta\n', | |
76 | '0000', |
|
76 | '0000', | |
77 | '0009done\n', |
|
77 | '0009done\n', | |
78 | ]) |
|
78 | ]) |
@@ -25,7 +25,7 b' from vcsserver import subprocessio' | |||||
25 | from vcsserver.str_utils import ascii_bytes |
|
25 | from vcsserver.str_utils import ascii_bytes | |
26 |
|
26 | |||
27 |
|
27 | |||
28 |
class FileLikeObj |
|
28 | class FileLikeObj: # pragma: no cover | |
29 |
|
29 | |||
30 | def __init__(self, data: bytes, size): |
|
30 | def __init__(self, data: bytes, size): | |
31 | chunks = size // len(data) |
|
31 | chunks = size // len(data) |
@@ -23,7 +23,7 b' import sys' | |||||
23 | from vcsserver.str_utils import ascii_bytes |
|
23 | from vcsserver.str_utils import ascii_bytes | |
24 |
|
24 | |||
25 |
|
25 | |||
26 |
class MockPopen |
|
26 | class MockPopen: | |
27 | def __init__(self, stderr): |
|
27 | def __init__(self, stderr): | |
28 | self.stdout = io.BytesIO(b'') |
|
28 | self.stdout = io.BytesIO(b'') | |
29 | self.stderr = io.BytesIO(stderr) |
|
29 | self.stderr = io.BytesIO(stderr) |
@@ -55,7 +55,7 b' def get_headers_call_context(environ, st' | |||||
55 | raise ValueError('Expected header HTTP_X_RC_VCS_STREAM_CALL_CONTEXT not found') |
|
55 | raise ValueError('Expected header HTTP_X_RC_VCS_STREAM_CALL_CONTEXT not found') | |
56 |
|
56 | |||
57 |
|
57 | |||
58 |
class RequestWrapperTween |
|
58 | class RequestWrapperTween: | |
59 | def __init__(self, handler, registry): |
|
59 | def __init__(self, handler, registry): | |
60 | self.handler = handler |
|
60 | self.handler = handler | |
61 | self.registry = registry |
|
61 | self.registry = registry |
@@ -18,7 +18,7 b'' | |||||
18 | from vcsserver.lib import rc_cache |
|
18 | from vcsserver.lib import rc_cache | |
19 |
|
19 | |||
20 |
|
20 | |||
21 |
class RemoteBase |
|
21 | class RemoteBase: | |
22 | EMPTY_COMMIT = '0' * 40 |
|
22 | EMPTY_COMMIT = '0' * 40 | |
23 |
|
23 | |||
24 | def _region(self, wire): |
|
24 | def _region(self, wire): |
@@ -50,7 +50,7 b' def _complete_environ(environ, input_dat' | |||||
50 |
|
50 | |||
51 |
|
51 | |||
52 | # pylint: disable=too-few-public-methods |
|
52 | # pylint: disable=too-few-public-methods | |
53 |
class _StartResponse |
|
53 | class _StartResponse: | |
54 | """Save the arguments of a start_response call.""" |
|
54 | """Save the arguments of a start_response call.""" | |
55 |
|
55 | |||
56 | __slots__ = ['status', 'headers', 'content'] |
|
56 | __slots__ = ['status', 'headers', 'content'] | |
@@ -76,7 +76,7 b' class _StartResponse(object):' | |||||
76 | self.content.append(content) |
|
76 | self.content.append(content) | |
77 |
|
77 | |||
78 |
|
78 | |||
79 |
class WSGIAppCaller |
|
79 | class WSGIAppCaller: | |
80 | """Calls a WSGI app.""" |
|
80 | """Calls a WSGI app.""" | |
81 |
|
81 | |||
82 | def __init__(self, app): |
|
82 | def __init__(self, app): |
General Comments 0
You need to be logged in to leave comments.
Login now