~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.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:
38
38
from bzrlib.merge3 import Merge3
39
39
import bzrlib.osutils
40
40
from bzrlib.osutils import rename, pathjoin
 
41
from progress import DummyProgress
41
42
from bzrlib.revision import common_ancestor, is_ancestor, NULL_REVISION
42
43
from bzrlib.transform import (TreeTransform, resolve_conflicts, cook_conflicts,
43
44
                              conflicts_strings, FinalPaths, create_by_entry,
44
45
                              unique_add)
45
46
from bzrlib.trace import mutter, warning, note
 
47
from bzrlib.ui import ui_factory
46
48
 
47
49
# TODO: Report back as changes are merged in
48
50
 
95
97
        self.interesting_ids = None
96
98
        self.show_base = False
97
99
        self.reprocess = False
 
100
        self._pb = ui_factory.progress_bar()
98
101
 
99
102
    def revision_tree(self, revision_id):
100
103
        return self.this_branch.repository.revision_tree(revision_id)
203
206
            try:
204
207
                self.base_rev_id = common_ancestor(self.this_basis, 
205
208
                                                   self.other_basis, 
206
 
                                                   self.this_branch.repository)
 
209
                                                   self.this_branch.repository,
 
210
                                                   self._pb)
207
211
            except NoCommonAncestor:
208
212
                raise UnrelatedBranches()
209
213
            self.base_tree = _get_revid_tree(self.this_branch, self.base_rev_id,
237
241
        elif self.show_base:
238
242
            raise BzrError("Showing base is not supported for this"
239
243
                                  " merge type. %s" % self.merge_type)
240
 
        merge = self.merge_type(**kwargs)
 
244
        merge = self.merge_type(pb=self._pb, **kwargs)
241
245
        if len(merge.cooked_conflicts) == 0:
242
246
            if not self.ignore_zero:
243
247
                note("All changes applied successfully.")
315
319
    history_based = False
316
320
 
317
321
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
318
 
                 reprocess=False, show_base=False):
 
322
                 reprocess=False, show_base=False, pb=DummyProgress()):
319
323
        """Initialize the merger object and perform the merge."""
320
324
        object.__init__(self)
321
325
        self.this_tree = working_tree
325
329
        self.cooked_conflicts = []
326
330
        self.reprocess = reprocess
327
331
        self.show_base = show_base
 
332
        self.pb = pb
328
333
 
329
334
        all_ids = set(base_tree)
330
335
        all_ids.update(other_tree)
331
 
        self.tt = TreeTransform(working_tree)
 
336
        self.tt = TreeTransform(working_tree, self.pb)
332
337
        try:
333
 
            for file_id in all_ids:
 
338
            for num, file_id in enumerate(all_ids):
 
339
                self.pb.update('Preparing file merge', num+1, len(all_ids))
334
340
                self.merge_names(file_id)
335
341
                file_status = self.merge_contents(file_id)
336
342
                self.merge_executable(file_id, file_status)
 
343
            self.pb.clear()
337
344
                
338
 
            fs_conflicts = resolve_conflicts(self.tt)
 
345
            fs_conflicts = resolve_conflicts(self.tt, self.pb)
339
346
            self.cook_conflicts(fs_conflicts)
340
347
            for line in conflicts_strings(self.cooked_conflicts):
341
348
                warning(line)
701
708
    supports_reprocess = False
702
709
    supports_show_base = False
703
710
 
704
 
    def __init__(self, working_tree, this_tree, base_tree, other_tree):
 
711
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
 
712
                 pb=DummyProgress()):
705
713
        self.this_revision_tree = self._get_revision_tree(this_tree)
706
714
        self.other_revision_tree = self._get_revision_tree(other_tree)
707
715
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
708
 
                                          base_tree, other_tree)
 
716
                                          base_tree, other_tree, pb=pb)
709
717
 
710
718
    def _get_revision_tree(self, tree):
711
719
        """Return a revision tree releated to this tree.