# HG changeset patch # User Mads Kiilerich # Date 1577369695 -3600 # Node ID 5f3101d54c3257b49e9a2941403f631630fc2d01 # Parent 0f69b5c35b2bfe83bc38585a30709f29a42a1752 vcs: drop special character encodings and some hardcoded UTF-8 - just use safe_unicode/safe_bytes diff -r 0f69b5c35b2b -r 5f3101d54c32 kallithea/lib/vcs/backends/git/changeset.py --- a/kallithea/lib/vcs/backends/git/changeset.py Fri Dec 27 23:30:56 2019 +0100 +++ b/kallithea/lib/vcs/backends/git/changeset.py Thu Dec 26 15:14:55 2019 +0100 @@ -448,8 +448,6 @@ Returns ``Node`` object from the given ``path``. If there is no node at the given ``path``, ``ChangesetError`` would be raised. """ - if isinstance(path, unicode): - path = path.encode('utf-8') path = self._fix_path(path) if path not in self.nodes: try: diff -r 0f69b5c35b2b -r 5f3101d54c32 kallithea/lib/vcs/backends/git/inmemory.py --- a/kallithea/lib/vcs/backends/git/inmemory.py Fri Dec 27 23:30:56 2019 +0100 +++ b/kallithea/lib/vcs/backends/git/inmemory.py Thu Dec 26 15:14:55 2019 +0100 @@ -7,7 +7,7 @@ from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset from kallithea.lib.vcs.exceptions import RepositoryError -from kallithea.lib.vcs.utils import safe_str +from kallithea.lib.vcs.utils import safe_bytes, safe_str class GitInMemoryChangeset(BaseInMemoryChangeset): @@ -39,7 +39,7 @@ repo = self.repository._repo object_store = repo.object_store - ENCODING = "UTF-8" + ENCODING = "UTF-8" # TODO: should probably be kept in sync with safe_unicode/safe_bytes and vcs/conf/settings.py DEFAULT_ENCODINGS # Create tree and populates it with blobs commit_tree = self.parents[0] and repo[self.parents[0]._commit.tree] or \ @@ -74,7 +74,7 @@ content = node.content blob = objects.Blob.from_string(content) - node_path = node.name.encode(ENCODING) + node_path = safe_bytes(node.name) if dirnames: # If there are trees which should be created we need to build # them now (in reverse order) diff -r 0f69b5c35b2b -r 5f3101d54c32 kallithea/lib/vcs/backends/hg/inmemory.py --- a/kallithea/lib/vcs/backends/hg/inmemory.py Fri Dec 27 23:30:56 2019 +0100 +++ b/kallithea/lib/vcs/backends/hg/inmemory.py Thu Dec 26 15:14:55 2019 +0100 @@ -2,7 +2,8 @@ from kallithea.lib.vcs.backends.base import BaseInMemoryChangeset from kallithea.lib.vcs.exceptions import RepositoryError -from kallithea.lib.vcs.utils.hgcompat import hex, memctx, memfilectx, tolocal +from kallithea.lib.vcs.utils import safe_bytes +from kallithea.lib.vcs.utils.hgcompat import hex, memctx, memfilectx class MercurialInMemoryChangeset(BaseInMemoryChangeset): @@ -87,11 +88,9 @@ date=date, extra=kwargs) - loc = lambda u: tolocal(u.encode('utf-8')) - # injecting given _repo params - commit_ctx._text = loc(message) - commit_ctx._user = loc(author) + commit_ctx._text = safe_bytes(message) + commit_ctx._user = safe_bytes(author) commit_ctx._date = date # TODO: Catch exceptions! diff -r 0f69b5c35b2b -r 5f3101d54c32 kallithea/lib/vcs/utils/hgcompat.py --- a/kallithea/lib/vcs/utils/hgcompat.py Fri Dec 27 23:30:56 2019 +0100 +++ b/kallithea/lib/vcs/utils/hgcompat.py Thu Dec 26 15:14:55 2019 +0100 @@ -9,7 +9,6 @@ from mercurial.commands import clone, nullid, pull from mercurial.context import memctx, memfilectx from mercurial.discovery import findcommonoutgoing -from mercurial.encoding import tolocal from mercurial.error import Abort, RepoError, RepoLookupError from mercurial.hg import peer from mercurial.hgweb import hgweb_mod