~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

merge merge tweaks from aaron, which includes latest .dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.changeset import generate_changeset, ExceptionConflictHandler
28
28
from bzrlib.changeset import Inventory, Diff3Merge
29
29
from bzrlib.branch import Branch
30
 
from bzrlib.errors import BzrCommandError, UnrelatedBranches
 
30
from bzrlib.errors import BzrCommandError, UnrelatedBranches, NoCommonAncestor
 
31
from bzrlib.errors import NoCommits
31
32
from bzrlib.delta import compare_trees
32
33
from bzrlib.trace import mutter, warning
33
34
from bzrlib.fetch import greedy_fetch
46
47
    conflict that are not explicitly handled cause an exception and
47
48
    terminate the merge.
48
49
    """
49
 
    def __init__(self, dir, ignore_zero=False):
50
 
        ExceptionConflictHandler.__init__(self, dir)
 
50
    def __init__(self, ignore_zero=False):
 
51
        ExceptionConflictHandler.__init__(self)
51
52
        self.conflicts = 0
52
53
        self.ignore_zero = ignore_zero
53
54
 
256
257
                                            this_branch)
257
258
        if other_revision[1] == -1:
258
259
            other_rev_id = other_branch.last_patch()
 
260
            if other_rev_id is None:
 
261
                raise NoCommits(other_branch)
259
262
            other_basis = other_rev_id
260
263
        elif other_revision[1] is not None:
261
264
            other_rev_id = other_branch.get_rev_id(other_revision[1])
263
266
        else:
264
267
            other_rev_id = None
265
268
            other_basis = other_branch.last_patch()
 
269
            if other_basis is None:
 
270
                raise NoCommits(other_branch)
266
271
        if base_revision == [None, None]:
267
 
            base_rev_id = common_ancestor(this_rev_id, other_basis, 
268
 
                                          this_branch)
269
 
            if base_rev_id is None:
 
272
            try:
 
273
                base_rev_id = common_ancestor(this_rev_id, other_basis, 
 
274
                                              this_branch)
 
275
            except NoCommonAncestor:
270
276
                raise UnrelatedBranches()
271
277
            base_tree = get_revid_tree(this_branch, base_rev_id, tempdir, 
272
278
                                       "base", None)
279
285
                base_rev_id = None
280
286
            else:
281
287
                base_rev_id = base_branch.get_rev_id(base_revision[1])
282
 
            if base_rev_id is not None:
283
 
                base_is_ancestor = is_ancestor(this_rev_id, base_rev_id, 
284
 
                                               MultipleRevisionSources(this_branch, 
285
 
                                                                       base_branch))
286
 
            else:
287
 
                base_is_ancestor = False
 
288
            multi_source = MultipleRevisionSources(this_branch, base_branch)
 
289
            base_is_ancestor = is_ancestor(this_rev_id, base_rev_id,
 
290
                                           multi_source)
288
291
        if file_list is None:
289
292
            interesting_ids = None
290
293
        else:
346
349
 
347
350
    inv_changes = merge_flex(this_tree, base_tree, other_tree,
348
351
                             generate_cset_optimized, get_inventory,
349
 
                             MergeConflictHandler(base_tree.root,
350
 
                                                  ignore_zero=ignore_zero),
 
352
                             MergeConflictHandler(ignore_zero=ignore_zero),
351
353
                             merge_factory=merge_factory, 
352
354
                             interesting_ids=interesting_ids)
353
355