~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-19 08:15:16 UTC
  • mfrom: (1714.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060519081516-cd19bd125a53a4d2
Merge low hanging fruit optimisation of 'bzr add' (Robert Collins, Martin Pool).

Show diffs side-by-side

added added

removed removed

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