566
566
def _maybe_fetch(self, source, target, revision_id):
567
567
if not source.repository.has_same_location(target.repository):
568
target.fetch(source, revision_id)
569
tags_to_fetch = set(source.tags.get_reverse_tag_dict())
570
except errors.TagsNotSupported:
572
fetch_spec = _mod_graph.NotInOtherForRevs(target.repository,
573
source.repository, [revision_id],
574
if_present_ids=tags_to_fetch).execute()
575
target.fetch(source, fetch_spec=fetch_spec)
570
577
def find_base(self):
571
578
revisions = [_mod_revision.ensure_null(self.this_basis),
582
589
elif len(lcas) == 1:
583
590
self.base_rev_id = list(lcas)[0]
584
591
else: # len(lcas) > 1
592
self._is_criss_cross = True
585
593
if len(lcas) > 2:
586
594
# find_unique_lca can only handle 2 nodes, so we have to
587
595
# start back at the beginning. It is a shame to traverse
593
601
self.base_rev_id = self.revision_graph.find_unique_lca(
595
self._is_criss_cross = True
603
sorted_lca_keys = self.revision_graph.find_merge_order(
605
if self.base_rev_id == _mod_revision.NULL_REVISION:
606
self.base_rev_id = sorted_lca_keys[0]
596
608
if self.base_rev_id == _mod_revision.NULL_REVISION:
597
609
raise errors.UnrelatedBranches()
598
610
if self._is_criss_cross:
599
611
trace.warning('Warning: criss-cross merge encountered. See bzr'
600
612
' help criss-cross.')
601
613
trace.mutter('Criss-cross lcas: %r' % lcas)
602
interesting_revision_ids = [self.base_rev_id]
603
interesting_revision_ids.extend(lcas)
614
if self.base_rev_id in lcas:
615
trace.mutter('Unable to find unique lca. '
616
'Fallback %r as best option.' % self.base_rev_id)
617
interesting_revision_ids = set(lcas)
618
interesting_revision_ids.add(self.base_rev_id)
604
619
interesting_trees = dict((t.get_revision_id(), t)
605
620
for t in self.this_branch.repository.revision_trees(
606
621
interesting_revision_ids))
607
622
self._cached_trees.update(interesting_trees)
608
self.base_tree = interesting_trees.pop(self.base_rev_id)
609
sorted_lca_keys = self.revision_graph.find_merge_order(
623
if self.base_rev_id in lcas:
624
self.base_tree = interesting_trees[self.base_rev_id]
626
self.base_tree = interesting_trees.pop(self.base_rev_id)
611
627
self._lca_trees = [interesting_trees[key]
612
628
for key in sorted_lca_keys]