~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-03-26 19:39:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2393.
  • Revision ID: abentley@panoramicfeedback.com-20070326193914-quycobjtiy7js5hl
Clean up apply methods

Show diffs side-by-side

added added

removed removed

Lines of Context:
738
738
        conflicts = self.find_conflicts()
739
739
        if len(conflicts) != 0:
740
740
            raise MalformedTransform(conflicts=conflicts)
741
 
        limbo_inv = {}
742
741
        inv = self._tree.inventory
 
742
        inventory_delta = []
743
743
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
744
744
        try:
745
745
            child_pb.update('Apply phase', 0, 2)
746
 
            self._apply_removals(inv, limbo_inv)
 
746
            self._apply_removals(inv, inventory_delta)
747
747
            child_pb.update('Apply phase', 1, 2)
748
 
            modified_paths = self._apply_insertions(inv, limbo_inv)
 
748
            modified_paths = self._apply_insertions(inv, inventory_delta)
749
749
        finally:
750
750
            child_pb.finished()
751
 
        self._tree.apply_inventory_delta(self.__inventory_delta)
 
751
        self._tree.apply_inventory_delta(inventory_delta)
752
752
        self.__done = True
753
753
        self.finalize()
754
754
        return _TransformResults(modified_paths)
757
757
        """Generate the limbo name of a file"""
758
758
        return pathjoin(self._limbodir, trans_id)
759
759
 
760
 
    def _apply_removals(self, inv, limbo_inv):
 
760
    def _apply_removals(self, inv, inventory_delta):
761
761
        """Perform tree operations that remove directory/inventory names.
762
762
        
763
763
        That is, delete files that are to be deleted, and put any files that
764
764
        need renaming into limbo.  This must be done in strict child-to-parent
765
765
        order.
766
766
        """
767
 
        self.__inventory_delta = []
768
767
        tree_paths = list(self._tree_path_ids.iteritems())
769
768
        tree_paths.sort(reverse=True)
770
769
        child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
788
787
                    else:
789
788
                        file_id = self.tree_file_id(trans_id)
790
789
                    assert file_id is not None
791
 
                    self.__inventory_delta.append((path, None, file_id,
792
 
                                                  None))
 
790
                    inventory_delta.append((path, None, file_id, None))
793
791
        finally:
794
792
            child_pb.finished()
795
793
 
796
 
    def _apply_insertions(self, inv, limbo_inv):
 
794
    def _apply_insertions(self, inv, inventory_delta):
797
795
        """Perform tree operations that insert directory/inventory names.
798
796
        
799
797
        That is, create any files that need to be created, and restore from
862
860
                        old_path = inv.id2path(new_entry.file_id)
863
861
                    else:
864
862
                        old_path = None
865
 
                    self.__inventory_delta.append((old_path, path,
866
 
                                                   new_entry.file_id,
867
 
                                                   new_entry))
 
863
                    inventory_delta.append((old_path, path,
 
864
                                            new_entry.file_id,
 
865
                                            new_entry))
868
866
        finally:
869
867
            child_pb.finished()
870
868
        return modified_paths