~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-03-09 21:04:59 UTC
  • mfrom: (1551.2.34 Aaron's small fixes)
  • Revision ID: pqm@pqm.ubuntu.com-20060309210459-a48571e310db5c23
Progress bar shows overall progress

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
44
44
from bzrlib.transform import (TreeTransform, resolve_conflicts, cook_conflicts,
45
45
                              conflicts_strings, FinalPaths, create_by_entry,
46
46
                              unique_add)
 
47
import bzrlib.ui
47
48
 
48
49
# TODO: Report back as changes are merged in
49
50
 
98
99
        self.show_base = False
99
100
        self.reprocess = False
100
101
        self._pb = pb 
 
102
        self.pp = None
 
103
 
101
104
 
102
105
    def revision_tree(self, revision_id):
103
106
        return self.this_branch.repository.revision_tree(revision_id)
203
206
        mutter("doing merge() with no base_revision specified")
204
207
        if base_revision == [None, None]:
205
208
            try:
206
 
                self.base_rev_id = common_ancestor(self.this_basis, 
207
 
                                                   self.other_basis, 
208
 
                                                   self.this_branch.repository,
209
 
                                                   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()
210
217
            except NoCommonAncestor:
211
218
                raise UnrelatedBranches()
212
219
            self.base_tree = _get_revid_tree(self.this_branch, self.base_rev_id,
228
235
    def do_merge(self):
229
236
        kwargs = {'working_tree':self.this_tree, 'this_tree': self.this_tree, 
230
237
                  'other_tree': self.other_tree, 
231
 
                  'interesting_ids': self.interesting_ids}
 
238
                  'interesting_ids': self.interesting_ids,
 
239
                  'pp': self.pp}
232
240
        if self.merge_type.requires_base:
233
241
            kwargs['base_tree'] = self.base_tree
234
242
        if self.merge_type.supports_reprocess:
320
328
 
321
329
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
322
330
                 interesting_ids=None, reprocess=False, show_base=False,
323
 
                 pb=DummyProgress()):
 
331
                 pb=DummyProgress(), pp=None):
324
332
        """Initialize the merger object and perform the merge."""
325
333
        object.__init__(self)
326
334
        self.this_tree = working_tree
331
339
        self.reprocess = reprocess
332
340
        self.show_base = show_base
333
341
        self.pb = pb
 
342
        self.pp = pp
 
343
        if self.pp is None:
 
344
            self.pp = ProgressPhase("Merge phase", 3, self.pb)
334
345
 
335
346
        if interesting_ids is not None:
336
347
            all_ids = interesting_ids
339
350
            all_ids.update(other_tree)
340
351
        self.tt = TreeTransform(working_tree, self.pb)
341
352
        try:
342
 
            for num, file_id in enumerate(all_ids):
343
 
                self.pb.update('Preparing file merge', num+1, len(all_ids))
344
 
                self.merge_names(file_id)
345
 
                file_status = self.merge_contents(file_id)
346
 
                self.merge_executable(file_id, file_status)
347
 
            self.pb.clear()
 
353
            self.pp.next_phase()
 
354
            child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
355
            try:
 
356
                for num, file_id in enumerate(all_ids):
 
357
                    child_pb.update('Preparing file merge', num, len(all_ids))
 
358
                    self.merge_names(file_id)
 
359
                    file_status = self.merge_contents(file_id)
 
360
                    self.merge_executable(file_id, file_status)
 
361
            finally:
 
362
                child_pb.finished()
348
363
                
349
 
            fs_conflicts = resolve_conflicts(self.tt, self.pb)
 
364
            self.pp.next_phase()
 
365
            child_pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
366
            try:
 
367
                fs_conflicts = resolve_conflicts(self.tt, child_pb)
 
368
            finally:
 
369
                child_pb.finished()
350
370
            self.cook_conflicts(fs_conflicts)
351
371
            for line in conflicts_strings(self.cooked_conflicts):
352
372
                warning(line)
 
373
            self.pp.next_phase()
353
374
            results = self.tt.apply()
354
375
        finally:
355
376
            try:
356
377
                self.tt.finalize()
357
378
            except:
358
379
                pass
 
380
            self.pb.clear()
359
381
        self.write_modified(results)
360
382
 
361
383
    def write_modified(self, results):
726
748
    supports_show_base = False
727
749
 
728
750
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
729
 
                 interesting_ids=None, pb=DummyProgress()):
 
751
                 interesting_ids=None, pb=DummyProgress(), pp=None):
730
752
        self.this_revision_tree = self._get_revision_tree(this_tree)
731
753
        self.other_revision_tree = self._get_revision_tree(other_tree)
732
754
        super(WeaveMerger, self).__init__(working_tree, this_tree, 
733
755
                                          base_tree, other_tree, 
734
756
                                          interesting_ids=interesting_ids, 
735
 
                                          pb=pb)
 
757
                                          pb=pb, pp=pp)
736
758
 
737
759
    def _get_revision_tree(self, tree):
738
760
        """Return a revision tree releated to this tree.