# HG changeset patch # User Mads Kiilerich # Date 1577369789 -3600 # Node ID e35373106528b29461b7f5144780cb9ec79f765d # Parent 502d2fcbe43421e292c674e81ae4c86073c2955e py3: remove safe_unicode in places where it no longer is needed because all strings (except bytes) already *are* unicode strings (The remaining safe_unicode calls are still needed and can't just be removed, generally because we in these cases still have to convert from bytes to unicode strings.) diff -r 502d2fcbe434 -r e35373106528 kallithea/bin/kallithea_cli_repo.py --- a/kallithea/bin/kallithea_cli_repo.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/bin/kallithea_cli_repo.py Thu Dec 26 15:16:29 2019 +0100 @@ -28,7 +28,7 @@ import kallithea.bin.kallithea_cli_base as cli_base from kallithea.lib.utils import REMOVED_REPO_PAT, repo2db_mapper -from kallithea.lib.utils2 import ask_ok, safe_str, safe_unicode +from kallithea.lib.utils2 import ask_ok, safe_str from kallithea.model.db import Repository, Ui from kallithea.model.meta import Session from kallithea.model.scm import ScmModel @@ -74,7 +74,7 @@ if not repositories: repo_list = Repository.query().all() else: - repo_names = [safe_unicode(n.strip()) for n in repositories] + repo_names = [n.strip() for n in repositories] repo_list = list(Repository.query() .filter(Repository.repo_name.in_(repo_names))) diff -r 502d2fcbe434 -r e35373106528 kallithea/controllers/admin/gists.py --- a/kallithea/controllers/admin/gists.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/controllers/admin/gists.py Thu Dec 26 15:16:29 2019 +0100 @@ -182,7 +182,10 @@ log.error(traceback.format_exc()) raise HTTPNotFound() if format == 'raw': - content = '\n\n'.join([safe_unicode(f.content) for f in c.files if (f_path is None or safe_unicode(f.path) == f_path)]) + content = '\n\n'.join( + safe_unicode(f.content) + for f in c.files if (f_path is None or f.path == f_path) + ) response.content_type = 'text/plain' return content return render('admin/gists/show.html') diff -r 502d2fcbe434 -r e35373106528 kallithea/controllers/admin/repo_groups.py --- a/kallithea/controllers/admin/repo_groups.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/controllers/admin/repo_groups.py Thu Dec 26 15:16:29 2019 +0100 @@ -40,7 +40,7 @@ from kallithea.lib import helpers as h from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoGroupPermissionLevelDecorator, LoginRequired from kallithea.lib.base import BaseController, render -from kallithea.lib.utils2 import safe_int, safe_unicode +from kallithea.lib.utils2 import safe_int from kallithea.model.db import RepoGroup, Repository from kallithea.model.forms import RepoGroupForm, RepoGroupPermsForm from kallithea.model.meta import Session @@ -116,7 +116,7 @@ ) for repo_gr in group_iter: - children_groups = [safe_unicode(g.name) for g in repo_gr.parents] + [safe_unicode(repo_gr.name)] + children_groups = [g.name for g in repo_gr.parents] + [repo_gr.name] repo_count = repo_gr.repositories.count() repo_groups_data.append({ "raw_name": repo_gr.group_name, diff -r 502d2fcbe434 -r e35373106528 kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/controllers/changeset.py Thu Dec 26 15:16:29 2019 +0100 @@ -257,7 +257,7 @@ Session().commit() data = { - 'target_id': h.safeid(h.safe_unicode(request.POST.get('f_path'))), + 'target_id': h.safeid(request.POST.get('f_path')), } if comment is not None: c.comment = comment diff -r 502d2fcbe434 -r e35373106528 kallithea/controllers/feed.py --- a/kallithea/controllers/feed.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/controllers/feed.py Thu Dec 26 15:16:29 2019 +0100 @@ -96,7 +96,7 @@ desc_msg.append('\n\n') desc_msg.append(safe_unicode(raw_diff)) desc_msg.append('') - return [safe_unicode(chunk) for chunk in desc_msg] + return desc_msg def _feed(self, repo_name, feeder): """Produce a simple feed""" diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/auth.py --- a/kallithea/lib/auth.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/auth.py Thu Dec 26 15:16:29 2019 +0100 @@ -42,7 +42,7 @@ from kallithea.config.routing import url from kallithea.lib.caching_query import FromCache from kallithea.lib.utils import conditional_cache, get_repo_group_slug, get_repo_slug, get_user_group_slug -from kallithea.lib.utils2 import ascii_bytes, ascii_str, safe_bytes, safe_unicode +from kallithea.lib.utils2 import ascii_bytes, ascii_str, safe_bytes from kallithea.lib.vcs.utils.lazy import LazyProperty from kallithea.model.db import ( Permission, RepoGroup, Repository, User, UserApiKeys, UserGroup, UserGroupMember, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserGroupToPerm, UserGroupUserGroupToPerm, UserIpMap, UserToPerm) @@ -817,10 +817,6 @@ self.required_perms = set(perms) def __call__(self, authuser, repo_name, purpose=None): - # repo_name MUST be unicode, since we handle keys in ok - # dict by unicode - repo_name = safe_unicode(repo_name) - try: ok = authuser.permissions['repositories'][repo_name] in self.required_perms except KeyError: diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/auth_modules/auth_container.py --- a/kallithea/lib/auth_modules/auth_container.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/auth_modules/auth_container.py Thu Dec 26 15:16:29 2019 +0100 @@ -29,7 +29,7 @@ from kallithea.lib import auth_modules from kallithea.lib.compat import hybrid_property -from kallithea.lib.utils2 import safe_str, safe_unicode, str2bool +from kallithea.lib.utils2 import safe_str, str2bool from kallithea.model.db import Setting @@ -199,8 +199,8 @@ user_data = { 'username': username, - 'firstname': safe_unicode(firstname or username), - 'lastname': safe_unicode(lastname or ''), + 'firstname': firstname or username, + 'lastname': lastname or '', 'groups': [], 'email': email or '', 'admin': admin or False, diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/auth_modules/auth_ldap.py --- a/kallithea/lib/auth_modules/auth_ldap.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/auth_modules/auth_ldap.py Thu Dec 26 15:16:29 2019 +0100 @@ -31,7 +31,7 @@ from kallithea.lib import auth_modules from kallithea.lib.compat import hybrid_property from kallithea.lib.exceptions import LdapConnectionError, LdapImportError, LdapPasswordError, LdapUsernameError -from kallithea.lib.utils2 import safe_str, safe_unicode +from kallithea.lib.utils2 import safe_str log = logging.getLogger(__name__) @@ -338,8 +338,8 @@ user_data = { 'username': username, - 'firstname': safe_unicode(get_ldap_attr('attr_firstname') or firstname), - 'lastname': safe_unicode(get_ldap_attr('attr_lastname') or lastname), + 'firstname': get_ldap_attr('attr_firstname') or firstname, + 'lastname': get_ldap_attr('attr_lastname') or lastname, 'groups': [], 'email': get_ldap_attr('attr_email') or email, 'admin': admin, diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/base.py --- a/kallithea/lib/base.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/base.py Thu Dec 26 15:16:29 2019 +0100 @@ -553,7 +553,7 @@ return log.debug('Found repository in database %s with state `%s`', - safe_unicode(_dbr), safe_unicode(_dbr.repo_state)) + _dbr, _dbr.repo_state) route = getattr(request.environ.get('routes.route'), 'name', '') # allow to delete repos that are somehow damages in filesystem diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/helpers.py Thu Dec 26 15:16:29 2019 +0100 @@ -205,8 +205,6 @@ class _FilesBreadCrumbs(object): def __call__(self, repo_name, rev, paths): - if isinstance(paths, str): - paths = safe_unicode(paths) url_l = [link_to(repo_name, url('files_home', repo_name=repo_name, revision=rev, f_path=''), @@ -954,7 +952,7 @@ suf = '' if len(nodes) > 30: suf = '
' + _(' and %s more') % (len(nodes) - 30) - return literal(pref + '
'.join([safe_unicode(x.path) + return literal(pref + '
'.join([x.path for x in nodes[:30]]) + suf) else: return ': ' + _('No files') diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/hooks.py Thu Dec 26 15:16:29 2019 +0100 @@ -34,7 +34,7 @@ from kallithea.lib import helpers as h from kallithea.lib.exceptions import UserCreationError from kallithea.lib.utils import action_logger, make_ui -from kallithea.lib.utils2 import HookEnvironmentError, ascii_str, get_hook_environment, safe_bytes, safe_str, safe_unicode +from kallithea.lib.utils2 import HookEnvironmentError, ascii_str, get_hook_environment, safe_bytes, safe_str from kallithea.lib.vcs.backends.base import EmptyChangeset from kallithea.model.db import Repository, User @@ -312,7 +312,6 @@ #logging.config.fileConfig(ini_file_path) # Note: we are in a different process - don't use configured logging kallithea.config.middleware.make_app(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) - repo_path = safe_unicode(repo_path) # fix if it's not a bare repo if repo_path.endswith(os.sep + '.git'): repo_path = repo_path[:-5] diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/indexers/daemon.py --- a/kallithea/lib/indexers/daemon.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/indexers/daemon.py Thu Dec 26 15:16:29 2019 +0100 @@ -77,8 +77,7 @@ # filter repo list if repo_list: - # Fix non-ascii repo names to unicode - repo_list = set(safe_unicode(repo_name) for repo_name in repo_list) + repo_list = set(repo_list) self.filtered_repo_paths = {} for repo_name, repo in self.repo_paths.items(): if repo_name in repo_list: @@ -110,7 +109,7 @@ self.initial = False def _get_index_revision(self, repo): - db_repo = Repository.get_by_repo_name(safe_unicode(repo.name)) + db_repo = Repository.get_by_repo_name(repo.name) landing_rev = 'tip' if db_repo: _rev_type, _rev = db_repo.landing_rev @@ -197,13 +196,12 @@ u_content = u'' indexed += 1 - p = safe_unicode(path) writer.add_document( - fileid=p, - owner=unicode(repo.contact), - repository_rawname=safe_unicode(repo_name), - repository=safe_unicode(repo_name), - path=p, + fileid=path, + owner=repo.contact, + repository_rawname=repo_name, + repository=repo_name, + path=path, content=u_content, modtime=self.get_node_mtime(node), extension=node.extension @@ -238,18 +236,18 @@ indexed += 1 log.debug(' >> %s %s/%s', cs, indexed, total) writer.add_document( - raw_id=unicode(cs.raw_id), - owner=unicode(repo.contact), + raw_id=cs.raw_id, + owner=repo.contact, date=cs._timestamp, - repository_rawname=safe_unicode(repo_name), - repository=safe_unicode(repo_name), + repository_rawname=repo_name, + repository=repo_name, author=cs.author, message=cs.message, last=cs.last, - added=u' '.join([safe_unicode(node.path) for node in cs.added]).lower(), - removed=u' '.join([safe_unicode(node.path) for node in cs.removed]).lower(), - changed=u' '.join([safe_unicode(node.path) for node in cs.changed]).lower(), - parents=u' '.join([cs.raw_id for cs in cs.parents]), + added=u' '.join(node.path for node in cs.added).lower(), + removed=u' '.join(node.path for node in cs.removed).lower(), + changed=u' '.join(node.path for node in cs.changed).lower(), + parents=u' '.join(cs.raw_id for cs in cs.parents), ) return indexed @@ -391,9 +389,7 @@ ri_cnt = 0 # indexed riwc_cnt = 0 # indexed with content for path in self.get_paths(repo): - path = safe_unicode(path) if path in to_index or path not in indexed_paths: - # This is either a file that's changed, or a new file # that wasn't indexed before. So index it! i, iwc = self.add_doc(writer, path, repo, repo_name) diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/middleware/pygrack.py --- a/kallithea/lib/middleware/pygrack.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/middleware/pygrack.py Thu Dec 26 15:16:29 2019 +0100 @@ -33,7 +33,7 @@ from webob import Request, Response, exc import kallithea -from kallithea.lib.utils2 import ascii_bytes, safe_unicode +from kallithea.lib.utils2 import ascii_bytes from kallithea.lib.vcs import subprocessio @@ -87,7 +87,6 @@ :param path: """ - path = safe_unicode(path) assert path.startswith('/' + self.repo_name + '/') return path[len(self.repo_name) + 2:].strip('/') diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/middleware/simplegit.py --- a/kallithea/lib/middleware/simplegit.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/middleware/simplegit.py Thu Dec 26 15:16:29 2019 +0100 @@ -35,7 +35,6 @@ from kallithea.lib.hooks import log_pull_action from kallithea.lib.middleware.pygrack import make_wsgi_app from kallithea.lib.utils import make_ui -from kallithea.lib.utils2 import safe_unicode from kallithea.model.db import Repository @@ -64,7 +63,7 @@ class parsed_request(object): # See https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols#_the_smart_protocol - repo_name = safe_unicode(m.group(1).rstrip('/')) + repo_name = m.group(1).rstrip('/') cmd = m.group(2) query_string = environ['QUERY_STRING'] diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/middleware/simplehg.py --- a/kallithea/lib/middleware/simplehg.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/middleware/simplehg.py Thu Dec 26 15:16:29 2019 +0100 @@ -36,7 +36,7 @@ from kallithea.lib.base import BaseVCSController, get_path_info from kallithea.lib.utils import make_ui -from kallithea.lib.utils2 import safe_bytes, safe_str, safe_unicode +from kallithea.lib.utils2 import safe_bytes, safe_str log = logging.getLogger(__name__) @@ -105,7 +105,7 @@ return None class parsed_request(object): - repo_name = safe_unicode(path_info[1:].rstrip('/')) + repo_name = path_info[1:].rstrip('/') query_string = environ['QUERY_STRING'] diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/utils.py --- a/kallithea/lib/utils.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/utils.py Thu Dec 26 15:16:29 2019 +0100 @@ -40,7 +40,7 @@ import kallithea.config.conf from kallithea.lib.exceptions import HgsubversionImportError -from kallithea.lib.utils2 import ascii_bytes, aslist, get_current_authuser, safe_bytes, safe_str, safe_unicode +from kallithea.lib.utils2 import ascii_bytes, aslist, get_current_authuser, safe_bytes, safe_str from kallithea.lib.vcs.backends.git.repository import GitRepository from kallithea.lib.vcs.backends.hg.repository import MercurialRepository from kallithea.lib.vcs.conf import settings @@ -150,7 +150,7 @@ user_log = UserLog() user_log.user_id = user_obj.user_id user_log.username = user_obj.username - user_log.action = safe_unicode(action) + user_log.action = action user_log.repository = repo_obj user_log.repository_name = repo_name @@ -160,7 +160,7 @@ meta.Session().add(user_log) log.info('Logging action:%s on %s by user:%s ip:%s', - action, safe_unicode(repo), user_obj, ipaddr) + action, repo, user_obj, ipaddr) if commit: meta.Session().commit() @@ -480,8 +480,7 @@ for name, repo in initial_repo_dict.items(): group = map_groups(name) - unicode_name = safe_unicode(name) - db_repo = repo_model.get_by_repo_name(unicode_name) + db_repo = repo_model.get_by_repo_name(name) # found repo that is on filesystem not in Kallithea database if not db_repo: log.info('repository %s not found, creating now', name) @@ -517,9 +516,8 @@ removed = [] # remove from database those repositories that are not in the filesystem - unicode_initial_repo_names = set(safe_unicode(name) for name in initial_repo_dict) for repo in sa.query(Repository).all(): - if repo.repo_name not in unicode_initial_repo_names: + if repo.repo_name not in initial_repo_dict: if remove_obsolete: log.debug("Removing non-existing repository found in db `%s`", repo.repo_name) diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/utils2.py Thu Dec 26 15:16:29 2019 +0100 @@ -322,19 +322,19 @@ def get_clone_url(clone_uri_tmpl, prefix_url, repo_name, repo_id, username=None): parsed_url = urlobject.URLObject(prefix_url) - prefix = safe_unicode(urllib.parse.unquote(parsed_url.path.rstrip('/'))) + prefix = urllib.parse.unquote(parsed_url.path.rstrip('/')) try: system_user = pwd.getpwuid(os.getuid()).pw_name except Exception: # TODO: support all systems - especially Windows system_user = 'kallithea' # hardcoded default value ... args = { 'scheme': parsed_url.scheme, - 'user': safe_unicode(urllib.parse.quote(safe_str(username or ''))), + 'user': urllib.parse.quote(safe_str(username or '')), 'netloc': parsed_url.netloc + prefix, # like "hostname:port/prefix" (with optional ":port" and "/prefix") 'prefix': prefix, # undocumented, empty or starting with / 'repo': repo_name, 'repoid': str(repo_id), - 'system_user': safe_unicode(system_user), + 'system_user': system_user, 'hostname': parsed_url.hostname, } url = re.sub('{([^{}]+)}', lambda m: args.get(m.group(1), m.group(0)), clone_uri_tmpl) @@ -344,7 +344,7 @@ if not url_obj.username: url_obj = url_obj.with_username(None) - return safe_unicode(url_obj) + return str(url_obj) def get_changeset_safe(repo, rev): diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/vcs/backends/base.py --- a/kallithea/lib/vcs/backends/base.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/vcs/backends/base.py Thu Dec 26 15:16:29 2019 +0100 @@ -15,7 +15,7 @@ from kallithea.lib.vcs.conf import settings from kallithea.lib.vcs.exceptions import ( ChangesetError, EmptyRepositoryError, NodeAlreadyAddedError, NodeAlreadyChangedError, NodeAlreadyExistsError, NodeAlreadyRemovedError, NodeDoesNotExistError, NodeNotChangedError, RepositoryError) -from kallithea.lib.vcs.utils import author_email, author_name, safe_unicode +from kallithea.lib.vcs.utils import author_email, author_name from kallithea.lib.vcs.utils.helpers import get_dict_for_attrs from kallithea.lib.vcs.utils.lazy import LazyProperty @@ -376,9 +376,9 @@ message=self.message, date=self.date, author=self.author, - added=[safe_unicode(el.path) for el in self.added], - changed=[safe_unicode(el.path) for el in self.changed], - removed=[safe_unicode(el.path) for el in self.removed], + added=[el.path for el in self.added], + changed=[el.path for el in self.changed], + removed=[el.path for el in self.removed], ) else: return dict( @@ -643,9 +643,9 @@ data = get_dict_for_attrs(self, ['raw_id', 'short_id', 'revision', 'date', 'message']) data['author'] = {'name': self.author_name, 'email': self.author_email} - data['added'] = [safe_unicode(node.path) for node in self.added] - data['changed'] = [safe_unicode(node.path) for node in self.changed] - data['removed'] = [safe_unicode(node.path) for node in self.removed] + data['added'] = [node.path for node in self.added] + data['changed'] = [node.path for node in self.changed] + data['removed'] = [node.path for node in self.removed] return data @LazyProperty diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/vcs/backends/git/repository.py --- a/kallithea/lib/vcs/backends/git/repository.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/vcs/backends/git/repository.py Thu Dec 26 15:16:29 2019 +0100 @@ -54,7 +54,7 @@ def __init__(self, repo_path, create=False, src_url=None, update_after_clone=False, bare=False): - self.path = safe_unicode(abspath(repo_path)) + self.path = abspath(repo_path) self.repo = self._get_repo(create, src_url, update_after_clone, bare) self.bare = self.repo.bare diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/vcs/backends/git/ssh.py --- a/kallithea/lib/vcs/backends/git/ssh.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/vcs/backends/git/ssh.py Thu Dec 26 15:16:29 2019 +0100 @@ -18,7 +18,7 @@ from kallithea.lib.hooks import log_pull_action from kallithea.lib.utils import make_ui from kallithea.lib.vcs.backends.ssh import BaseSshHandler -from kallithea.lib.vcs.utils import safe_str, safe_unicode +from kallithea.lib.vcs.utils import safe_str log = logging.getLogger(__name__) @@ -56,7 +56,7 @@ ssh_command_parts[0] in ['git-upload-pack', 'git-receive-pack'] and ssh_command_parts[1].startswith('/') ): - return cls(safe_unicode(ssh_command_parts[1][1:]), ssh_command_parts[0]) + return cls(ssh_command_parts[1][1:], ssh_command_parts[0]) return None diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/vcs/backends/hg/ssh.py --- a/kallithea/lib/vcs/backends/hg/ssh.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/vcs/backends/hg/ssh.py Thu Dec 26 15:16:29 2019 +0100 @@ -19,7 +19,7 @@ from kallithea.lib.utils import make_ui from kallithea.lib.vcs.backends.ssh import BaseSshHandler -from kallithea.lib.vcs.utils import safe_bytes, safe_unicode +from kallithea.lib.vcs.utils import safe_bytes log = logging.getLogger(__name__) @@ -47,7 +47,7 @@ >>> MercurialSshHandler.make(shlex.split('git-upload-pack "/foo"')) # not handled here """ if ssh_command_parts[:2] == ['hg', '-R'] and ssh_command_parts[3:] == ['serve', '--stdio']: - return cls(safe_unicode(ssh_command_parts[2])) + return cls(ssh_command_parts[2]) return None diff -r 502d2fcbe434 -r e35373106528 kallithea/lib/vcs/nodes.py --- a/kallithea/lib/vcs/nodes.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/lib/vcs/nodes.py Thu Dec 26 15:16:29 2019 +0100 @@ -126,7 +126,7 @@ Returns name of the node so if its path then only last part is returned. """ - return safe_unicode(self.path.rstrip('/').split('/')[-1]) + return self.path.rstrip('/').split('/')[-1] def _get_kind(self): return self._kind @@ -605,5 +605,5 @@ Returns name of the node so if its path then only last part is returned. """ - org = safe_unicode(self.path.rstrip('/').split('/')[-1]) + org = self.path.rstrip('/').rsplit('/', 1)[-1] return u'%s @ %s' % (org, self.changeset.short_id) diff -r 502d2fcbe434 -r e35373106528 kallithea/model/comment.py --- a/kallithea/model/comment.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/model/comment.py Thu Dec 26 15:16:29 2019 +0100 @@ -31,7 +31,7 @@ from tg.i18n import ugettext as _ from kallithea.lib import helpers as h -from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode +from kallithea.lib.utils2 import extract_mentioned_users from kallithea.model.db import ChangesetComment, PullRequest, Repository, User from kallithea.model.meta import Session from kallithea.model.notification import NotificationModel @@ -81,11 +81,10 @@ repo_name=repo.repo_name, revision=revision, anchor='comment-%s' % comment.comment_id) - subj = safe_unicode( - h.link_to('Re changeset: %(desc)s %(line)s' % + subj = h.link_to( + 'Re changeset: %(desc)s %(line)s' % {'desc': desc, 'line': line}, - comment_url) - ) + comment_url) # get the current participants of this changeset recipients = _list_changeset_commenters(revision) # add changeset author if it's known locally @@ -127,13 +126,12 @@ h.canonical_hostname())) comment_url = pull_request.url(canonical=True, anchor='comment-%s' % comment.comment_id) - subj = safe_unicode( - h.link_to('Re pull request %(pr_nice_id)s: %(desc)s %(line)s' % + subj = h.link_to( + 'Re pull request %(pr_nice_id)s: %(desc)s %(line)s' % {'desc': desc, 'pr_nice_id': comment.pull_request.nice_id(), 'line': line}, - comment_url) - ) + comment_url) # get the current participants of this pull request recipients = _list_pull_request_commenters(pull_request) recipients.append(pull_request.owner) diff -r 502d2fcbe434 -r e35373106528 kallithea/model/db.py --- a/kallithea/model/db.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/model/db.py Thu Dec 26 15:16:29 2019 +0100 @@ -328,9 +328,9 @@ info = { 'modules': sorted(mods, key=lambda k: k[0].lower()), 'py_version': platform.python_version(), - 'platform': safe_unicode(platform.platform()), + 'platform': platform.platform(), 'kallithea_version': kallithea.__version__, - 'git_version': safe_unicode(check_git_version()), + 'git_version': str(check_git_version()), 'git_path': kallithea.CONFIG.get('git_path') } return info @@ -1162,7 +1162,7 @@ # names in the database, but that eventually needs to be converted # into a valid system path p += self.repo_name.split(Repository.url_sep()) - return os.path.join(*(safe_unicode(d) for d in p)) + return os.path.join(*p) @property def cache_keys(self): @@ -2282,7 +2282,7 @@ @revisions.setter def revisions(self, val): - self._revisions = safe_unicode(':'.join(val)) + self._revisions = ':'.join(val) @property def org_ref_parts(self): diff -r 502d2fcbe434 -r e35373106528 kallithea/model/gist.py --- a/kallithea/model/gist.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/model/gist.py Thu Dec 26 15:16:29 2019 +0100 @@ -33,7 +33,7 @@ import traceback from kallithea.lib import ext_json -from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, safe_unicode, time_to_datetime +from kallithea.lib.utils2 import AttributeDict, ascii_bytes, safe_int, time_to_datetime from kallithea.model.db import Gist, Session, User from kallithea.model.repo import RepoModel from kallithea.model.scm import ScmModel @@ -120,7 +120,7 @@ gist.gist_access_id = gist_access_id gist.owner_id = owner.user_id gist.gist_expires = gist_expires - gist.gist_type = safe_unicode(gist_type) + gist.gist_type = gist_type Session().add(gist) Session().flush() # make database assign gist.gist_id if gist_type == Gist.GIST_PUBLIC: diff -r 502d2fcbe434 -r e35373106528 kallithea/model/pull_request.py --- a/kallithea/model/pull_request.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/model/pull_request.py Thu Dec 26 15:16:29 2019 +0100 @@ -33,7 +33,7 @@ from tg.i18n import ugettext as _ from kallithea.lib import helpers as h -from kallithea.lib.utils2 import ascii_bytes, extract_mentioned_users, safe_unicode +from kallithea.lib.utils2 import ascii_bytes, extract_mentioned_users from kallithea.model.db import ChangesetStatus, PullRequest, PullRequestReviewer, User from kallithea.model.meta import Session from kallithea.model.notification import NotificationModel @@ -68,14 +68,12 @@ threading = ['%s-pr-%s@%s' % (pr.other_repo.repo_name, pr.pull_request_id, h.canonical_hostname())] - subject = safe_unicode( - h.link_to( - _('%(user)s wants you to review pull request %(pr_nice_id)s: %(pr_title)s') % + subject = h.link_to( + _('%(user)s wants you to review pull request %(pr_nice_id)s: %(pr_title)s') % {'user': user.username, 'pr_title': pr.title, 'pr_nice_id': pr.nice_id()}, - pr_url) - ) + pr_url) body = pr.description _org_ref_type, org_ref_name, _org_rev = pr.org_ref.split(':') _other_ref_type, other_ref_name, _other_rev = pr.other_ref.split(':') diff -r 502d2fcbe434 -r e35373106528 kallithea/model/repo.py --- a/kallithea/model/repo.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/model/repo.py Thu Dec 26 15:16:29 2019 +0100 @@ -39,7 +39,7 @@ from kallithea.lib.exceptions import AttachedForksError from kallithea.lib.hooks import log_delete_repository from kallithea.lib.utils import is_valid_repo_uri, make_ui -from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str, safe_unicode +from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str from kallithea.lib.vcs.backends import get_backend from kallithea.model.db import ( Permission, RepoGroup, Repository, RepositoryField, Session, Statistics, Ui, User, UserGroup, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserRepoGroupToPerm, UserRepoToPerm) @@ -337,8 +337,8 @@ fork_of = Repository.guess_instance(fork_of) repo_group = RepoGroup.guess_instance(repo_group) try: - repo_name = safe_unicode(repo_name) - description = safe_unicode(description) + repo_name = repo_name + description = description # repo name is just a name of repository # while repo_name_full is a full qualified name that is combined # with name and path of group @@ -653,7 +653,7 @@ raise Exception('This path %s is a valid group' % repo_path) log.info('creating repo %s in %s from url: `%s`', - repo_name, safe_unicode(repo_path), + repo_name, repo_path, obfuscate_url_pw(clone_uri)) backend = get_backend(repo_type) @@ -674,7 +674,7 @@ raise Exception('Not supported repo_type %s expected hg/git' % repo_type) log.debug('Created repo %s with %s backend', - safe_unicode(repo_name), safe_unicode(repo_type)) + repo_name, repo_type) return repo def _rename_filesystem_repo(self, old, new): diff -r 502d2fcbe434 -r e35373106528 kallithea/model/scm.py --- a/kallithea/model/scm.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/model/scm.py Thu Dec 26 15:16:29 2019 +0100 @@ -41,7 +41,7 @@ from kallithea.lib.exceptions import IMCCommitError, NonRelativePathError from kallithea.lib.hooks import process_pushed_raw_ids from kallithea.lib.utils import action_logger, get_filesystem_repos, make_ui -from kallithea.lib.utils2 import safe_bytes, safe_str, safe_unicode, set_hook_environment +from kallithea.lib.utils2 import safe_bytes, safe_str, set_hook_environment from kallithea.lib.vcs import get_backend from kallithea.lib.vcs.backends.base import EmptyChangeset from kallithea.lib.vcs.exceptions import RepositoryError @@ -401,10 +401,6 @@ # in any other case this will throw exceptions and deny commit content = safe_str(content) path = safe_str(f_path) - # message and author needs to be unicode - # proper backend should then translate that into required type - message = safe_unicode(message) - author = safe_unicode(author) imc = IMC(repo) imc.change(FileNode(path, content, mode=cs.get_file_mode(f_path))) try: @@ -491,9 +487,10 @@ content = content.read() processed_nodes.append((f_path, content)) - message = safe_unicode(message) + message = message committer = user.full_contact - author = safe_unicode(author) if author else committer + if not author: + author = committer IMC = self._get_IMC_module(scm_instance.alias) imc = IMC(scm_instance) @@ -534,9 +531,10 @@ user = User.guess_instance(user) scm_instance = repo.scm_instance_no_cache() - message = safe_unicode(message) + message = message committer = user.full_contact - author = safe_unicode(author) if author else committer + if not author: + author = committer imc_class = self._get_IMC_module(scm_instance.alias) imc = imc_class(scm_instance) @@ -614,9 +612,10 @@ content = nodes[f_path].get('content') processed_nodes.append((f_path, content)) - message = safe_unicode(message) + message = message committer = user.full_contact - author = safe_unicode(author) if author else committer + if not author: + author = committer IMC = self._get_IMC_module(scm_instance.alias) imc = IMC(scm_instance) diff -r 502d2fcbe434 -r e35373106528 kallithea/model/user.py --- a/kallithea/model/user.py Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/model/user.py Thu Dec 26 15:16:29 2019 +0100 @@ -38,7 +38,7 @@ from kallithea.lib.caching_query import FromCache from kallithea.lib.exceptions import DefaultUserException, UserOwnsReposException -from kallithea.lib.utils2 import generate_api_key, get_current_authuser, safe_unicode +from kallithea.lib.utils2 import generate_api_key, get_current_authuser from kallithea.model.db import Permission, User, UserEmailMap, UserIpMap, UserToPerm from kallithea.model.meta import Session @@ -142,10 +142,8 @@ new_user.admin = admin new_user.email = email new_user.active = active - new_user.extern_name = safe_unicode(extern_name) \ - if extern_name else None - new_user.extern_type = safe_unicode(extern_type) \ - if extern_type else None + new_user.extern_name = extern_name + new_user.extern_type = extern_type new_user.name = firstname new_user.lastname = lastname diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/admin/gists/edit.html --- a/kallithea/templates/admin/gists/edit.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/admin/gists/edit.html Thu Dec 26 15:16:29 2019 +0100 @@ -67,8 +67,8 @@ % for cnt, file in enumerate(c.files):
- - + +
diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/admin/gists/show.html --- a/kallithea/templates/admin/gists/show.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/admin/gists/show.html Thu Dec 26 15:16:29 2019 +0100 @@ -76,10 +76,10 @@
- ${h.safe_unicode(file.path)} + ${file.path}
- ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_access_id, format='raw', revision=file.changeset.raw_id, f_path=h.safe_unicode(file.path)),class_="btn btn-default btn-xs")} + ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_access_id, format='raw', revision=file.changeset.raw_id, f_path=file.path),class_="btn btn-default btn-xs")}
diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/changeset/changeset.html --- a/kallithea/templates/changeset/changeset.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/changeset/changeset.html Thu Dec 26 15:16:29 2019 +0100 @@ -143,7 +143,7 @@ %for fid, url_fid, op, a_path, path, diff, stats in file_diff_data:
- ${h.link_to(h.safe_unicode(path), '#%s' % fid)} + ${h.link_to(path, '#%s' % fid)}
${h.fancy_file_stats(stats)}
diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/changeset/changeset_file_comment.html --- a/kallithea/templates/changeset/changeset_file_comment.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/changeset/changeset_file_comment.html Thu Dec 26 15:16:29 2019 +0100 @@ -164,7 +164,7 @@
%for f_path, lines in c.inline_comments: %for line_no, comments in lines.items(): -
+
%for co in comments: ${comment_block(co)} %endfor diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/changeset/changeset_range.html --- a/kallithea/templates/changeset/changeset_range.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/changeset/changeset_range.html Thu Dec 26 15:16:29 2019 +0100 @@ -56,7 +56,7 @@
- ${h.link_to(h.safe_unicode(path), '#%s' % fid)} + ${h.link_to(path, '#%s' % fid)}
${h.fancy_file_stats(stats)}
diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/changeset/diff_block.html --- a/kallithea/templates/changeset/diff_block.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/changeset/diff_block.html Thu Dec 26 15:16:29 2019 +0100 @@ -22,7 +22,7 @@
- ${h.safe_unicode(cs_filename)} + ${cs_filename}
@@ -57,13 +57,13 @@ %endif - + - + - + - + ${c.ignorews_url(request.GET, url_fid)} ${c.context_url(request.GET, url_fid)} @@ -73,7 +73,7 @@ ${h.checkbox('checkbox-show-inline-' + id_fid, checked="checked",class_="show-inline-comments",**{'data-id_for':id_fid})}
-
+
${diff|n} %if op and cs_filename.rsplit('.')[-1] in ['png', 'gif', 'jpg', 'bmp']:
Show images
diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/compare/compare_diff.html --- a/kallithea/templates/compare/compare_diff.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/compare/compare_diff.html Thu Dec 26 15:16:29 2019 +0100 @@ -72,7 +72,7 @@
- ${h.link_to(h.safe_unicode(path), '#%s' % fid)} + ${h.link_to(path, '#%s' % fid)}
${h.fancy_file_stats(stats)}
diff -r 502d2fcbe434 -r e35373106528 kallithea/templates/files/diff_2way.html --- a/kallithea/templates/files/diff_2way.html Tue Dec 31 15:39:17 2019 +0100 +++ b/kallithea/templates/files/diff_2way.html Thu Dec 26 15:16:29 2019 +0100 @@ -34,22 +34,22 @@
- ${h.link_to(h.safe_unicode(c.node1.path),h.url('files_home',repo_name=c.repo_name, - revision=c.cs2.raw_id,f_path=h.safe_unicode(c.node1.path)))} + ${h.link_to(c.node1.path,h.url('files_home',repo_name=c.repo_name, + revision=c.cs2.raw_id,f_path=c.node1.path))}
- - - - ${h.checkbox('ignorews', label=_('Ignore whitespace'))} @@ -61,8 +61,8 @@