[meld] vc.git: Store filenames as unicode in the tree cache



commit 41a6111838fd66ba965ee5fa63300558b3551667
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Sep 20 07:36:25 2014 +1000

    vc.git: Store filenames as unicode in the tree cache
    
    Rather than assuming that we've got UTF8 filenames, this commit decodes
    all paths using the filesystem encoding before inserting them into the
    tree cache.

 meld/vc/git.py |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/meld/vc/git.py b/meld/vc/git.py
index daff37b..90d8b36 100644
--- a/meld/vc/git.py
+++ b/meld/vc/git.py
@@ -30,6 +30,7 @@ import os
 import re
 import shutil
 import subprocess
+import sys
 import tempfile
 
 from meld.conf import _, ngettext
@@ -65,6 +66,8 @@ class Vc(_vc.CachedVc):
         "U": _vc.STATE_CONFLICT,  # Unmerged
     }
 
+    file_encoding = sys.getfilesystemencoding()
+
     def __init__(self, location):
         super(Vc, self).__init__(location)
         self._tree_cache = {}
@@ -343,6 +346,7 @@ class Vc(_vc.CachedVc):
                 # returned by git as quoted strings
                 if name[0] == '"':
                     name = name[1:-1].decode('string_escape')
+                name = name.decode(self.file_encoding)
                 return os.path.abspath(
                     os.path.join(self.location, name))
 
@@ -379,9 +383,8 @@ class Vc(_vc.CachedVc):
         retfiles = []
         retdirs = []
         for name, path in files:
-            # Inside python dictionaries, keys are stored as utf8 strings.
-            state = tree.get(path.encode('utf8'), _vc.STATE_NORMAL)
-            meta = self._tree_meta_cache.get(path.encode('utf8'), "")
+            state = tree.get(path, _vc.STATE_NORMAL)
+            meta = self._tree_meta_cache.get(path, "")
             retfiles.append(_vc.File(path, name, state, options=meta))
         for name, path in dirs:
             state = tree.get(path, _vc.STATE_NORMAL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]