##// END OF EJS Templates
python3: fixes and code optimization for python3.11
super-admin -
r1114:8a549c84 python3
parent child Browse files
Show More
@@ -64,7 +64,7 b' def obfuscate_qs(query_string):'
64 parsed.append((k, v))
64 parsed.append((k, v))
65
65
66 return '&'.join('{}{}'.format(
66 return '&'.join('{}{}'.format(
67 k, '={}'.format(v) if v else '') for k, v in parsed)
67 k, f'={v}' if v else '') for k, v in parsed)
68
68
69
69
70 def raise_from_original(new_type, org_exc: Exception):
70 def raise_from_original(new_type, org_exc: Exception):
@@ -109,7 +109,7 b' class HTTPRepoLocked(HTTPLocked):'
109 def __init__(self, title, status_code=None, **kwargs):
109 def __init__(self, title, status_code=None, **kwargs):
110 self.code = status_code or HTTPLocked.code
110 self.code = status_code or HTTPLocked.code
111 self.title = title
111 self.title = title
112 super(HTTPRepoLocked, self).__init__(**kwargs)
112 super().__init__(**kwargs)
113
113
114
114
115 class HTTPRepoBranchProtected(HTTPForbidden):
115 class HTTPRepoBranchProtected(HTTPForbidden):
@@ -1,5 +1,3 b''
1 # -*- coding: utf-8 -*-
2
3 # RhodeCode VCSServer provides access to different vcs backends via network.
1 # RhodeCode VCSServer provides access to different vcs backends via network.
4 # Copyright (C) 2014-2020 RhodeCode GmbH
2 # Copyright (C) 2014-2020 RhodeCode GmbH
5 #
3 #
@@ -553,7 +551,7 b' def git_pre_receive(unused_repo_path, re'
553 if type_ == 'heads' and not (new_branch or delete_branch):
551 if type_ == 'heads' and not (new_branch or delete_branch):
554 old_rev = push_ref['old_rev']
552 old_rev = push_ref['old_rev']
555 new_rev = push_ref['new_rev']
553 new_rev = push_ref['new_rev']
556 cmd = [settings.GIT_EXECUTABLE, 'rev-list', old_rev, '^{}'.format(new_rev)]
554 cmd = [settings.GIT_EXECUTABLE, 'rev-list', old_rev, f'^{new_rev}']
557 stdout, stderr = subprocessio.run_command(
555 stdout, stderr = subprocessio.run_command(
558 cmd, env=os.environ.copy())
556 cmd, env=os.environ.copy())
559 # means we're having some non-reachable objects, this forced push was used
557 # means we're having some non-reachable objects, this forced push was used
@@ -206,7 +206,7 b' class VCSViewPredicate(object):'
206 self.remotes = val
206 self.remotes = val
207
207
208 def text(self):
208 def text(self):
209 return 'vcs view method = %s' % (list(self.remotes.keys()),)
209 return f'vcs view method = {list(self.remotes.keys())}'
210
210
211 phash = text
211 phash = text
212
212
@@ -368,7 +368,7 b' class HTTPApplication(object):'
368 if statsd:
368 if statsd:
369 statsd.incr(
369 statsd.incr(
370 'vcsserver_method_total', tags=[
370 'vcsserver_method_total', tags=[
371 "method:{}".format(method),
371 f"method:{method}",
372 ])
372 ])
373 return payload, remote, method, args, kwargs
373 return payload, remote, method, args, kwargs
374
374
@@ -673,9 +673,9 b' class HTTPApplication(object):'
673
673
674 statsd = request.registry.statsd
674 statsd = request.registry.statsd
675 if statsd:
675 if statsd:
676 exc_type = "{}.{}".format(exception.__class__.__module__, exception.__class__.__name__)
676 exc_type = f"{exception.__class__.__module__}.{exception.__class__.__name__}"
677 statsd.incr('vcsserver_exception_total',
677 statsd.incr('vcsserver_exception_total',
678 tags=["type:{}".format(exc_type)])
678 tags=[f"type:{exc_type}"])
679 raise exception
679 raise exception
680
680
681
681
@@ -1,5 +1,3 b''
1 # -*- coding: utf-8 -*-
2
3 # RhodeCode VCSServer provides access to different vcs backends via network.
1 # RhodeCode VCSServer provides access to different vcs backends via network.
4 # Copyright (C) 2014-2020 RhodeCode GmbH
2 # Copyright (C) 2014-2020 RhodeCode GmbH
5 #
3 #
@@ -126,10 +124,10 b' def store_exception(exc_id, exc_info, pr'
126 def _find_exc_file(exc_id, prefix=global_prefix):
124 def _find_exc_file(exc_id, prefix=global_prefix):
127 exc_store_path = get_exc_store()
125 exc_store_path = get_exc_store()
128 if prefix:
126 if prefix:
129 exc_id = '{}_{}'.format(exc_id, prefix)
127 exc_id = f'{exc_id}_{prefix}'
130 else:
128 else:
131 # search without a prefix
129 # search without a prefix
132 exc_id = '{}'.format(exc_id)
130 exc_id = f'{exc_id}'
133
131
134 # we need to search the store for such start pattern as above
132 # we need to search the store for such start pattern as above
135 for fname in os.listdir(exc_store_path):
133 for fname in os.listdir(exc_store_path):
@@ -1,5 +1,3 b''
1 # -*- coding: utf-8 -*-
2
3 # RhodeCode VCSServer provides access to different vcs backends via network.
1 # RhodeCode VCSServer provides access to different vcs backends via network.
4 # Copyright (C) 2014-2020 RhodeCode GmbH
2 # Copyright (C) 2014-2020 RhodeCode GmbH
5 #
3 #
@@ -53,11 +51,11 b' class LRUDictDebug(LRUDict):'
53 Wrapper to provide some debug options
51 Wrapper to provide some debug options
54 """
52 """
55 def _report_keys(self):
53 def _report_keys(self):
56 elems_cnt = '%s/%s' % (len(list(self.keys())), self.size)
54 elems_cnt = '{}/{}'.format(len(list(self.keys())), self.size)
57 # trick for pformat print it more nicely
55 # trick for pformat print it more nicely
58 fmt = '\n'
56 fmt = '\n'
59 for cnt, elem in enumerate(self.keys()):
57 for cnt, elem in enumerate(self.keys()):
60 fmt += '%s - %s\n' % (cnt+1, safe_str(elem))
58 fmt += '{} - {}\n'.format(cnt+1, safe_str(elem))
61 log.debug('current LRU keys (%s):%s', elems_cnt, fmt)
59 log.debug('current LRU keys (%s):%s', elems_cnt, fmt)
62
60
63 def __getitem__(self, key):
61 def __getitem__(self, key):
@@ -1,5 +1,3 b''
1 # -*- coding: utf-8 -*-
2
3 # RhodeCode VCSServer provides access to different vcs backends via network.
1 # RhodeCode VCSServer provides access to different vcs backends via network.
4 # Copyright (C) 2014-2020 RhodeCode GmbH
2 # Copyright (C) 2014-2020 RhodeCode GmbH
5 #
3 #
@@ -58,7 +58,7 b' class LRUMemoryBackend(memory_backend.Me'
58 LRUDictClass = LRUDictDebug
58 LRUDictClass = LRUDictDebug
59
59
60 arguments['cache_dict'] = LRUDictClass(self.max_size)
60 arguments['cache_dict'] = LRUDictClass(self.max_size)
61 super(LRUMemoryBackend, self).__init__(arguments)
61 super().__init__(arguments)
62
62
63 def __repr__(self):
63 def __repr__(self):
64 return f'{self.__class__}(maxsize=`{self.max_size}`)'
64 return f'{self.__class__}(maxsize=`{self.max_size}`)'
@@ -79,19 +79,19 b' class LRUMemoryBackend(memory_backend.Me'
79
79
80
80
81 class PickleSerializer:
81 class PickleSerializer:
82 serializer: Union[None, Serializer] = staticmethod( # type: ignore
82 serializer: None | Serializer = staticmethod( # type: ignore
83 functools.partial(pickle.dumps, protocol=pickle.HIGHEST_PROTOCOL)
83 functools.partial(pickle.dumps, protocol=pickle.HIGHEST_PROTOCOL)
84 )
84 )
85 deserializer: Union[None, Deserializer] = staticmethod( # type: ignore
85 deserializer: None | Deserializer = staticmethod( # type: ignore
86 functools.partial(pickle.loads)
86 functools.partial(pickle.loads)
87 )
87 )
88
88
89
89
90 class MsgPackSerializer(object):
90 class MsgPackSerializer(object):
91 serializer: Union[None, Serializer] = staticmethod( # type: ignore
91 serializer: None | Serializer = staticmethod( # type: ignore
92 msgpack.packb
92 msgpack.packb
93 )
93 )
94 deserializer: Union[None, Deserializer] = staticmethod( # type: ignore
94 deserializer: None | Deserializer = staticmethod( # type: ignore
95 functools.partial(msgpack.unpackb, use_list=False)
95 functools.partial(msgpack.unpackb, use_list=False)
96 )
96 )
97
97
@@ -114,7 +114,7 b' class FileNamespaceBackend(PickleSeriali'
114 os.makedirs(db_file_dir)
114 os.makedirs(db_file_dir)
115
115
116 try:
116 try:
117 super(FileNamespaceBackend, self).__init__(arguments)
117 super().__init__(arguments)
118 except Exception:
118 except Exception:
119 log.exception('Failed to initialize db at: %s', db_file)
119 log.exception('Failed to initialize db at: %s', db_file)
120 raise
120 raise
@@ -152,7 +152,7 b' class BaseRedisBackend(redis_backend.Red'
152
152
153 def __init__(self, arguments):
153 def __init__(self, arguments):
154 self.db_conn = arguments.get('host', '') or arguments.get('url', '') or 'redis-host'
154 self.db_conn = arguments.get('host', '') or arguments.get('url', '') or 'redis-host'
155 super(BaseRedisBackend, self).__init__(arguments)
155 super().__init__(arguments)
156
156
157 self._lock_timeout = self.lock_timeout
157 self._lock_timeout = self.lock_timeout
158 self._lock_auto_renewal = str2bool(arguments.pop("lock_auto_renewal", True))
158 self._lock_auto_renewal = str2bool(arguments.pop("lock_auto_renewal", True))
@@ -168,7 +168,7 b' def get_or_create_region(region_name, re'
168 region_obj = region_meta.dogpile_cache_regions.get(region_name)
168 region_obj = region_meta.dogpile_cache_regions.get(region_name)
169 if not region_obj:
169 if not region_obj:
170 reg_keys = list(region_meta.dogpile_cache_regions.keys())
170 reg_keys = list(region_meta.dogpile_cache_regions.keys())
171 raise EnvironmentError(f'Region `{region_name}` not in configured: {reg_keys}.')
171 raise OSError(f'Region `{region_name}` not in configured: {reg_keys}.')
172
172
173 region_uid_name = f'{region_name}:{region_namespace}'
173 region_uid_name = f'{region_name}:{region_namespace}'
174
174
@@ -1,5 +1,3 b''
1 # -*- coding: utf-8 -*-
2
3 # RhodeCode VCSServer provides access to different vcs backends via network.
1 # RhodeCode VCSServer provides access to different vcs backends via network.
4 # Copyright (C) 2014-2020 RhodeCode GmbH
2 # Copyright (C) 2014-2020 RhodeCode GmbH
5 #
3 #
@@ -29,7 +29,7 b' class _Singleton(type):'
29
29
30 def __call__(cls, *args, **kwargs):
30 def __call__(cls, *args, **kwargs):
31 if cls not in cls._instances:
31 if cls not in cls._instances:
32 cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
32 cls._instances[cls] = super().__call__(*args, **kwargs)
33 return cls._instances[cls]
33 return cls._instances[cls]
34
34
35
35
@@ -47,13 +47,13 b' class StatsdClientClass(Singleton):'
47
47
48 if name.startswith("statsd"):
48 if name.startswith("statsd"):
49 if self.setup_run:
49 if self.setup_run:
50 return super(StatsdClientClass, self).__getattribute__(name)
50 return super().__getattribute__(name)
51 else:
51 else:
52 if self.strict_mode_init:
52 if self.strict_mode_init:
53 raise StatsdClientNotInitialised(f"requested key was {name}")
53 raise StatsdClientNotInitialised(f"requested key was {name}")
54 return None
54 return None
55
55
56 return super(StatsdClientClass, self).__getattribute__(name)
56 return super().__getattribute__(name)
57
57
58 def setup(self, settings):
58 def setup(self, settings):
59 """
59 """
@@ -56,7 +56,7 b' class FileWrapper(object):'
56 return data
56 return data
57
57
58 def __repr__(self):
58 def __repr__(self):
59 return '<FileWrapper %s len: %s, read: %s>' % (
59 return '<FileWrapper {} len: {}, read: {}>'.format(
60 self.fd, self.content_length, self.content_length - self.remain
60 self.fd, self.content_length, self.content_length - self.remain
61 )
61 )
62
62
@@ -66,7 +66,7 b' class GitRepository(object):'
66
66
67 git_folder_signature = frozenset(('config', 'head', 'info', 'objects', 'refs'))
67 git_folder_signature = frozenset(('config', 'head', 'info', 'objects', 'refs'))
68 commands = frozenset(('git-upload-pack', 'git-receive-pack'))
68 commands = frozenset(('git-upload-pack', 'git-receive-pack'))
69 valid_accepts = frozenset(('application/x-{}-result'.format(c) for c in commands))
69 valid_accepts = frozenset(f'application/x-{c}-result' for c in commands)
70
70
71 # The last bytes are the SHA1 of the first 12 bytes.
71 # The last bytes are the SHA1 of the first 12 bytes.
72 EMPTY_PACK = (
72 EMPTY_PACK = (
@@ -330,7 +330,7 b' class GitRepository(object):'
330 inputstream = request.body_file_seekable
330 inputstream = request.body_file_seekable
331
331
332 resp = Response()
332 resp = Response()
333 resp.content_type = 'application/x-{}-result'.format(git_command)
333 resp.content_type = f'application/x-{git_command}-result'
334 resp.charset = None
334 resp.charset = None
335
335
336 pre_pull_messages = ''
336 pre_pull_messages = ''
@@ -142,7 +142,7 b' class GitRemote(RemoteBase):'
142
142
143 def _wire_to_config(self, wire):
143 def _wire_to_config(self, wire):
144 if 'config' in wire:
144 if 'config' in wire:
145 return dict([(x[0] + '_' + x[1], x[2]) for x in wire['config']])
145 return {x[0] + '_' + x[1]: x[2] for x in wire['config']}
146 return {}
146 return {}
147
147
148 def _remote_conf(self, config):
148 def _remote_conf(self, config):
@@ -151,7 +151,7 b' class GitRemote(RemoteBase):'
151 ]
151 ]
152 ssl_cert_dir = config.get('vcs_ssl_dir')
152 ssl_cert_dir = config.get('vcs_ssl_dir')
153 if ssl_cert_dir:
153 if ssl_cert_dir:
154 params.extend(['-c', 'http.sslCAinfo={}'.format(ssl_cert_dir)])
154 params.extend(['-c', f'http.sslCAinfo={ssl_cert_dir}'])
155 return params
155 return params
156
156
157 @reraise_safe_exceptions
157 @reraise_safe_exceptions
@@ -321,7 +321,7 b' class GitRemote(RemoteBase):'
321 store = LFSOidStore(
321 store = LFSOidStore(
322 oid=oid, repo=repo_name, store_location=store_location)
322 oid=oid, repo=repo_name, store_location=store_location)
323 return store.oid_path
323 return store.oid_path
324 raise ValueError('Unable to fetch oid with path {}'.format(oid))
324 raise ValueError(f'Unable to fetch oid with path {oid}')
325
325
326 @reraise_safe_exceptions
326 @reraise_safe_exceptions
327 def bulk_request(self, wire, rev, pre_load):
327 def bulk_request(self, wire, rev, pre_load):
@@ -383,7 +383,7 b' class GitRemote(RemoteBase):'
383
383
384 q = {"service": 'git-upload-pack'}
384 q = {"service": 'git-upload-pack'}
385 qs = '?%s' % urllib.parse.urlencode(q)
385 qs = '?%s' % urllib.parse.urlencode(q)
386 cu = "%s%s" % (test_uri, qs)
386 cu = "{}{}".format(test_uri, qs)
387 req = urllib.request.Request(cu, None, {})
387 req = urllib.request.Request(cu, None, {})
388
388
389 try:
389 try:
@@ -394,7 +394,7 b' class GitRemote(RemoteBase):'
394 except Exception as e:
394 except Exception as e:
395 log.warning("URL cannot be opened: %s", cleaned_uri, exc_info=True)
395 log.warning("URL cannot be opened: %s", cleaned_uri, exc_info=True)
396 # means it cannot be cloned
396 # means it cannot be cloned
397 raise exceptions.URLError(e)("[%s] org_exc: %s" % (cleaned_uri, e))
397 raise exceptions.URLError(e)("[{}] org_exc: {}".format(cleaned_uri, e))
398
398
399 # now detect if it's proper git repo
399 # now detect if it's proper git repo
400 gitdata = resp.read()
400 gitdata = resp.read()
@@ -405,7 +405,7 b' class GitRemote(RemoteBase):'
405 pass
405 pass
406 else:
406 else:
407 raise exceptions.URLError()(
407 raise exceptions.URLError()(
408 "url [%s] does not look like an git" % (cleaned_uri,))
408 "url [{}] does not look like an git".format(cleaned_uri))
409
409
410 return True
410 return True
411
411
@@ -943,12 +943,12 b' class GitRemote(RemoteBase):'
943 author = commit.get_object().author
943 author = commit.get_object().author
944
944
945 if author.email:
945 if author.email:
946 return "{} <{}>".format(author.name, author.email)
946 return f"{author.name} <{author.email}>"
947
947
948 try:
948 try:
949 return "{}".format(author.name)
949 return f"{author.name}"
950 except Exception:
950 except Exception:
951 return "{}".format(safe_str(author.raw_name))
951 return f"{safe_str(author.raw_name)}"
952
952
953 return _author(repo_id, commit_id)
953 return _author(repo_id, commit_id)
954
954
@@ -997,7 +997,7 b' class GitRemote(RemoteBase):'
997 wire, ['rev-list', '--all', '--children', f'{commit_id}^..{head}'])
997 wire, ['rev-list', '--all', '--children', f'{commit_id}^..{head}'])
998
998
999 child_ids = []
999 child_ids = []
1000 pat = re.compile(r'^{}'.format(commit_id))
1000 pat = re.compile(fr'^{commit_id}')
1001 for line in output.splitlines():
1001 for line in output.splitlines():
1002 line = safe_str(line)
1002 line = safe_str(line)
1003 if pat.match(line):
1003 if pat.match(line):
@@ -1036,7 +1036,7 b' class GitRemote(RemoteBase):'
1036 def tag_remove(self, wire, tag_name):
1036 def tag_remove(self, wire, tag_name):
1037 repo_init = self._factory.repo_libgit2(wire)
1037 repo_init = self._factory.repo_libgit2(wire)
1038 with repo_init as repo:
1038 with repo_init as repo:
1039 key = 'refs/tags/{}'.format(tag_name)
1039 key = f'refs/tags/{tag_name}'
1040 repo.references.delete(key)
1040 repo.references.delete(key)
1041
1041
1042 @reraise_safe_exceptions
1042 @reraise_safe_exceptions
@@ -1081,7 +1081,7 b' class GitRemote(RemoteBase):'
1081 try:
1081 try:
1082 tree = repo[tree_id]
1082 tree = repo[tree_id]
1083 except KeyError:
1083 except KeyError:
1084 raise ObjectMissing('No tree with id: {}'.format(tree_id))
1084 raise ObjectMissing(f'No tree with id: {tree_id}')
1085
1085
1086 result = []
1086 result = []
1087 for item in tree:
1087 for item in tree:
@@ -1363,7 +1363,7 b' class GitRemote(RemoteBase):'
1363 try:
1363 try:
1364 tree = repo[tree_id]
1364 tree = repo[tree_id]
1365 except KeyError:
1365 except KeyError:
1366 raise ObjectMissing('No tree with id: {}'.format(tree_id))
1366 raise ObjectMissing(f'No tree with id: {tree_id}')
1367
1367
1368 index = LibGit2Index.Index()
1368 index = LibGit2Index.Index()
1369 index.read_tree(tree)
1369 index.read_tree(tree)
@@ -431,9 +431,9 b' class HgRemote(RemoteBase):'
431 ('Accept', 'application/mercurial-0.1')]
431 ('Accept', 'application/mercurial-0.1')]
432
432
433 q = {"cmd": 'between'}
433 q = {"cmd": 'between'}
434 q.update({'pairs': "%s-%s" % ('0' * 40, '0' * 40)})
434 q.update({'pairs': "{}-{}".format('0' * 40, '0' * 40)})
435 qs = '?%s' % urllib.parse.urlencode(q)
435 qs = '?%s' % urllib.parse.urlencode(q)
436 cu = "%s%s" % (test_uri, qs)
436 cu = "{}{}".format(test_uri, qs)
437 req = urllib.request.Request(cu, None, {})
437 req = urllib.request.Request(cu, None, {})
438
438
439 try:
439 try:
@@ -444,7 +444,7 b' class HgRemote(RemoteBase):'
444 except Exception as e:
444 except Exception as e:
445 log.warning("URL cannot be opened: %s", cleaned_uri, exc_info=True)
445 log.warning("URL cannot be opened: %s", cleaned_uri, exc_info=True)
446 # means it cannot be cloned
446 # means it cannot be cloned
447 raise exceptions.URLError(e)("[%s] org_exc: %s" % (cleaned_uri, e))
447 raise exceptions.URLError(e)("[{}] org_exc: {}".format(cleaned_uri, e))
448
448
449 # now check if it's a proper hg repo, but don't do it for svn
449 # now check if it's a proper hg repo, but don't do it for svn
450 try:
450 try:
@@ -138,7 +138,7 b' class SvnRemote(RemoteBase):'
138 tb = traceback.format_exc()
138 tb = traceback.format_exc()
139 log.debug("Invalid Subversion url: `%s`, tb: %s", url, tb)
139 log.debug("Invalid Subversion url: `%s`, tb: %s", url, tb)
140 raise URLError(
140 raise URLError(
141 '"%s" is not a valid Subversion source url.' % (url, ))
141 '"{}" is not a valid Subversion source url.'.format(url))
142 return True
142 return True
143
143
144 def is_path_valid_repository(self, wire, path):
144 def is_path_valid_repository(self, wire, path):
@@ -239,7 +239,7 b' class SvnRemote(RemoteBase):'
239 removed.append(path)
239 removed.append(path)
240 else:
240 else:
241 raise NotImplementedError(
241 raise NotImplementedError(
242 "Action %s not supported on path %s" % (
242 "Action {} not supported on path {}".format(
243 change.action, path))
243 change.action, path))
244
244
245 changes = {
245 changes = {
@@ -418,10 +418,10 b' class SvnRemote(RemoteBase):'
418 reason = 'INVALID_CERTIFICATE'
418 reason = 'INVALID_CERTIFICATE'
419
419
420 if reason == 'UNKNOWN':
420 if reason == 'UNKNOWN':
421 reason = 'UNKNOWN:{}'.format(safe_str(errors))
421 reason = f'UNKNOWN:{safe_str(errors)}'
422
422
423 raise Exception(
423 raise Exception(
424 'Failed to dump the remote repository from %s. Reason:%s' % (
424 'Failed to dump the remote repository from {}. Reason:{}'.format(
425 src_url, reason))
425 src_url, reason))
426 if load.returncode != 0:
426 if load.returncode != 0:
427 raise Exception(
427 raise Exception(
@@ -575,8 +575,7 b' class SvnRemote(RemoteBase):'
575 # return only DIR, and then all entries in that dir
575 # return only DIR, and then all entries in that dir
576 yield os.path.join(root_dir, f_name), {'mode': filemode_default}, f_type
576 yield os.path.join(root_dir, f_name), {'mode': filemode_default}, f_type
577 new_root = os.path.join(root_dir, f_name)
577 new_root = os.path.join(root_dir, f_name)
578 for _f_name, _f_data, _f_type in walk_tree(root, new_root, _commit_id):
578 yield from walk_tree(root, new_root, _commit_id)
579 yield _f_name, _f_data, _f_type
580 else:
579 else:
581
580
582 f_path = os.path.join(root_dir, f_name).rstrip(b'/')
581 f_path = os.path.join(root_dir, f_name).rstrip(b'/')
@@ -723,10 +722,10 b' class SvnDiffer(object):'
723 buf.write("=" * 67 + '\n')
722 buf.write("=" * 67 + '\n')
724 buf.write("Cannot display: file marked as a binary type.\n")
723 buf.write("Cannot display: file marked as a binary type.\n")
725 buf.write("svn:mime-type = %s\n" % mime_type)
724 buf.write("svn:mime-type = %s\n" % mime_type)
726 buf.write("Index: %s\n" % (tgt_path, ))
725 buf.write("Index: {}\n".format(tgt_path))
727 buf.write("=" * 67 + '\n')
726 buf.write("=" * 67 + '\n')
728 buf.write("diff --git a/%(tgt_path)s b/%(tgt_path)s\n" % {
727 buf.write("diff --git a/{tgt_path} b/{tgt_path}\n".format(
729 'tgt_path': tgt_path})
728 tgt_path=tgt_path))
730
729
731 if change == 'add':
730 if change == 'add':
732 # TODO: johbo: SVN is missing a zero here compared to git
731 # TODO: johbo: SVN is missing a zero here compared to git
@@ -746,15 +745,15 b' class SvnDiffer(object):'
746 # if self.binary_content:
745 # if self.binary_content:
747 # buf.write('GIT binary patch\n')
746 # buf.write('GIT binary patch\n')
748
747
749 buf.write("--- a/%s\t(revision %s)\n" % (
748 buf.write("--- a/{}\t(revision {})\n".format(
750 src_path, self.src_rev))
749 src_path, self.src_rev))
751 src_lines = self._svn_readlines(self.src_root, src_full_path)
750 src_lines = self._svn_readlines(self.src_root, src_full_path)
752
751
753 if change == 'delete':
752 if change == 'delete':
754 buf.write("+++ /dev/null\t(revision %s)\n" % (self.tgt_rev, ))
753 buf.write("+++ /dev/null\t(revision {})\n".format(self.tgt_rev))
755 tgt_lines = []
754 tgt_lines = []
756 else:
755 else:
757 buf.write("+++ b/%s\t(revision %s)\n" % (
756 buf.write("+++ b/{}\t(revision {})\n".format(
758 tgt_path, self.tgt_rev))
757 tgt_path, self.tgt_rev))
759 tgt_lines = self._svn_readlines(self.tgt_root, tgt_full_path)
758 tgt_lines = self._svn_readlines(self.tgt_root, tgt_full_path)
760
759
@@ -104,7 +104,7 b' class HgWeb(mercurial.hgweb.hgweb_mod.hg'
104 res.setbodybytes(b'')
104 res.setbodybytes(b'')
105 return res.sendresponse()
105 return res.sendresponse()
106
106
107 return super(HgWeb, self)._runwsgi(req, res, repo)
107 return super()._runwsgi(req, res, repo)
108
108
109
109
110 def make_hg_ui_from_config(repo_config):
110 def make_hg_ui_from_config(repo_config):
@@ -44,7 +44,7 b' def base64_to_str(text) -> str:'
44 return safe_str(base64.encodebytes(safe_bytes(text))).strip()
44 return safe_str(base64.encodebytes(safe_bytes(text))).strip()
45
45
46
46
47 def get_default_encodings() -> typing.List[str]:
47 def get_default_encodings() -> list[str]:
48 return ['utf8']
48 return ['utf8']
49
49
50
50
@@ -1,4 +1,3 b''
1 # -*- coding: utf-8 -*-
2 #
1 #
3 # Copyright (C) 2004-2009 Edgewall Software
2 # Copyright (C) 2004-2009 Edgewall Software
4 # Copyright (C) 2004-2006 Christopher Lenz <cmlenz@gmx.de>
3 # Copyright (C) 2004-2006 Christopher Lenz <cmlenz@gmx.de>
@@ -174,7 +173,7 b' def unified_diff(fromlines, tolines, con'
174 i1, i2 = -1, -1 # support for Add changes
173 i1, i2 = -1, -1 # support for Add changes
175 if j1 == 0 and j2 == 0:
174 if j1 == 0 and j2 == 0:
176 j1, j2 = -1, -1 # support for Delete changes
175 j1, j2 = -1, -1 # support for Delete changes
177 yield '@@ -%s +%s @@%s' % (
176 yield '@@ -{} +{} @@{}'.format(
178 _hunk_range(i1 + 1, i2 - i1),
177 _hunk_range(i1 + 1, i2 - i1),
179 _hunk_range(j1 + 1, j2 - j1),
178 _hunk_range(j1 + 1, j2 - j1),
180 lineterm)
179 lineterm)
@@ -41,7 +41,7 b' class StrictAttributeDict(AttributeDictB'
41 try:
41 try:
42 return self[attr]
42 return self[attr]
43 except KeyError:
43 except KeyError:
44 raise AttributeError('%s object has no attribute %s' % (
44 raise AttributeError('{} object has no attribute {}'.format(
45 self.__class__, attr))
45 self.__class__, attr))
46
46
47
47
@@ -28,7 +28,7 b' class RemoteBase(object):'
28
28
29 def _cache_on(self, wire):
29 def _cache_on(self, wire):
30 context = wire.get('context', '')
30 context = wire.get('context', '')
31 context_uid = '{}'.format(context)
31 context_uid = f'{context}'
32 repo_id = wire.get('repo_id', '')
32 repo_id = wire.get('repo_id', '')
33 cache = wire.get('cache', True)
33 cache = wire.get('cache', True)
34 cache_on = context and cache
34 cache_on = context and cache
General Comments 0
You need to be logged in to leave comments. Login now