changeset 4425:a1841a3cf03b

indexer: rework get_node to handle alternative path element separators Problem seen on Windows by Dominik Ruf.
author Mads Kiilerich <madski@unity3d.com>
date Tue, 12 Aug 2014 13:08:23 +0200
parents fc7eed9ebe60
children e172e98f3e35
files kallithea/lib/indexers/daemon.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/indexers/daemon.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/indexers/daemon.py	Tue Aug 12 13:08:23 2014 +0200
@@ -146,17 +146,21 @@
 
     def get_node(self, repo, path, index_rev=None):
         """
-        gets a filenode based on given full path.It operates on string for
-        hg git compatability.
+        gets a filenode based on given full path. It operates on string for
+        hg git compatibility.
 
         :param repo: scm repo instance
         :param path: full path including root location
         :return: FileNode
         """
-        root_path = safe_str(repo.path)+'/'
-        parts = safe_str(path).partition(root_path)
+        # FIXME: paths should be normalized ... or even better: don't include repo.path
+        path = safe_str(path)
+        repo_path = safe_str(repo.path)
+        assert path.startswith(repo_path)
+        assert path[len(repo_path)] in (os.path.sep, os.path.altsep)
+        node_path = path[len(repo_path) + 1:]
         cs = self._get_index_changeset(repo, index_rev=index_rev)
-        node = cs.get_node(parts[-1])
+        node = cs.get_node(node_path)
         return node
 
     def get_node_mtime(self, node):