~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

Handle progress phases more nicely in merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from bzrlib.merge3 import Merge3
38
38
import bzrlib.osutils
39
39
from bzrlib.osutils import rename, pathjoin
40
 
from progress import DummyProgress
 
40
from progress import DummyProgress, ProgressPhase
41
41
from bzrlib.revision import common_ancestor, is_ancestor, NULL_REVISION
42
42
from bzrlib.symbol_versioning import *
43
43
from bzrlib.trace import mutter, warning, note
99
99
        self.show_base = False
100
100
        self.reprocess = False
101
101
        self._pb = pb 
 
102
        self.pp = None
 
103
 
102
104
 
103
105
    def revision_tree(self, revision_id):
104
106
        return self.this_branch.repository.revision_tree(revision_id)
204
206
        mutter("doing merge() with no base_revision specified")
205
207
        if base_revision == [None, None]:
206
208
            try:
207
 
                self.base_rev_id = common_ancestor(self.this_basis, 
208
 
                                                   self.other_basis, 
209
 
                                                   self.this_branch.repository,
210
 
                                                   self._pb)
 
209
                pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
210
                try:
 
211
                    this_repo = self.this_branch.repository
 
212
                    self.base_rev_id = common_ancestor(self.this_basis, 
 
213
                                                       self.other_basis, 
 
214
                                                       this_repo, pb)
 
215
                finally:
 
216
                    pb.finished()
211
217
            except NoCommonAncestor:
212
218
                raise UnrelatedBranches()
213
219
            self.base_tree = _get_revid_tree(self.this_branch, self.base_rev_id,
229
235
    def do_merge(self):
230
236
        kwargs = {'working_tree':self.this_tree, 'this_tree': self.this_tree, 
231
237
                  'other_tree': self.other_tree, 
232
 
                  'interesting_ids': self.interesting_ids}
 
238
                  'interesting_ids': self.interesting_ids,
 
239
                  'pp': self.pp}
233
240
        if self.merge_type.requires_base:
234
241
            kwargs['base_tree'] = self.base_tree
235
242
        if self.merge_type.supports_reprocess:
321
328
 
322
329
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
323
330
                 interesting_ids=None, reprocess=False, show_base=False,
324
 
                 pb=DummyProgress()):
 
331
                 pb=DummyProgress(), pp=None):
325
332
        """Initialize the merger object and perform the merge."""
326
333
        object.__init__(self)
327
334
        self.this_tree = working_tree
332
339
        self.reprocess = reprocess
333
340
        self.show_base = show_base
334
341
        self.pb = pb
 
342
        self.pp = pp
 
343
        if self.pp is None:
 
344
            self.pp = ProgressPhase("Merge phase", 3, self.pb)
335
345
 
336
346
        if interesting_ids is not None:
337
347
            all_ids = interesting_ids
340
350
            all_ids.update(other_tree)
341
351
        self.tt = TreeTransform(working_tree, self.pb)
342
352
        try:
343
 
            self.pb.update('Merge phase', 0, 3)
 
353
            self.pp.next_phase()
344
354
            child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
345
355
            try:
346
356
                for num, file_id in enumerate(all_ids):
351
361
            finally:
352
362
                child_pb.finished()
353
363
                
354
 
            self.pb.update('Merge phase', 1, 3)
 
364
            self.pp.next_phase()
355
365
            child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
356
366
            try:
357
367
                fs_conflicts = resolve_conflicts(self.tt, child_pb)
360
370
            self.cook_conflicts(fs_conflicts)
361
371
            for line in conflicts_strings(self.cooked_conflicts):
362
372
                warning(line)
363
 
            self.pb.update('Merge phase', 2, 3)
 
373
            self.pp.next_phase()
364
374
            results = self.tt.apply()
365
375
        finally:
366
376
            try:
738
748
    supports_show_base = False
739
749
 
740
750
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
741
 
                 interesting_ids=None, pb=DummyProgress()):
 
751
                 interesting_ids=None, pb=DummyProgress(), pp=None):
742
752
        self.this_revision_tree = self._get_revision_tree(this_tree)
743
753
        self.other_revision_tree = self._get_revision_tree(other_tree)
744
754
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
745
755
                                          base_tree, other_tree, 
746
756
                                          interesting_ids=interesting_ids, 
747
 
                                          pb=pb)
 
757
                                          pb=pb, pp=pp)
748
758
 
749
759
    def _get_revision_tree(self, tree):
750
760
        """Return a revision tree releated to this tree.