~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2006-02-16 18:52:17 UTC
  • mto: (1558.1.4 Aaron's integration)
  • mto: This revision was merged to the branch mainline in revision 1565.
  • Revision ID: abentley@panoramicfeedback.com-20060216185217-c766d147d91191d8
Added progress bars to merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
                           ExistingLimbo, ImmortalLimbo)
25
25
from bzrlib.inventory import InventoryEntry
26
26
from bzrlib.osutils import file_kind, supports_executable, pathjoin
 
27
from bzrlib.progress import DummyProgress
27
28
from bzrlib.trace import mutter
28
29
 
29
30
 
38
39
 
39
40
class TreeTransform(object):
40
41
    """Represent a tree transformation."""
41
 
    def __init__(self, tree):
 
42
    def __init__(self, tree, pb=DummyProgress()):
42
43
        """Note: a write lock is taken on the tree.
43
44
        
44
45
        Use TreeTransform.finalize() to release the lock
72
73
        self._tree_id_paths = {}
73
74
        self._new_root = self.get_id_tree(tree.get_root_id())
74
75
        self.__done = False
 
76
        self._pb = pb
75
77
 
76
78
    def __get_root(self):
77
79
        return self._new_root
654
656
        """
655
657
        tree_paths = list(self._tree_path_ids.iteritems())
656
658
        tree_paths.sort(reverse=True)
657
 
        for path, trans_id in tree_paths:
 
659
        for num, data in enumerate(tree_paths):
 
660
            path, trans_id = data
 
661
            self._pb.update('removing file', num+1, len(tree_paths))
658
662
            full_path = self._tree.abspath(path)
659
663
            if trans_id in self._removed_contents:
660
664
                self.delete_any(full_path)
675
679
                if file_id is not None:
676
680
                    limbo_inv[trans_id] = inv[file_id]
677
681
                    del inv[file_id]
 
682
        self._pb.clear()
678
683
 
679
684
    def _apply_insertions(self, inv, limbo_inv):
680
685
        """Perform tree operations that insert directory/inventory names.
683
688
        limbo any files that needed renaming.  This must be done in strict
684
689
        parent-to-child order.
685
690
        """
686
 
        for path, trans_id in self.new_paths():
 
691
        new_paths = self.new_paths()
 
692
        for num, (path, trans_id) in enumerate(new_paths):
 
693
            self._pb.update('adding file', num+1, len(new_paths))
687
694
            try:
688
695
                kind = self._new_contents[trans_id]
689
696
            except KeyError:
714
721
            # requires files and inventory entries to be in place
715
722
            if trans_id in self._new_executability:
716
723
                self._set_executability(path, inv, trans_id)
 
724
        self._pb.clear()
717
725
 
718
726
    def _set_executability(self, path, inv, trans_id):
719
727
        """Set the executability of versioned files """
999
1007
        tt.finalize()
1000
1008
 
1001
1009
 
1002
 
def resolve_conflicts(tt):
 
1010
def resolve_conflicts(tt, pb=DummyProgress()):
1003
1011
    """Make many conflict-resolution attempts, but die if they fail"""
1004
1012
    new_conflicts = set()
1005
 
    for n in range(10):
1006
 
        conflicts = tt.find_conflicts()
1007
 
        if len(conflicts) == 0:
1008
 
            return new_conflicts
1009
 
        new_conflicts.update(conflict_pass(tt, conflicts))
1010
 
    raise MalformedTransform(conflicts=conflicts)
 
1013
    try:
 
1014
        for n in range(10):
 
1015
            pb.update('Resolution pass', n+1, 10)
 
1016
            conflicts = tt.find_conflicts()
 
1017
            if len(conflicts) == 0:
 
1018
                return new_conflicts
 
1019
            new_conflicts.update(conflict_pass(tt, conflicts))
 
1020
        raise MalformedTransform(conflicts=conflicts)
 
1021
    finally:
 
1022
        pb.clear()
1011
1023
 
1012
1024
 
1013
1025
def conflict_pass(tt, conflicts):