/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-06 12:06:20 UTC
  • mfrom: (1740 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060606120620-50066b0951e4ef7c
merge bzr.dev 1740

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
        self._removed_id = set()
104
104
        self._tree_path_ids = {}
105
105
        self._tree_id_paths = {}
 
106
        self._realpaths = {}
 
107
        # Cache of realpath results, to speed up canonical_path
 
108
        self._relpaths = {}
 
109
        # Cache of relpath results, to speed up canonical_path
106
110
        self._new_root = self.trans_id_tree_file_id(tree.get_root_id())
107
111
        self.__done = False
108
112
        self._pb = pb
213
217
    def canonical_path(self, path):
214
218
        """Get the canonical tree-relative path"""
215
219
        # don't follow final symlinks
216
 
        dirname, basename = os.path.split(self._tree.abspath(path))
217
 
        dirname = os.path.realpath(dirname)
218
 
        return self._tree.relpath(pathjoin(dirname, basename))
 
220
        abs = self._tree.abspath(path)
 
221
        if abs in self._relpaths:
 
222
            return self._relpaths[abs]
 
223
        dirname, basename = os.path.split(abs)
 
224
        if dirname not in self._realpaths:
 
225
            self._realpaths[dirname] = os.path.realpath(dirname)
 
226
        dirname = self._realpaths[dirname]
 
227
        abs = pathjoin(dirname, basename)
 
228
        if dirname in self._relpaths:
 
229
            relpath = pathjoin(self._relpaths[dirname], basename)
 
230
            relpath = relpath.rstrip('/\\')
 
231
        else:
 
232
            relpath = self._tree.relpath(abs)
 
233
        self._relpaths[abs] = relpath
 
234
        return relpath
219
235
 
220
236
    def trans_id_tree_path(self, path):
221
237
        """Determine (and maybe set) the transaction ID for a tree path."""