~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Martin Pool
  • Date: 2006-11-02 10:20:19 UTC
  • mfrom: (2114 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2119.
  • Revision ID: mbp@sourcefrog.net-20061102102019-9a5a02f485dff6f6
merge bzr.dev and reconcile several changes, also some test fixes

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)
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:
1232
1241
        basis_tree = None
1233
1242
        try:
1234
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
1235
1247
                child_pb.update("New file check", id_num+1, 
1236
1248
                                len(sorted_interesting))
1237
1249
                if file_id not in target_tree: