/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: Canonical.com Patch Queue Manager
  • Date: 2006-06-26 19:35:47 UTC
  • mfrom: (1813.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060626193547-43661d1377f72b4d
(robertc) Misc minor typos and the like.

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."""
521
539
        if child_id is None:
522
540
            return lexists(self._tree.abspath(childpath))
523
541
        else:
524
 
            if tt.final_parent(child_id) != parent_id:
 
542
            if self.final_parent(child_id) != parent_id:
525
543
                return False
526
 
            if child_id in tt._removed_contents:
 
544
            if child_id in self._removed_contents:
527
545
                # XXX What about dangling file-ids?
528
546
                return False
529
547
            else:
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)
1045
1066
    try:
1046
1067
        working_kind = working_tree.kind(file_id)
1047
1068
        has_contents = True
1048
 
    except OSError, e:
1049
 
        if e.errno != errno.ENOENT:
1050
 
            raise
 
1069
    except NoSuchFile:
1051
1070
        has_contents = False
1052
1071
        contents_mod = True
1053
1072
        meta_mod = False
1197
1216
            new_conflicts.add((c_type, 'Versioned directory', conflict[1]))
1198
1217
    return new_conflicts
1199
1218
 
 
1219
 
1200
1220
def cook_conflicts(raw_conflicts, tt):
1201
1221
    """Generate a list of cooked conflicts, sorted by file path"""
1202
 
    def key(conflict):
1203
 
        if conflict.path is not None:
1204
 
            return conflict.path, conflict.typestring
1205
 
        elif getattr(conflict, "conflict_path", None) is not None:
1206
 
            return conflict.conflict_path, conflict.typestring
1207
 
        else:
1208
 
            return None, conflict.typestring
 
1222
    from bzrlib.conflicts import Conflict
 
1223
    conflict_iter = iter_cook_conflicts(raw_conflicts, tt)
 
1224
    return sorted(conflict_iter, key=Conflict.sort_key)
1209
1225
 
1210
 
    return sorted(list(iter_cook_conflicts(raw_conflicts, tt)), key=key)
1211
1226
 
1212
1227
def iter_cook_conflicts(raw_conflicts, tt):
1213
1228
    from bzrlib.conflicts import Conflict