582
582
elif len(lcas) == 1:
583
583
self.base_rev_id = list(lcas)[0]
584
584
else: # len(lcas) > 1
585
self._is_criss_cross = True
586
585
if len(lcas) > 2:
587
586
# find_unique_lca can only handle 2 nodes, so we have to
588
587
# start back at the beginning. It is a shame to traverse
594
593
self.base_rev_id = self.revision_graph.find_unique_lca(
596
sorted_lca_keys = self.revision_graph.find_merge_order(
598
if self.base_rev_id == _mod_revision.NULL_REVISION:
599
self.base_rev_id = sorted_lca_keys[0]
595
self._is_criss_cross = True
601
596
if self.base_rev_id == _mod_revision.NULL_REVISION:
602
597
raise errors.UnrelatedBranches()
603
598
if self._is_criss_cross:
604
599
trace.warning('Warning: criss-cross merge encountered. See bzr'
605
600
' help criss-cross.')
606
601
trace.mutter('Criss-cross lcas: %r' % lcas)
607
if self.base_rev_id in lcas:
608
trace.mutter('Unable to find unique lca. '
609
'Fallback %r as best option.' % self.base_rev_id)
610
interesting_revision_ids = set(lcas)
611
interesting_revision_ids.add(self.base_rev_id)
602
interesting_revision_ids = [self.base_rev_id]
603
interesting_revision_ids.extend(lcas)
612
604
interesting_trees = dict((t.get_revision_id(), t)
613
605
for t in self.this_branch.repository.revision_trees(
614
606
interesting_revision_ids))
615
607
self._cached_trees.update(interesting_trees)
616
if self.base_rev_id in lcas:
617
self.base_tree = interesting_trees[self.base_rev_id]
619
self.base_tree = interesting_trees.pop(self.base_rev_id)
608
self.base_tree = interesting_trees.pop(self.base_rev_id)
609
sorted_lca_keys = self.revision_graph.find_merge_order(
620
611
self._lca_trees = [interesting_trees[key]
621
612
for key in sorted_lca_keys]