/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: Aaron Bentley
  • Date: 2006-11-17 04:06:03 UTC
  • mfrom: (2139 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2162.
  • Revision ID: aaron.bentley@utoronto.ca-20061117040603-pgebxndswvwk26tt
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib import bzrdir, errors
22
22
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
23
23
                           ReusingTransform, NotVersionedError, CantMoveRoot,
24
 
                           ExistingLimbo, ImmortalLimbo)
 
24
                           ExistingLimbo, ImmortalLimbo, NoFinalPath)
25
25
from bzrlib.inventory import InventoryEntry
26
26
from bzrlib.osutils import (file_kind, supports_executable, pathjoin, lexists,
27
27
                            delete_any)
292
292
        except KeyError:
293
293
            return
294
294
        try:
295
 
            mode = os.stat(old_path).st_mode
 
295
            mode = os.stat(self._tree.abspath(old_path)).st_mode
296
296
        except OSError, e:
297
297
            if e.errno == errno.ENOENT:
298
298
                return
457
457
        try:
458
458
            return self._new_name[trans_id]
459
459
        except KeyError:
460
 
            return os.path.basename(self._tree_id_paths[trans_id])
 
460
            try:
 
461
                return os.path.basename(self._tree_id_paths[trans_id])
 
462
            except KeyError:
 
463
                raise NoFinalPath(trans_id, self)
461
464
 
462
465
    def by_parent(self):
463
466
        """Return a map of parent: children for known parents.
570
573
            parent_id = trans_id
571
574
            while parent_id is not ROOT_PARENT:
572
575
                seen.add(parent_id)
573
 
                parent_id = self.final_parent(parent_id)
 
576
                try:
 
577
                    parent_id = self.final_parent(parent_id)
 
578
                except KeyError:
 
579
                    break
574
580
                if parent_id == trans_id:
575
581
                    conflicts.append(('parent loop', trans_id))
576
582
                if parent_id in seen:
954
960
      it is silently replaced.
955
961
    - Otherwise, conflict resolution will move the old file to 'oldname.moved'.
956
962
    """
957
 
    assert 2 > len(wt.inventory)
 
963
    if len(wt.inventory) > 1:  # more than just a root
 
964
        raise errors.WorkingTreeAlreadyPopulated(base=wt.basedir)
958
965
    file_trans_id = {}
959
966
    top_pb = bzrlib.ui.ui_factory.nested_progress_bar()
960
967
    pp = ProgressPhase("Build phase", 2, top_pb)
 
968
    if tree.inventory.root is not None:
 
969
        wt.set_root_id(tree.inventory.root.file_id)
961
970
    tt = TreeTransform(wt)
962
971
    divert = set()
963
972
    try:
1229
1238
        pp.next_phase()
1230
1239
        wt_interesting = [i for i in working_tree.inventory if interesting(i)]
1231
1240
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
1241
        basis_tree = None
1232
1242
        try:
1233
1243
            for id_num, file_id in enumerate(wt_interesting):
 
1244
                if (working_tree.inventory.is_root(file_id) and 
 
1245
                    len(target_tree.inventory) == 0):
 
1246
                    continue
1234
1247
                child_pb.update("New file check", id_num+1, 
1235
1248
                                len(sorted_interesting))
1236
1249
                if file_id not in target_tree:
1240
1253
                        file_kind = working_tree.kind(file_id)
1241
1254
                    except NoSuchFile:
1242
1255
                        file_kind = None
 
1256
                    delete_merge_modified = (file_id in merge_modified)
1243
1257
                    if file_kind != 'file' and file_kind is not None:
1244
1258
                        keep_contents = False
1245
 
                        delete_merge_modified = False
1246
1259
                    else:
 
1260
                        if basis_tree is None:
 
1261
                            basis_tree = working_tree.basis_tree()
 
1262
                        wt_sha1 = working_tree.get_file_sha1(file_id)
1247
1263
                        if (file_id in merge_modified and 
1248
 
                            merge_modified[file_id] == 
1249
 
                            working_tree.get_file_sha1(file_id)):
1250
 
                            keep_contents = False
1251
 
                            delete_merge_modified = True
 
1264
                            merge_modified[file_id] == wt_sha1):
 
1265
                            keep_contents = False
 
1266
                        elif (file_id in basis_tree and 
 
1267
                            basis_tree.get_file_sha1(file_id) == wt_sha1):
 
1268
                            keep_contents = False
1252
1269
                        else:
1253
1270
                            keep_contents = True
1254
 
                            delete_merge_modified = False
1255
1271
                    if not keep_contents:
1256
1272
                        tt.delete_contents(trans_id)
1257
1273
                    if delete_merge_modified: