~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

Added canonical_path function

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        """
58
58
        return self.get_tree_path_id(self._tree.id2path(inventory_id))
59
59
 
 
60
    def canonical_path(self, path):
 
61
        """Get the canonical tree-relative path"""
 
62
        # don't follow final symlinks
 
63
        dirname, basename = os.path.split(self._tree.abspath(path))
 
64
        dirname = os.path.realpath(dirname)
 
65
        return self._tree.relpath(os.path.join(dirname, basename))
 
66
 
60
67
    def get_tree_path_id(self, path):
61
68
        """Determine (and maybe set) the transaction ID for a tree path."""
62
 
        path = os.path.realpath(path)
 
69
        path = self.canonical_path(path)
63
70
        if path not in self._tree_path_ids:
64
71
            self._tree_path_ids[path] = self._assign_id()
65
72
            self._tree_id_paths[self._tree_path_ids[path]] = path
100
107
            if path is None:
101
108
                raise NoSuchFile(None)
102
109
            try:
103
 
                return file_kind(path)
 
110
                return file_kind(self._tree.abspath(path))
104
111
            except OSError, e:
105
112
                if e.errno != errno.ENOENT:
106
113
                    raise