Changeset - 5f3101d54c32
[Not reviewed]
default
0 4 0
Mads Kiilerich - 6 years ago 2019-12-26 15:14:55
mads@kiilerich.com
Grafted from: 52b913f63494
vcs: drop special character encodings and some hardcoded UTF-8 - just use safe_unicode/safe_bytes
4 files changed with 7 insertions and 11 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/git/changeset.py
Show inline comments
 
@@ -448,8 +448,6 @@ class GitChangeset(BaseChangeset):
 
        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:
kallithea/lib/vcs/backends/git/inmemory.py
Show inline comments
 
@@ -7,7 +7,7 @@ from dulwich import objects
 

	
 
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 @@ class GitInMemoryChangeset(BaseInMemoryC
 
        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 @@ class GitInMemoryChangeset(BaseInMemoryC
 
                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)
kallithea/lib/vcs/backends/hg/inmemory.py
Show inline comments
 
@@ -2,7 +2,8 @@ import datetime
 

	
 
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 @@ class MercurialInMemoryChangeset(BaseInM
 
            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!
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -9,7 +9,6 @@ from mercurial import obsutil, patch, sc
 
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
0 comments (0 inline, 0 general)