/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: Robert Collins
  • Date: 2006-06-09 09:04:53 UTC
  • mfrom: (1755.2.1 add)
  • mto: (1755.1.2 integration)
  • mto: This revision was merged to the branch mainline in revision 1757.
  • Revision ID: robertc@robertcollins.net-20060609090453-10e94172dc5f670b
MergeĀ currentĀ head.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.progress import DummyProgress, ProgressPhase
28
28
from bzrlib.trace import mutter, warning
29
29
import bzrlib.ui 
 
30
import bzrlib.urlutils as urlutils
30
31
 
31
32
 
32
33
ROOT_PARENT = "root-parent"
79
80
        self._tree.lock_write()
80
81
        try:
81
82
            control_files = self._tree._control_files
82
 
            self._limbodir = control_files.controlfilename('limbo')
 
83
            self._limbodir = urlutils.local_path_from_url(
 
84
                control_files.controlfilename('limbo'))
83
85
            try:
84
86
                os.mkdir(self._limbodir)
85
87
            except OSError, e:
101
103
        self._removed_id = set()
102
104
        self._tree_path_ids = {}
103
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
104
110
        self._new_root = self.trans_id_tree_file_id(tree.get_root_id())
105
111
        self.__done = False
106
112
        self._pb = pb
211
217
    def canonical_path(self, path):
212
218
        """Get the canonical tree-relative path"""
213
219
        # don't follow final symlinks
214
 
        dirname, basename = os.path.split(self._tree.abspath(path))
215
 
        dirname = os.path.realpath(dirname)
216
 
        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
217
235
 
218
236
    def trans_id_tree_path(self, path):
219
237
        """Determine (and maybe set) the transaction ID for a tree path."""
829
847
        parent_id is the transaction id of the parent directory of the file.
830
848
        contents is an iterator of bytestrings, which will be used to produce
831
849
        the file.
832
 
        file_id is the inventory ID of the file, if it is to be versioned.
 
850
        :param file_id: The inventory ID of the file, if it is to be versioned.
 
851
        :param executable: Only valid when a file_id has been supplied.
833
852
        """
834
853
        trans_id = self._new_entry(name, parent_id, file_id)
 
854
        # TODO: rather than scheduling a set_executable call,
 
855
        # have create_file create the file with the right mode.
835
856
        self.create_file(contents, trans_id)
836
857
        if executable is not None:
837
858
            self.set_executability(executable, trans_id)