Browse files

Reimplement git filesystem charset handling

Make use of the new encoding handling implemented in the
`PyGit.Storage`. So now Trac should always get pathnames as unicode
objects.

A new TracIni option `git_fs_encoding` can be used to change the
default utf8 encoding.

This implementation assumes `from_unicode(to_unicode(.))` to be an
identity function.
  • Loading branch information...
1 parent b93a90d commit 35171676ba04bd1d6e4eb01f493864fdc94a8607 @hvr committed Oct 17, 2010
Showing with 9 additions and 2 deletions.
  1. +9 −2 tracext/git/git_fs.py
View
11 tracext/git/git_fs.py
@@ -163,6 +163,9 @@ def get_link_resolvers(self):
"use git-committer-author timestamp instead of git-author timestamp"
" as changeset timestamp")
+ _git_fs_encoding = Option('git', 'git_fs_encoding', 'utf-8',
+ "define charset encoding of paths within git repository")
+
_git_bin = PathOption('git', 'git_bin', '/usr/bin/git',
"path to git executable (relative to trac project folder!)")
@@ -215,6 +218,7 @@ def rlookup_uid(_):
repos = GitRepository(dir, params, self.log,
persistent_cache=self._persistent_cache,
git_bin=self._git_bin,
+ git_fs_encoding=self._git_fs_encoding,
shortrev_len=self._shortrev_len,
rlookup_uid=rlookup_uid,
use_committer_id=self._use_committer_id,
@@ -317,6 +321,7 @@ class GitRepository(Repository):
def __init__(self, path, params, log,
persistent_cache=False,
git_bin='git',
+ git_fs_encoding='utf-8',
shortrev_len=7,
rlookup_uid=lambda _: None,
use_committer_id=False,
@@ -331,7 +336,9 @@ def __init__(self, path, params, log,
self._use_committer_time = use_committer_time
self._use_committer_id = use_committer_id
- self.git = PyGIT.StorageFactory(path, log, not persistent_cache, git_bin=git_bin).getInstance()
+ self.git = PyGIT.StorageFactory(path, log, not persistent_cache,
+ git_bin=git_bin,
+ git_fs_encoding=git_fs_encoding).getInstance()
Repository.__init__(self, "git:"+path, self.params, log)
@@ -632,7 +639,7 @@ def get_changes(self):
paths_seen.add(path)
- yield (to_unicode(path), kind, action, to_unicode(p_path), p_rev)
+ yield path, kind, action, p_path, p_rev
def get_branches(self):

0 comments on commit 3517167

Please sign in to comment.