Show More
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2015-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -54,7 +52,7 b' def free_cache_keys(*args):' | |||||
54 | if cache_keys_by_pid: |
|
52 | if cache_keys_by_pid: | |
55 | try: |
|
53 | try: | |
56 | for cache_proc in set(cache_keys_by_pid): |
|
54 | for cache_proc in set(cache_keys_by_pid): | |
57 |
like_expression = '{}%' |
|
55 | like_expression = f'{cache_proc}%' | |
58 | qry = CacheKey.query().filter(CacheKey.cache_key.like(like_expression)) |
|
56 | qry = CacheKey.query().filter(CacheKey.cache_key.like(like_expression)) | |
59 | count = qry.count() |
|
57 | count = qry.count() | |
60 | log.info('Clearing %s: %s cache keys, total: %s', cache_proc, len(cache_keys_by_pid), count) |
|
58 | log.info('Clearing %s: %s cache keys, total: %s', cache_proc, len(cache_keys_by_pid), count) |
@@ -181,7 +181,7 b' def get_or_create_region(region_name, re' | |||||
181 | region_obj = region_meta.dogpile_cache_regions.get(region_name) |
|
181 | region_obj = region_meta.dogpile_cache_regions.get(region_name) | |
182 | if not region_obj: |
|
182 | if not region_obj: | |
183 | reg_keys = list(region_meta.dogpile_cache_regions.keys()) |
|
183 | reg_keys = list(region_meta.dogpile_cache_regions.keys()) | |
184 |
raise |
|
184 | raise OSError(f'Region `{region_name}` not in configured: {reg_keys}.') | |
185 |
|
185 | |||
186 | region_uid_name = f'{region_name}:{region_namespace}' |
|
186 | region_uid_name = f'{region_name}:{region_namespace}' | |
187 |
|
187 | |||
@@ -331,7 +331,7 b' class InvalidationContext(object):' | |||||
331 | self.cache_key = compute_key_from_params(uid) |
|
331 | self.cache_key = compute_key_from_params(uid) | |
332 | self.cache_key = 'proc:{}|thread:{}|params:{}'.format( |
|
332 | self.cache_key = 'proc:{}|thread:{}|params:{}'.format( | |
333 | self.proc_id, self.thread_id, self.cache_key) |
|
333 | self.proc_id, self.thread_id, self.cache_key) | |
334 |
self.proc_key = 'proc:{ |
|
334 | self.proc_key = f'proc:{self.proc_id}' | |
335 | self.compute_time = 0 |
|
335 | self.compute_time = 0 | |
336 |
|
336 | |||
337 | def get_or_create_cache_obj(self, cache_type, invalidation_namespace=''): |
|
337 | def get_or_create_cache_obj(self, cache_type, invalidation_namespace=''): |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2016-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -76,7 +74,7 b' def command(ini_path, filename, file_pat' | |||||
76 |
|
74 | |||
77 | repo = Repository.get(repo_id) |
|
75 | repo = Repository.get(repo_id) | |
78 | if not repo: |
|
76 | if not repo: | |
79 |
click.secho('ERROR: Unable to find repository with id `{}`' |
|
77 | click.secho(f'ERROR: Unable to find repository with id `{repo_id}`', | |
80 | fg='red') |
|
78 | fg='red') | |
81 | sys.exit(-1) |
|
79 | sys.exit(-1) | |
82 |
|
80 | |||
@@ -87,7 +85,7 b' def command(ini_path, filename, file_pat' | |||||
87 | db_user = User.get_first_super_admin() |
|
85 | db_user = User.get_first_super_admin() | |
88 |
|
86 | |||
89 | if not db_user: |
|
87 | if not db_user: | |
90 |
click.secho('ERROR: Unable to find user with id/username `{}`' |
|
88 | click.secho(f'ERROR: Unable to find user with id/username `{user_id}`', | |
91 | fg='red') |
|
89 | fg='red') | |
92 | sys.exit(-1) |
|
90 | sys.exit(-1) | |
93 |
|
91 | |||
@@ -96,12 +94,12 b' def command(ini_path, filename, file_pat' | |||||
96 | storage = store_utils.get_file_storage(request.registry.settings) |
|
94 | storage = store_utils.get_file_storage(request.registry.settings) | |
97 |
|
95 | |||
98 | with open(file_path, 'rb') as f: |
|
96 | with open(file_path, 'rb') as f: | |
99 |
click.secho('Adding new artifact from path: `{}`' |
|
97 | click.secho(f'Adding new artifact from path: `{file_path}`', | |
100 | fg='green') |
|
98 | fg='green') | |
101 |
|
99 | |||
102 | file_data = _store_file( |
|
100 | file_data = _store_file( | |
103 | storage, auth_user, filename, content=None, check_acl=True, |
|
101 | storage, auth_user, filename, content=None, check_acl=True, | |
104 | file_obj=f, description=description, |
|
102 | file_obj=f, description=description, | |
105 | scope_repo_id=repo.repo_id) |
|
103 | scope_repo_id=repo.repo_id) | |
106 |
click.secho('File Data: {}' |
|
104 | click.secho(f'File Data: {file_data}', | |
107 | fg='green') |
|
105 | fg='green') |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2016-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2016-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2016-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2017-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2017-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2017-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -12,7 +12,7 b' class _Singleton(type):' | |||||
12 |
|
12 | |||
13 | def __call__(cls, *args, **kwargs): |
|
13 | def __call__(cls, *args, **kwargs): | |
14 | if cls not in cls._instances: |
|
14 | if cls not in cls._instances: | |
15 |
cls._instances[cls] = super( |
|
15 | cls._instances[cls] = super().__call__(*args, **kwargs) | |
16 | return cls._instances[cls] |
|
16 | return cls._instances[cls] | |
17 |
|
17 | |||
18 |
|
18 | |||
@@ -29,12 +29,12 b' class StatsdClientClass(Singleton):' | |||||
29 |
|
29 | |||
30 | if name.startswith("statsd"): |
|
30 | if name.startswith("statsd"): | |
31 | if self.setup_run: |
|
31 | if self.setup_run: | |
32 |
return super( |
|
32 | return super().__getattribute__(name) | |
33 | else: |
|
33 | else: | |
34 | return None |
|
34 | return None | |
35 | #raise StatsdClientNotInitialised("requested key was %s" % name) |
|
35 | #raise StatsdClientNotInitialised("requested key was %s" % name) | |
36 |
|
36 | |||
37 |
return super( |
|
37 | return super().__getattribute__(name) | |
38 |
|
38 | |||
39 | def setup(self, settings): |
|
39 | def setup(self, settings): | |
40 | """ |
|
40 | """ |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -67,7 +66,7 b' def base64_to_str(text) -> str:' | |||||
67 | return safe_str(base64.encodebytes(safe_bytes(text))).strip() |
|
66 | return safe_str(base64.encodebytes(safe_bytes(text))).strip() | |
68 |
|
67 | |||
69 |
|
68 | |||
70 |
def get_default_encodings() -> |
|
69 | def get_default_encodings() -> list[str]: | |
71 | return aslist(rhodecode.CONFIG.get('default_encoding', 'utf8'), sep=',') |
|
70 | return aslist(rhodecode.CONFIG.get('default_encoding', 'utf8'), sep=',') | |
72 |
|
71 | |||
73 |
|
72 |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2017-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -125,7 +123,7 b' class SysInfoRes(object):' | |||||
125 | return self.__json__() |
|
123 | return self.__json__() | |
126 |
|
124 | |||
127 | def __str__(self): |
|
125 | def __str__(self): | |
128 |
return '<SysInfoRes({ |
|
126 | return f'<SysInfoRes({self.__json__()})>' | |
129 |
|
127 | |||
130 |
|
128 | |||
131 | class SysInfo(object): |
|
129 | class SysInfo(object): | |
@@ -146,7 +144,7 b' class SysInfo(object):' | |||||
146 | return computed.__json__() |
|
144 | return computed.__json__() | |
147 |
|
145 | |||
148 | def __str__(self): |
|
146 | def __str__(self): | |
149 |
return '<SysInfo({ |
|
147 | return f'<SysInfo({self.function_name})>' | |
150 |
|
148 | |||
151 | def compute(self, **kwargs): |
|
149 | def compute(self, **kwargs): | |
152 | return self.function_name(**kwargs) |
|
150 | return self.function_name(**kwargs) | |
@@ -251,7 +249,7 b' def uptime():' | |||||
251 | human_value['boot_time'] = time_to_datetime(boot_time) |
|
249 | human_value['boot_time'] = time_to_datetime(boot_time) | |
252 | human_value['uptime'] = age(time_to_datetime(boot_time), show_suffix=False) |
|
250 | human_value['uptime'] = age(time_to_datetime(boot_time), show_suffix=False) | |
253 |
|
251 | |||
254 |
human_value['text'] = 'Server started {}' |
|
252 | human_value['text'] = f'Server started {date_or_age}' | |
255 | return SysInfoRes(value=value, human_value=human_value) |
|
253 | return SysInfoRes(value=value, human_value=human_value) | |
256 |
|
254 | |||
257 |
|
255 | |||
@@ -270,10 +268,10 b' def memory():' | |||||
270 | value['used_real'], value['total'], 1) |
|
268 | value['used_real'], value['total'], 1) | |
271 |
|
269 | |||
272 | human_value = value.copy() |
|
270 | human_value = value.copy() | |
273 |
human_value['text'] = ' |
|
271 | human_value['text'] = '{}/{}, {}% used'.format( | |
274 | format_byte_size_binary(value['used_real']), |
|
272 | format_byte_size_binary(value['used_real']), | |
275 | format_byte_size_binary(value['total']), |
|
273 | format_byte_size_binary(value['total']), | |
276 |
value['percent_used'] |
|
274 | value['percent_used']) | |
277 |
|
275 | |||
278 | keys = list(value.keys())[::] |
|
276 | keys = list(value.keys())[::] | |
279 | keys.pop(keys.index('percent')) |
|
277 | keys.pop(keys.index('percent')) | |
@@ -546,7 +544,7 b' def git_info():' | |||||
546 | value = human_value = '' |
|
544 | value = human_value = '' | |
547 | try: |
|
545 | try: | |
548 | value = git.discover_git_version(raise_on_exc=True) |
|
546 | value = git.discover_git_version(raise_on_exc=True) | |
549 |
human_value = 'version reported from VCSServer: {}' |
|
547 | human_value = f'version reported from VCSServer: {value}' | |
550 | except Exception as e: |
|
548 | except Exception as e: | |
551 | state = {'message': str(e), 'type': STATE_ERR} |
|
549 | state = {'message': str(e), 'type': STATE_ERR} | |
552 |
|
550 | |||
@@ -560,7 +558,7 b' def hg_info():' | |||||
560 | value = human_value = '' |
|
558 | value = human_value = '' | |
561 | try: |
|
559 | try: | |
562 | value = hg.discover_hg_version(raise_on_exc=True) |
|
560 | value = hg.discover_hg_version(raise_on_exc=True) | |
563 |
human_value = 'version reported from VCSServer: {}' |
|
561 | human_value = f'version reported from VCSServer: {value}' | |
564 | except Exception as e: |
|
562 | except Exception as e: | |
565 | state = {'message': str(e), 'type': STATE_ERR} |
|
563 | state = {'message': str(e), 'type': STATE_ERR} | |
566 | return SysInfoRes(value=value, state=state, human_value=human_value) |
|
564 | return SysInfoRes(value=value, state=state, human_value=human_value) | |
@@ -573,7 +571,7 b' def svn_info():' | |||||
573 | value = human_value = '' |
|
571 | value = human_value = '' | |
574 | try: |
|
572 | try: | |
575 | value = svn.discover_svn_version(raise_on_exc=True) |
|
573 | value = svn.discover_svn_version(raise_on_exc=True) | |
576 |
human_value = 'version reported from VCSServer: {}' |
|
574 | human_value = f'version reported from VCSServer: {value}' | |
577 | except Exception as e: |
|
575 | except Exception as e: | |
578 | state = {'message': str(e), 'type': STATE_ERR} |
|
576 | state = {'message': str(e), 'type': STATE_ERR} | |
579 | return SysInfoRes(value=value, state=state, human_value=human_value) |
|
577 | return SysInfoRes(value=value, state=state, human_value=human_value) | |
@@ -774,7 +772,7 b' def server_info(environ):' | |||||
774 | from rhodecode.lib.base import get_server_ip_addr, get_server_port |
|
772 | from rhodecode.lib.base import get_server_ip_addr, get_server_port | |
775 |
|
773 | |||
776 | value = { |
|
774 | value = { | |
777 |
'server_ip': ' |
|
775 | 'server_ip': '{}:{}'.format( | |
778 | get_server_ip_addr(environ, log_errors=False), |
|
776 | get_server_ip_addr(environ, log_errors=False), | |
779 | get_server_port(environ) |
|
777 | get_server_port(environ) | |
780 | ), |
|
778 | ), |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2017-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -165,9 +163,8 b' class MemcachedAuthSessions(BaseAuthSess' | |||||
165 | """ Return a list of tuples containing keys and details """ |
|
163 | """ Return a list of tuples containing keys and details """ | |
166 | cmd = 'stats cachedump %s %s' |
|
164 | cmd = 'stats cachedump %s %s' | |
167 | for slab_id in slab_ids: |
|
165 | for slab_id in slab_ids: | |
168 |
|
|
166 | yield from self._key_regex.finditer( | |
169 |
self._run_telnet_cmd(client, cmd % (slab_id, limit))) |
|
167 | self._run_telnet_cmd(client, cmd % (slab_id, limit))) | |
170 | yield key |
|
|||
171 |
|
168 | |||
172 | def get_count(self): |
|
169 | def get_count(self): | |
173 | client = self._get_client() |
|
170 | client = self._get_client() | |
@@ -261,4 +258,4 b' def get_session_handler(session_type):' | |||||
261 | return types[session_type] |
|
258 | return types[session_type] | |
262 | except KeyError: |
|
259 | except KeyError: | |
263 | raise ValueError( |
|
260 | raise ValueError( | |
264 |
'This type {} is not supported' |
|
261 | f'This type {session_type} is not supported') |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -192,8 +191,7 b' def get_filesystem_repos(path, recursive' | |||||
192 | #check if this dir containts other repos for recursive scan |
|
191 | #check if this dir containts other repos for recursive scan | |
193 | rec_path = os.path.join(p, dirpath) |
|
192 | rec_path = os.path.join(p, dirpath) | |
194 | if os.path.isdir(rec_path): |
|
193 | if os.path.isdir(rec_path): | |
195 |
|
|
194 | yield from _get_repos(rec_path) | |
196 | yield inner_scm |
|
|||
197 |
|
195 | |||
198 | return _get_repos(path) |
|
196 | return _get_repos(path) | |
199 |
|
197 | |||
@@ -330,7 +328,7 b' def ask_ok(prompt, retries=4, complaint=' | |||||
330 | return False |
|
328 | return False | |
331 | retries = retries - 1 |
|
329 | retries = retries - 1 | |
332 | if retries < 0: |
|
330 | if retries < 0: | |
333 |
raise |
|
331 | raise OSError | |
334 | print(complaint) |
|
332 | print(complaint) | |
335 |
|
333 | |||
336 | # propagated from mercurial documentation |
|
334 | # propagated from mercurial documentation | |
@@ -805,5 +803,5 b' def send_test_email(recipients, email_bo' | |||||
805 | from rhodecode.lib.celerylib import tasks, run_task |
|
803 | from rhodecode.lib.celerylib import tasks, run_task | |
806 |
|
804 | |||
807 | email_body = email_body_plaintext = email_body |
|
805 | email_body = email_body_plaintext = email_body | |
808 |
subject = 'SUBJECT FROM: { |
|
806 | subject = f'SUBJECT FROM: {socket.gethostname()}' | |
809 | tasks.send_email(recipients, subject, email_body_plaintext, email_body) |
|
807 | tasks.send_email(recipients, subject, email_body_plaintext, email_body) |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -715,7 +713,7 b' def action_logger_generic(action, namesp' | |||||
715 | user = '<unknown user>' |
|
713 | user = '<unknown user>' | |
716 | logfunc = log.warning |
|
714 | logfunc = log.warning | |
717 |
|
715 | |||
718 |
logfunc('Logging action by {}: {}' |
|
716 | logfunc(f'Logging action by {user}: {action}') | |
719 |
|
717 | |||
720 |
|
718 | |||
721 | def escape_split(text, sep=',', maxsplit=-1): |
|
719 | def escape_split(text, sep=',', maxsplit=-1): |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2014-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -347,7 +345,7 b' class BaseRepository(object):' | |||||
347 | raise NotImplementedError |
|
345 | raise NotImplementedError | |
348 |
|
346 | |||
349 | def __repr__(self): |
|
347 | def __repr__(self): | |
350 |
return '<{ |
|
348 | return f'<{self.__class__.__name__} at {self.path}>' | |
351 |
|
349 | |||
352 | def __len__(self): |
|
350 | def __len__(self): | |
353 | return self.count() |
|
351 | return self.count() | |
@@ -716,7 +714,7 b' class BaseRepository(object):' | |||||
716 | """ |
|
714 | """ | |
717 | return os.path.join( |
|
715 | return os.path.join( | |
718 | os.path.dirname(repo_path), |
|
716 | os.path.dirname(repo_path), | |
719 |
'.__shadow_{ |
|
717 | f'.__shadow_{os.path.basename(repo_path)}_{workspace_id}') | |
720 |
|
718 | |||
721 | @classmethod |
|
719 | @classmethod | |
722 | def _get_shadow_repository_path(cls, repo_path, repo_id, workspace_id): |
|
720 | def _get_shadow_repository_path(cls, repo_path, repo_id, workspace_id): | |
@@ -728,7 +726,7 b' class BaseRepository(object):' | |||||
728 | else: |
|
726 | else: | |
729 | return os.path.join( |
|
727 | return os.path.join( | |
730 | os.path.dirname(repo_path), |
|
728 | os.path.dirname(repo_path), | |
731 |
'.__shadow_repo_{}_{}' |
|
729 | f'.__shadow_repo_{repo_id}_{workspace_id}') | |
732 |
|
730 | |||
733 | def cleanup_merge_workspace(self, repo_id, workspace_id): |
|
731 | def cleanup_merge_workspace(self, repo_id, workspace_id): | |
734 | """ |
|
732 | """ | |
@@ -806,7 +804,7 b' class BaseRepository(object):' | |||||
806 |
|
804 | |||
807 | def _validate_branch_name(self, branch_name): |
|
805 | def _validate_branch_name(self, branch_name): | |
808 | if branch_name and branch_name not in self.branches_all: |
|
806 | if branch_name and branch_name not in self.branches_all: | |
809 |
msg = ("Branch {} not found in {}" |
|
807 | msg = (f"Branch {branch_name} not found in {self}") | |
810 | raise BranchDoesNotExistError(msg) |
|
808 | raise BranchDoesNotExistError(msg) | |
811 |
|
809 | |||
812 | # |
|
810 | # | |
@@ -1583,7 +1581,7 b' class BaseInMemoryCommit(object):' | |||||
1583 | pass |
|
1581 | pass | |
1584 | else: |
|
1582 | else: | |
1585 | raise NodeAlreadyExistsError( |
|
1583 | raise NodeAlreadyExistsError( | |
1586 |
"Node `{ |
|
1584 | f"Node `{node.path}` already exists at {p}") | |
1587 |
|
1585 | |||
1588 | # Check nodes marked as changed |
|
1586 | # Check nodes marked as changed | |
1589 | missing = set(self.changed) |
|
1587 | missing = set(self.changed) |
@@ -373,7 +373,7 b' class GitRepository(BaseRepository):' | |||||
373 | if name in self.tags: |
|
373 | if name in self.tags: | |
374 | raise TagAlreadyExistError("Tag %s already exists" % name) |
|
374 | raise TagAlreadyExistError("Tag %s already exists" % name) | |
375 | commit = self.get_commit(commit_id=commit_id) |
|
375 | commit = self.get_commit(commit_id=commit_id) | |
376 |
message = message or "Added tag {} for commit { |
|
376 | message = message or f"Added tag {name} for commit {commit.raw_id}" | |
377 |
|
377 | |||
378 | self._remote.set_refs('refs/tags/%s' % name, commit.raw_id) |
|
378 | self._remote.set_refs('refs/tags/%s' % name, commit.raw_id) | |
379 |
|
379 | |||
@@ -641,7 +641,7 b' class GitRepository(BaseRepository):' | |||||
641 | else: |
|
641 | else: | |
642 | output, __ = repo1.run_git_command( |
|
642 | output, __ = repo1.run_git_command( | |
643 | ['log', '--reverse', '--pretty=format: %H', '-s', |
|
643 | ['log', '--reverse', '--pretty=format: %H', '-s', | |
644 |
'{}..{}' |
|
644 | f'{commit_id1}..{commit_id2}']) | |
645 | commits = [ |
|
645 | commits = [ | |
646 | repo1.get_commit(commit_id=commit_id, pre_load=pre_load) |
|
646 | repo1.get_commit(commit_id=commit_id, pre_load=pre_load) | |
647 | for commit_id in self.COMMIT_ID_PAT.findall(output)] |
|
647 | for commit_id in self.COMMIT_ID_PAT.findall(output)] | |
@@ -912,7 +912,7 b' class GitRepository(BaseRepository):' | |||||
912 | target_repo._local_pull(self.path, source_branch) |
|
912 | target_repo._local_pull(self.path, source_branch) | |
913 | else: |
|
913 | else: | |
914 | cmd = ['push', os.path.abspath(repository_path), |
|
914 | cmd = ['push', os.path.abspath(repository_path), | |
915 |
'{}:{}' |
|
915 | f'{source_branch}:{target_branch}'] | |
916 | gitenv = {} |
|
916 | gitenv = {} | |
917 | if rc_scm_data: |
|
917 | if rc_scm_data: | |
918 | gitenv.update({'RC_SCM_DATA': rc_scm_data}) |
|
918 | gitenv.update({'RC_SCM_DATA': rc_scm_data}) | |
@@ -922,7 +922,7 b' class GitRepository(BaseRepository):' | |||||
922 | self.run_git_command(cmd, fail_on_stderr=False, extra_env=gitenv) |
|
922 | self.run_git_command(cmd, fail_on_stderr=False, extra_env=gitenv) | |
923 |
|
923 | |||
924 | def _get_new_pr_branch(self, source_branch, target_branch): |
|
924 | def _get_new_pr_branch(self, source_branch, target_branch): | |
925 |
prefix = 'pr_{}-{}_' |
|
925 | prefix = f'pr_{source_branch}-{target_branch}_' | |
926 | pr_branches = [] |
|
926 | pr_branches = [] | |
927 | for branch in self.branches: |
|
927 | for branch in self.branches: | |
928 | if branch.startswith(prefix): |
|
928 | if branch.startswith(prefix): |
@@ -289,7 +289,7 b' class MercurialCommit(base.BaseCommit):' | |||||
289 |
|
289 | |||
290 | if self._get_kind(path) != NodeKind.DIR: |
|
290 | if self._get_kind(path) != NodeKind.DIR: | |
291 | raise CommitError( |
|
291 | raise CommitError( | |
292 |
"Directory does not exist for idx { |
|
292 | f"Directory does not exist for idx {self.raw_id} at '{path}'") | |
293 | path = self._fix_path(path) |
|
293 | path = self._fix_path(path) | |
294 |
|
294 | |||
295 | filenodes = [ |
|
295 | filenodes = [ |
@@ -178,7 +178,7 b' class MercurialRepository(BaseRepository' | |||||
178 | local = kwargs.setdefault('local', False) |
|
178 | local = kwargs.setdefault('local', False) | |
179 |
|
179 | |||
180 | if message is None: |
|
180 | if message is None: | |
181 |
message = "Added tag {} for commit { |
|
181 | message = f"Added tag {name} for commit {commit.short_id}" | |
182 |
|
182 | |||
183 | date, tz = date_to_timestamp_plus_offset(date) |
|
183 | date, tz = date_to_timestamp_plus_offset(date) | |
184 |
|
184 | |||
@@ -529,17 +529,17 b' class MercurialRepository(BaseRepository' | |||||
529 | commit_filter = [] |
|
529 | commit_filter = [] | |
530 |
|
530 | |||
531 | if branch_name and not branch_ancestors: |
|
531 | if branch_name and not branch_ancestors: | |
532 |
commit_filter.append('branch("{}")' |
|
532 | commit_filter.append(f'branch("{branch_name}")') | |
533 | elif branch_name and branch_ancestors: |
|
533 | elif branch_name and branch_ancestors: | |
534 |
commit_filter.append('ancestors(branch("{}"))' |
|
534 | commit_filter.append(f'ancestors(branch("{branch_name}"))') | |
535 |
|
535 | |||
536 | if start_date and not end_date: |
|
536 | if start_date and not end_date: | |
537 |
commit_filter.append('date(">{}")' |
|
537 | commit_filter.append(f'date(">{start_date}")') | |
538 | if end_date and not start_date: |
|
538 | if end_date and not start_date: | |
539 |
commit_filter.append('date("<{}")' |
|
539 | commit_filter.append(f'date("<{end_date}")') | |
540 | if start_date and end_date: |
|
540 | if start_date and end_date: | |
541 | commit_filter.append( |
|
541 | commit_filter.append( | |
542 |
'date(">{}") and date("<{}")' |
|
542 | f'date(">{start_date}") and date("<{end_date}")') | |
543 |
|
543 | |||
544 | if not show_hidden: |
|
544 | if not show_hidden: | |
545 | commit_filter.append('not obsolete()') |
|
545 | commit_filter.append('not obsolete()') | |
@@ -657,7 +657,7 b' class MercurialRepository(BaseRepository' | |||||
657 | unresolved = None |
|
657 | unresolved = None | |
658 | if use_rebase: |
|
658 | if use_rebase: | |
659 | try: |
|
659 | try: | |
660 |
bookmark_name = 'rcbook{}{}' |
|
660 | bookmark_name = f'rcbook{source_ref_commit_id}{target_ref_commit_id}' | |
661 | self.bookmark(bookmark_name, revision=source_ref.commit_id) |
|
661 | self.bookmark(bookmark_name, revision=source_ref.commit_id) | |
662 | self._remote.rebase( |
|
662 | self._remote.rebase( | |
663 | source=source_ref_commit_id, dest=target_ref_commit_id) |
|
663 | source=source_ref_commit_id, dest=target_ref_commit_id) | |
@@ -687,7 +687,7 b' class MercurialRepository(BaseRepository' | |||||
687 | self._remote.invalidate_vcs_cache() |
|
687 | self._remote.invalidate_vcs_cache() | |
688 | self._remote.commit( |
|
688 | self._remote.commit( | |
689 | message=safe_str(merge_message), |
|
689 | message=safe_str(merge_message), | |
690 |
username=safe_str('{} <{}>' |
|
690 | username=safe_str(f'{user_name} <{user_email}>')) | |
691 | self._remote.invalidate_vcs_cache() |
|
691 | self._remote.invalidate_vcs_cache() | |
692 | return self._identify(), True |
|
692 | return self._identify(), True | |
693 | except RepositoryError as e: |
|
693 | except RepositoryError as e: | |
@@ -718,7 +718,7 b' class MercurialRepository(BaseRepository' | |||||
718 | try: |
|
718 | try: | |
719 | self._remote.commit( |
|
719 | self._remote.commit( | |
720 | message=safe_str(message), |
|
720 | message=safe_str(message), | |
721 |
username=safe_str('{} <{}>' |
|
721 | username=safe_str(f'{user_name} <{user_email}>'), | |
722 | close_branch=True) |
|
722 | close_branch=True) | |
723 | self._remote.invalidate_vcs_cache() |
|
723 | self._remote.invalidate_vcs_cache() | |
724 | return self._identify(), True |
|
724 | return self._identify(), True | |
@@ -767,7 +767,7 b' class MercurialRepository(BaseRepository' | |||||
767 | if len(heads_all) > max_heads: |
|
767 | if len(heads_all) > max_heads: | |
768 | heads = '\n,'.join( |
|
768 | heads = '\n,'.join( | |
769 | heads_all[:max_heads] + |
|
769 | heads_all[:max_heads] + | |
770 |
['and { |
|
770 | [f'and {len(heads_all)-max_heads} more.']) | |
771 | else: |
|
771 | else: | |
772 | heads = '\n,'.join(heads_all) |
|
772 | heads = '\n,'.join(heads_all) | |
773 | metadata = { |
|
773 | metadata = { | |
@@ -862,7 +862,7 b' class MercurialRepository(BaseRepository' | |||||
862 | max_conflicts = 20 |
|
862 | max_conflicts = 20 | |
863 | if len(all_conflicts) > max_conflicts: |
|
863 | if len(all_conflicts) > max_conflicts: | |
864 | conflicts = all_conflicts[:max_conflicts] \ |
|
864 | conflicts = all_conflicts[:max_conflicts] \ | |
865 |
+ ['and { |
|
865 | + [f'and {len(all_conflicts)-max_conflicts} more.'] | |
866 | else: |
|
866 | else: | |
867 | conflicts = all_conflicts |
|
867 | conflicts = all_conflicts | |
868 | metadata['unresolved_files'] = \ |
|
868 | metadata['unresolved_files'] = \ |
@@ -53,7 +53,7 b' class SubversionCommit(base.BaseCommit):' | |||||
53 | # which knows how to translate commit index and commit id |
|
53 | # which knows how to translate commit index and commit id | |
54 | self.raw_id = commit_id |
|
54 | self.raw_id = commit_id | |
55 | self.short_id = commit_id |
|
55 | self.short_id = commit_id | |
56 |
self.id = 'r{}' |
|
56 | self.id = f'r{commit_id}' | |
57 |
|
57 | |||
58 | # TODO: Implement the following placeholder attributes |
|
58 | # TODO: Implement the following placeholder attributes | |
59 | self.nodes = {} |
|
59 | self.nodes = {} | |
@@ -199,7 +199,7 b' class SubversionCommit(base.BaseCommit):' | |||||
199 | return nodes.NodeKind.DIR |
|
199 | return nodes.NodeKind.DIR | |
200 | else: |
|
200 | else: | |
201 | raise CommitError( |
|
201 | raise CommitError( | |
202 |
"Node does not exist at the given path '{}'" |
|
202 | f"Node does not exist at the given path '{path}'") | |
203 |
|
203 | |||
204 | @LazyProperty |
|
204 | @LazyProperty | |
205 | def _changes_cache(self): |
|
205 | def _changes_cache(self): |
@@ -221,7 +221,7 b' class SubversionRepository(base.BaseRepo' | |||||
221 | commit_idx = svn_rev - 1 |
|
221 | commit_idx = svn_rev - 1 | |
222 | if commit_idx >= len(self.commit_ids): |
|
222 | if commit_idx >= len(self.commit_ids): | |
223 | raise CommitDoesNotExistError( |
|
223 | raise CommitDoesNotExistError( | |
224 |
"Commit at index {} does not exist." |
|
224 | f"Commit at index {commit_idx} does not exist.") | |
225 | return commit_idx |
|
225 | return commit_idx | |
226 |
|
226 | |||
227 | @staticmethod |
|
227 | @staticmethod | |
@@ -245,7 +245,7 b' class SubversionRepository(base.BaseRepo' | |||||
245 |
|
245 | |||
246 | def _check_path(self): |
|
246 | def _check_path(self): | |
247 | if not os.path.exists(self.path): |
|
247 | if not os.path.exists(self.path): | |
248 |
raise VCSError('Path "{}" does not exist!' |
|
248 | raise VCSError(f'Path "{self.path}" does not exist!') | |
249 | if not self._remote.is_path_valid_repository(self.path): |
|
249 | if not self._remote.is_path_valid_repository(self.path): | |
250 | raise VCSError( |
|
250 | raise VCSError( | |
251 | 'Path "%s" does not contain a Subversion repository' % |
|
251 | 'Path "%s" does not contain a Subversion repository' % | |
@@ -341,11 +341,11 b' class SubversionRepository(base.BaseRepo' | |||||
341 | return commit_id |
|
341 | return commit_id | |
342 | else: |
|
342 | else: | |
343 | raise CommitDoesNotExistError( |
|
343 | raise CommitDoesNotExistError( | |
344 |
"Commit {} does not exist." |
|
344 | f"Commit {commit_id} does not exist.") | |
345 | if commit_id not in [ |
|
345 | if commit_id not in [ | |
346 | None, 'HEAD', 'tip', self.DEFAULT_BRANCH_NAME]: |
|
346 | None, 'HEAD', 'tip', self.DEFAULT_BRANCH_NAME]: | |
347 | raise CommitDoesNotExistError( |
|
347 | raise CommitDoesNotExistError( | |
348 |
"Commit id {} not understood." |
|
348 | f"Commit id {commit_id} not understood.") | |
349 | svn_rev = self._remote.lookup('HEAD') |
|
349 | svn_rev = self._remote.lookup('HEAD') | |
350 | return str(svn_rev) |
|
350 | return str(svn_rev) | |
351 |
|
351 |
@@ -51,7 +51,7 b' def get_scm(path):' | |||||
51 | if len(found_scms) > 1: |
|
51 | if len(found_scms) > 1: | |
52 | found = ', '.join(x[0] for x in found_scms) |
|
52 | found = ', '.join(x[0] for x in found_scms) | |
53 | raise VCSError( |
|
53 | raise VCSError( | |
54 |
'More than one [{}] scm found at given path {}' |
|
54 | f'More than one [{found}] scm found at given path {path}') | |
55 |
|
55 | |||
56 | if len(found_scms) == 0: |
|
56 | if len(found_scms) == 0: | |
57 | raise VCSError('No scm found at given path %s' % path) |
|
57 | raise VCSError('No scm found at given path %s' % path) |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -55,7 +54,7 b' def _format_ref_id(name, raw_id):' | |||||
55 |
|
54 | |||
56 | def _format_ref_id_svn(name, raw_id): |
|
55 | def _format_ref_id_svn(name, raw_id): | |
57 | """Special way of formatting a reference for Subversion including path""" |
|
56 | """Special way of formatting a reference for Subversion including path""" | |
58 |
return ' |
|
57 | return '{}@{}'.format(name, raw_id) | |
59 |
|
58 | |||
60 |
|
59 | |||
61 | def get_commit_from_ref_name(repo, ref_name, ref_type=None): |
|
60 | def get_commit_from_ref_name(repo, ref_name, ref_type=None): | |
@@ -83,6 +82,6 b' def get_commit_from_ref_name(repo, ref_n' | |||||
83 | commit_id = ref_type_mapping[ref_type][ref_name] |
|
82 | commit_id = ref_type_mapping[ref_type][ref_name] | |
84 | except KeyError: |
|
83 | except KeyError: | |
85 | raise RepositoryError( |
|
84 | raise RepositoryError( | |
86 |
' |
|
85 | '{} "{}" does not exist'.format(ref_type, ref_name)) | |
87 |
|
86 | |||
88 | return repo_scm.get_commit(commit_id) |
|
87 | return repo_scm.get_commit(commit_id) |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2013-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -95,8 +93,7 b' class CommentsModel(BaseModel):' | |||||
95 | [comment_groups[_co.pull_request_version_id].append(_co) for _co in comments] |
|
93 | [comment_groups[_co.pull_request_version_id].append(_co) for _co in comments] | |
96 |
|
94 | |||
97 | def yield_comments(pos): |
|
95 | def yield_comments(pos): | |
98 |
|
|
96 | yield from comment_groups[pos] | |
99 | yield co |
|
|||
100 |
|
97 | |||
101 | comment_versions = collections.defaultdict( |
|
98 | comment_versions = collections.defaultdict( | |
102 | lambda: collections.defaultdict(list)) |
|
99 | lambda: collections.defaultdict(list)) | |
@@ -402,7 +399,7 b' class CommentsModel(BaseModel):' | |||||
402 | commit_comment_url = self.get_url(comment, request=request) |
|
399 | commit_comment_url = self.get_url(comment, request=request) | |
403 | commit_comment_reply_url = self.get_url( |
|
400 | commit_comment_reply_url = self.get_url( | |
404 | comment, request=request, |
|
401 | comment, request=request, | |
405 |
anchor='comment-{ |
|
402 | anchor=f'comment-{comment.comment_id}/?/ReplyToComment') | |
406 |
|
403 | |||
407 | target_repo_url = h.link_to( |
|
404 | target_repo_url = h.link_to( | |
408 | repo.repo_name, |
|
405 | repo.repo_name, | |
@@ -438,7 +435,7 b' class CommentsModel(BaseModel):' | |||||
438 | pr_comment_url = self.get_url(comment, request=request) |
|
435 | pr_comment_url = self.get_url(comment, request=request) | |
439 | pr_comment_reply_url = self.get_url( |
|
436 | pr_comment_reply_url = self.get_url( | |
440 | comment, request=request, |
|
437 | comment, request=request, | |
441 |
anchor='comment-{ |
|
438 | anchor=f'comment-{comment.comment_id}/?/ReplyToComment') | |
442 |
|
439 | |||
443 | pr_url = h.route_url( |
|
440 | pr_url = h.route_url( | |
444 | 'pullrequest_show', |
|
441 | 'pullrequest_show', | |
@@ -595,7 +592,7 b' class CommentsModel(BaseModel):' | |||||
595 |
|
592 | |||
596 | comment = self.__get_commit_comment(comment) |
|
593 | comment = self.__get_commit_comment(comment) | |
597 | if anchor is None: |
|
594 | if anchor is None: | |
598 |
anchor = 'comment-{ |
|
595 | anchor = f'comment-{comment.comment_id}' | |
599 |
|
596 | |||
600 | if comment.pull_request: |
|
597 | if comment.pull_request: | |
601 | pull_request = comment.pull_request |
|
598 | pull_request = comment.pull_request | |
@@ -823,7 +820,7 b' class CommentsModel(BaseModel):' | |||||
823 |
|
820 | |||
824 |
|
821 | |||
825 | def _parse_comment_line_number(line_no): |
|
822 | def _parse_comment_line_number(line_no): | |
826 | """ |
|
823 | r""" | |
827 | Parses line numbers of the form "(o|n)\d+" and returns them in a tuple. |
|
824 | Parses line numbers of the form "(o|n)\d+" and returns them in a tuple. | |
828 | """ |
|
825 | """ | |
829 | old_line = None |
|
826 | old_line = None | |
@@ -839,10 +836,10 b' def _parse_comment_line_number(line_no):' | |||||
839 |
|
836 | |||
840 | def _diff_to_comment_line_number(diff_line): |
|
837 | def _diff_to_comment_line_number(diff_line): | |
841 | if diff_line.new is not None: |
|
838 | if diff_line.new is not None: | |
842 |
return |
|
839 | return f'n{diff_line.new}' | |
843 | elif diff_line.old is not None: |
|
840 | elif diff_line.old is not None: | |
844 |
return |
|
841 | return f'o{diff_line.old}' | |
845 |
return |
|
842 | return '' | |
846 |
|
843 | |||
847 |
|
844 | |||
848 | def _diff_line_delta(a, b): |
|
845 | def _diff_line_delta(a, b): | |
@@ -852,4 +849,4 b' def _diff_line_delta(a, b):' | |||||
852 | return abs(a.old - b.old) |
|
849 | return abs(a.old - b.old) | |
853 | else: |
|
850 | else: | |
854 | raise ValueError( |
|
851 | raise ValueError( | |
855 |
"Cannot compute delta between {} and {}" |
|
852 | f"Cannot compute delta between {a} and {b}") |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 | # Copyright (C) 2010-2023 RhodeCode GmbH |
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -84,8 +83,8 b' def LoginForm(localizer):' | |||||
84 | min=1, |
|
83 | min=1, | |
85 | not_empty=True, |
|
84 | not_empty=True, | |
86 | messages={ |
|
85 | messages={ | |
87 |
'empty': _( |
|
86 | 'empty': _('Please enter a login'), | |
88 |
'tooShort': _( |
|
87 | 'tooShort': _('Enter a value %(min)i characters long or more') | |
89 | } |
|
88 | } | |
90 | ) |
|
89 | ) | |
91 |
|
90 | |||
@@ -95,8 +94,8 b' def LoginForm(localizer):' | |||||
95 | max=72, |
|
94 | max=72, | |
96 | not_empty=True, |
|
95 | not_empty=True, | |
97 | messages={ |
|
96 | messages={ | |
98 |
'empty': _( |
|
97 | 'empty': _('Please enter a password'), | |
99 |
'tooShort': _( |
|
98 | 'tooShort': _('Enter %(min)i characters or more')} | |
100 | ) |
|
99 | ) | |
101 |
|
100 | |||
102 | remember = v.StringBoolean(if_missing=False) |
|
101 | remember = v.StringBoolean(if_missing=False) | |
@@ -322,7 +321,7 b' def RepoFieldForm(localizer):' | |||||
322 |
|
321 | |||
323 | new_field_key = All(v.FieldKey(localizer), |
|
322 | new_field_key = All(v.FieldKey(localizer), | |
324 | v.UnicodeString(strip=True, min=3, not_empty=True)) |
|
323 | v.UnicodeString(strip=True, min=3, not_empty=True)) | |
325 |
new_field_value = v.UnicodeString(not_empty=False, if_missing= |
|
324 | new_field_value = v.UnicodeString(not_empty=False, if_missing='') | |
326 | new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'], |
|
325 | new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'], | |
327 | if_missing='str') |
|
326 | if_missing='str') | |
328 | new_field_label = v.UnicodeString(not_empty=False) |
|
327 | new_field_label = v.UnicodeString(not_empty=False) |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2013-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -102,7 +100,7 b' class GistModel(BaseModel):' | |||||
102 | repo = Gist.get_by_access_id(gist_access_id) |
|
100 | repo = Gist.get_by_access_id(gist_access_id) | |
103 | vcs_repo = repo.scm_instance() |
|
101 | vcs_repo = repo.scm_instance() | |
104 | if not vcs_repo: |
|
102 | if not vcs_repo: | |
105 |
raise VCSError('Failed to load gist repository for {}' |
|
103 | raise VCSError(f'Failed to load gist repository for {repo}') | |
106 |
|
104 | |||
107 | commit = vcs_repo.get_commit(commit_id=revision) |
|
105 | commit = vcs_repo.get_commit(commit_id=revision) | |
108 | return commit, [n for n in commit.get_node('/')] |
|
106 | return commit, [n for n in commit.get_node('/')] |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -391,7 +389,7 b' class EmailNotificationModel(BaseModel):' | |||||
391 | EmailNotificationModel.TYPE_TEST, **email_kwargs) |
|
389 | EmailNotificationModel.TYPE_TEST, **email_kwargs) | |
392 |
|
390 | |||
393 | """ |
|
391 | """ | |
394 |
super( |
|
392 | super().__init__() | |
395 | self.rhodecode_instance_name = rhodecode.CONFIG.get('rhodecode_title') |
|
393 | self.rhodecode_instance_name = rhodecode.CONFIG.get('rhodecode_title') | |
396 |
|
394 | |||
397 | def _update_kwargs_for_render(self, kwargs): |
|
395 | def _update_kwargs_for_render(self, kwargs): |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -283,7 +282,7 b' class PermissionModel(BaseModel):' | |||||
283 | # at that stage we validate all are passed inside form_result |
|
282 | # at that stage we validate all are passed inside form_result | |
284 | for _perm_key, perm_value in _global_perms.items(): |
|
283 | for _perm_key, perm_value in _global_perms.items(): | |
285 | if perm_value is None: |
|
284 | if perm_value is None: | |
286 |
raise ValueError('Missing permission for |
|
285 | raise ValueError('Missing permission for {}'.format(_perm_key)) | |
287 |
|
286 | |||
288 | if obj_type == 'user': |
|
287 | if obj_type == 'user': | |
289 | p = self._make_new_user_perm(to_object, perm_value) |
|
288 | p = self._make_new_user_perm(to_object, perm_value) |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2012-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -1067,7 +1066,7 b' class RepoModel(BaseModel):' | |||||
1067 |
|
1066 | |||
1068 | _now = datetime.datetime.now() |
|
1067 | _now = datetime.datetime.now() | |
1069 | _ms = str(_now.microsecond).rjust(6, '0') |
|
1068 | _ms = str(_now.microsecond).rjust(6, '0') | |
1070 |
_d = 'rm__ |
|
1069 | _d = 'rm__{}__{}'.format(_now.strftime('%Y%m%d_%H%M%S_' + _ms), | |
1071 | repo.just_name) |
|
1070 | repo.just_name) | |
1072 | if repo_group: |
|
1071 | if repo_group: | |
1073 | # if repository is in group, prefix the removal path with the group |
|
1072 | # if repository is in group, prefix the removal path with the group | |
@@ -1196,4 +1195,4 b' class ReadmeMatch:' | |||||
1196 | return self.node.path |
|
1195 | return self.node.path | |
1197 |
|
1196 | |||
1198 | def __repr__(self): |
|
1197 | def __repr__(self): | |
1199 |
return '<ReadmeMatch { |
|
1198 | return f'<ReadmeMatch {self.path} priority={self.priority}' |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -173,7 +171,7 b' class RepoGroupModel(BaseModel):' | |||||
173 | if os.path.isdir(create_path): |
|
171 | if os.path.isdir(create_path): | |
174 | if exc_on_failure: |
|
172 | if exc_on_failure: | |
175 | abs_create_path = os.path.abspath(create_path) |
|
173 | abs_create_path = os.path.abspath(create_path) | |
176 |
raise Exception('Directory `{}` already exists !' |
|
174 | raise Exception(f'Directory `{abs_create_path}` already exists !') | |
177 | return False |
|
175 | return False | |
178 | return True |
|
176 | return True | |
179 |
|
177 | |||
@@ -234,7 +232,7 b' class RepoGroupModel(BaseModel):' | |||||
234 | # archive that group` |
|
232 | # archive that group` | |
235 | _now = datetime.datetime.now() |
|
233 | _now = datetime.datetime.now() | |
236 | _ms = str(_now.microsecond).rjust(6, '0') |
|
234 | _ms = str(_now.microsecond).rjust(6, '0') | |
237 |
_d = 'rm__ |
|
235 | _d = 'rm__{}_GROUP_{}'.format( | |
238 | _now.strftime('%Y%m%d_%H%M%S_' + _ms), group.name) |
|
236 | _now.strftime('%Y%m%d_%H%M%S_' + _ms), group.name) | |
239 | shutil.move(rm_path, os.path.join(self.repos_path, _d)) |
|
237 | shutil.move(rm_path, os.path.join(self.repos_path, _d)) | |
240 |
|
238 |
@@ -1,5 +1,3 b'' | |||||
1 |
|
||||
2 |
|
||||
3 |
|
|
1 | # Copyright (C) 2011-2023 RhodeCode GmbH | |
4 | # |
|
2 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify |
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -61,7 +60,7 b' class UserTemp(object):' | |||||
61 | self.user_id = user_id |
|
60 | self.user_id = user_id | |
62 |
|
61 | |||
63 | def __repr__(self): |
|
62 | def __repr__(self): | |
64 |
return "< |
|
63 | return "<{}('id:{}')>".format(self.__class__.__name__, self.user_id) | |
65 |
|
64 | |||
66 |
|
65 | |||
67 | class RepoTemp(object): |
|
66 | class RepoTemp(object): | |
@@ -69,7 +68,7 b' class RepoTemp(object):' | |||||
69 | self.repo_id = repo_id |
|
68 | self.repo_id = repo_id | |
70 |
|
69 | |||
71 | def __repr__(self): |
|
70 | def __repr__(self): | |
72 |
return "< |
|
71 | return "<{}('id:{}')>".format(self.__class__.__name__, self.repo_id) | |
73 |
|
72 | |||
74 |
|
73 | |||
75 | class SimpleCachedRepoList(object): |
|
74 | class SimpleCachedRepoList(object): | |
@@ -91,7 +90,7 b' class SimpleCachedRepoList(object):' | |||||
91 | return len(self.db_repo_list) |
|
90 | return len(self.db_repo_list) | |
92 |
|
91 | |||
93 | def __repr__(self): |
|
92 | def __repr__(self): | |
94 |
return '< |
|
93 | return '<{} ({})>'.format(self.__class__.__name__, self.__len__()) | |
95 |
|
94 | |||
96 | def __iter__(self): |
|
95 | def __iter__(self): | |
97 | for dbr in self.db_repo_list: |
|
96 | for dbr in self.db_repo_list: | |
@@ -133,7 +132,7 b' class _PermCheckIterator(object):' | |||||
133 | return len(self.obj_list) |
|
132 | return len(self.obj_list) | |
134 |
|
133 | |||
135 | def __repr__(self): |
|
134 | def __repr__(self): | |
136 |
return '< |
|
135 | return '<{} ({})>'.format(self.__class__.__name__, self.__len__()) | |
137 |
|
136 | |||
138 | def __iter__(self): |
|
137 | def __iter__(self): | |
139 | for db_obj in self.obj_list: |
|
138 | for db_obj in self.obj_list: | |
@@ -152,7 +151,7 b' class RepoList(_PermCheckIterator):' | |||||
152 | if not perm_set: |
|
151 | if not perm_set: | |
153 | perm_set = ['repository.read', 'repository.write', 'repository.admin'] |
|
152 | perm_set = ['repository.read', 'repository.write', 'repository.admin'] | |
154 |
|
153 | |||
155 |
super( |
|
154 | super().__init__( | |
156 | obj_list=db_repo_list, |
|
155 | obj_list=db_repo_list, | |
157 | obj_attr='_repo_name', perm_set=perm_set, |
|
156 | obj_attr='_repo_name', perm_set=perm_set, | |
158 | perm_checker=HasRepoPermissionAny, |
|
157 | perm_checker=HasRepoPermissionAny, | |
@@ -165,7 +164,7 b' class RepoGroupList(_PermCheckIterator):' | |||||
165 | if not perm_set: |
|
164 | if not perm_set: | |
166 | perm_set = ['group.read', 'group.write', 'group.admin'] |
|
165 | perm_set = ['group.read', 'group.write', 'group.admin'] | |
167 |
|
166 | |||
168 |
super( |
|
167 | super().__init__( | |
169 | obj_list=db_repo_group_list, |
|
168 | obj_list=db_repo_group_list, | |
170 | obj_attr='_group_name', perm_set=perm_set, |
|
169 | obj_attr='_group_name', perm_set=perm_set, | |
171 | perm_checker=HasRepoGroupPermissionAny, |
|
170 | perm_checker=HasRepoGroupPermissionAny, | |
@@ -178,7 +177,7 b' class UserGroupList(_PermCheckIterator):' | |||||
178 | if not perm_set: |
|
177 | if not perm_set: | |
179 | perm_set = ['usergroup.read', 'usergroup.write', 'usergroup.admin'] |
|
178 | perm_set = ['usergroup.read', 'usergroup.write', 'usergroup.admin'] | |
180 |
|
179 | |||
181 |
super( |
|
180 | super().__init__( | |
182 | obj_list=db_user_group_list, |
|
181 | obj_list=db_user_group_list, | |
183 | obj_attr='users_group_name', perm_set=perm_set, |
|
182 | obj_attr='users_group_name', perm_set=perm_set, | |
184 | perm_checker=HasUserGroupPermissionAny, |
|
183 | perm_checker=HasUserGroupPermissionAny, | |
@@ -284,7 +283,7 b' class ScmModel(BaseModel):' | |||||
284 | config.set('extensions', 'largefiles', '') |
|
283 | config.set('extensions', 'largefiles', '') | |
285 | repo.update_commit_cache(config=config, cs_cache=None) |
|
284 | repo.update_commit_cache(config=config, cs_cache=None) | |
286 | if delete: |
|
285 | if delete: | |
287 |
cache_namespace_uid = 'cache_repo.{}' |
|
286 | cache_namespace_uid = f'cache_repo.{repo_id}' | |
288 | rc_cache.clear_cache_namespace('cache_repo', cache_namespace_uid, method=rc_cache.CLEAR_INVALIDATE) |
|
287 | rc_cache.clear_cache_namespace('cache_repo', cache_namespace_uid, method=rc_cache.CLEAR_INVALIDATE) | |
289 |
|
288 | |||
290 | def toggle_following_repo(self, follow_repo_id, user_id): |
|
289 | def toggle_following_repo(self, follow_repo_id, user_id): |
@@ -87,7 +87,7 b' class UserModel(BaseModel):' | |||||
87 | query = query.filter(User.active == true()) |
|
87 | query = query.filter(User.active == true()) | |
88 |
|
88 | |||
89 | if name_contains: |
|
89 | if name_contains: | |
90 |
ilike_expression = |
|
90 | ilike_expression = f'%{safe_str(name_contains)}%' | |
91 | query = query.filter( |
|
91 | query = query.filter( | |
92 | or_( |
|
92 | or_( | |
93 | User.name.ilike(ilike_expression), |
|
93 | User.name.ilike(ilike_expression), | |
@@ -387,7 +387,7 b' class UserModel(BaseModel):' | |||||
387 | self.add_auth_token( |
|
387 | self.add_auth_token( | |
388 | user=username, lifetime_minutes=-1, |
|
388 | user=username, lifetime_minutes=-1, | |
389 | role=self.auth_token_role.ROLE_FEED, |
|
389 | role=self.auth_token_role.ROLE_FEED, | |
390 |
description= |
|
390 | description='Generated feed token') | |
391 |
|
391 | |||
392 | kwargs = new_user.get_dict() |
|
392 | kwargs = new_user.get_dict() | |
393 | # backward compat, require api_keys present |
|
393 | # backward compat, require api_keys present |
@@ -129,7 +129,7 b' def UniqueListFromString(localizer):' | |||||
129 | def _convert_to_python(self, value, state): |
|
129 | def _convert_to_python(self, value, state): | |
130 | if isinstance(value, str): |
|
130 | if isinstance(value, str): | |
131 | value = aslist(value, ',') |
|
131 | value = aslist(value, ',') | |
132 |
return super( |
|
132 | return super()._convert_to_python(value, state) | |
133 | return _validator |
|
133 | return _validator | |
134 |
|
134 | |||
135 |
|
135 | |||
@@ -951,7 +951,7 b' def ValidIp(localizer):' | |||||
951 |
|
951 | |||
952 | # we override the default to_python() call |
|
952 | # we override the default to_python() call | |
953 | def to_python(self, value, state): |
|
953 | def to_python(self, value, state): | |
954 |
v = super( |
|
954 | v = super().to_python(value, state) | |
955 | v = safe_str(v.strip()) |
|
955 | v = safe_str(v.strip()) | |
956 | net = ipaddress.ip_network(address=v, strict=False) |
|
956 | net = ipaddress.ip_network(address=v, strict=False) | |
957 | return str(net) |
|
957 | return str(net) | |
@@ -1078,7 +1078,7 b' def ValidPattern(localizer):' | |||||
1078 | new_item_id = name[len(pattern_name)+1:] |
|
1078 | new_item_id = name[len(pattern_name)+1:] | |
1079 |
|
1079 | |||
1080 | def _field(name): |
|
1080 | def _field(name): | |
1081 |
return ' |
|
1081 | return '{}_{}_{}'.format(prefix, name, new_item_id) | |
1082 |
|
1082 | |||
1083 | values = { |
|
1083 | values = { | |
1084 | 'issuetracker_pat': value.get(_field('pattern')), |
|
1084 | 'issuetracker_pat': value.get(_field('pattern')), |
General Comments 0
You need to be logged in to leave comments.
Login now