[PATCH] repo model: properly handle unicode Git repo paths with dulwich 0.9.9+
Thomas De Schampheleire
patrickdepinguin at gmail.com
Sun Mar 29 15:44:12 EDT 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1427657601 -7200
# Sun Mar 29 21:33:21 2015 +0200
# Node ID be46b65653de6d38e208629bde1886fe31cf38c4
# Parent 65c5e70a1d0c1861d7dc835f204d132342920da2
repo model: properly handle unicode Git repo paths with dulwich 0.9.9+
Since commit 65c5e70a1d0c bumped the dulwich requirement, following tests
that create non-ascii Git repositories fail:
TestAdminReposControllerGIT.test_create_non_ascii
TestAdminReposControllerGIT.test_delete_non_ascii
Using safe_unicode() instead of safe_str() to construct the repository path
in the repo model fixes this problem for Git repositories.
For Mercurial, safe_unicode() does not work and it has to be safe_str().
diff --git a/kallithea/model/repo.py b/kallithea/model/repo.py
--- a/kallithea/model/repo.py
+++ b/kallithea/model/repo.py
@@ -709,8 +709,11 @@
_paths = [repo_store_location]
else:
_paths = [self.repos_path, new_parent_path, repo_name]
- # we need to make it str for mercurial
- repo_path = os.path.join(*map(lambda x: safe_str(x), _paths))
+ # we need to make it str for mercurial
+ if repo_type == 'hg':
+ repo_path = os.path.join(*map(lambda x: safe_str(x), _paths))
+ else:
+ repo_path = os.path.join(*map(lambda x: safe_unicode(x), _paths))
# check if this path is not a repository
if is_valid_repo(repo_path, self.repos_path):
More information about the kallithea-general
mailing list