2662
2661
change_reporter = delta._ChangeReporter(
2663
2662
unversioned_filter=tree.is_ignored)
2664
other_transport = None
2665
other_revision_id = None
2666
possible_transports = []
2667
# The user may provide a bundle or branch as 'branch' We first try to
2668
# identify a bundle, if it's not, we try to preserve connection used by
2669
# the transport to access the branch.
2665
2670
if branch is not None:
2667
mergeable = bundle.read_mergeable_from_url(
2669
except errors.NotABundle:
2670
pass # Continue on considering this url a Branch
2672
if revision is not None:
2673
raise errors.BzrCommandError(
2674
'Cannot use -r with merge directives or bundles')
2675
other_revision_id = mergeable.install_revisions(
2676
tree.branch.repository)
2677
revision = [RevisionSpec.from_string(
2678
'revid:' + other_revision_id)]
2671
url = urlutils.normalize_url(branch)
2672
url, filename = urlutils.split(url, exclude_trailing_slash=False)
2673
other_transport = transport.get_transport(url)
2676
read_bundle = bundle.read_mergeable_from_transport
2677
# There may be redirections but we ignore the intermediate
2678
# and final transports used
2679
mergeable, t = read_bundle(other_transport, filename)
2680
except errors.NotABundle:
2681
# Continue on considering this url a Branch but adjust the
2683
other_transport = other_transport.clone(filename)
2685
if revision is not None:
2686
raise errors.BzrCommandError('Cannot use -r with merge'
2687
' directives or bundles')
2688
other_revision_id = mergeable.install_revisions(
2689
tree.branch.repository)
2690
revision = [RevisionSpec.from_string(
2691
'revid:' + other_revision_id)]
2692
possible_transports.append(other_transport)
2680
2694
if revision is None \
2681
2695
or len(revision) < 1 or revision[0].needs_branch():
2689
2703
base = [None, None]
2690
2704
other = [branch, -1]
2691
other_branch, path = Branch.open_containing(branch)
2705
other_branch, path = Branch.open_containing(branch,
2706
possible_transports)
2693
2708
if uncommitted:
2694
2709
raise errors.BzrCommandError('Cannot use --uncommitted and'
2697
2712
if len(revision) == 1:
2698
2713
base = [None, None]
2699
2714
if other_revision_id is not None:
2715
# We merge from a bundle
2700
2716
other_branch = None
2704
other_branch, path = Branch.open_containing(branch)
2720
other_branch, path = Branch.open_containing(
2721
branch, possible_transports)
2705
2722
revno = revision[0].in_history(other_branch).revno
2706
2723
other = [branch, revno]
2709
2726
if None in revision:
2710
2727
raise errors.BzrCommandError(
2711
2728
"Merge doesn't permit empty revision specifier.")
2712
base_branch, path = Branch.open_containing(branch)
2729
base_branch, path = Branch.open_containing(branch,
2730
possible_transports)
2713
2731
branch1 = revision[1].get_branch() or branch
2714
other_branch, path1 = Branch.open_containing(branch1)
2732
other_branch, path1 = Branch.open_containing(
2733
branch1, possible_transports)
2715
2734
if revision[0].get_branch() is not None:
2716
2735
# then path was obtained from it, and is None.
2719
2738
base = [branch, revision[0].in_history(base_branch).revno]
2720
2739
other = [branch1, revision[1].in_history(other_branch).revno]
2741
# Remember where we merge from
2722
2742
if ((tree.branch.get_parent() is None or remember) and
2723
2743
other_branch is not None):
2724
2744
tree.branch.set_parent(other_branch.base)
2738
2758
conflict_count = _merge_helper(
2739
other, base, other_rev_id=other_revision_id,
2759
other, base, possible_transports,
2760
other_rev_id=other_revision_id,
2740
2761
check_clean=(not force),
2741
2762
merge_type=merge_type,
2742
2763
reprocess=reprocess,
3684
3705
# command-line interpretation helper for merge-related commands
3685
def _merge_helper(other_revision, base_revision,
3706
def _merge_helper(other_revision, base_revision, possible_transports=None,
3686
3707
check_clean=True, ignore_zero=False,
3687
3708
this_dir=None, backup_files=False,
3688
3709
merge_type=None,
3749
3770
if other_rev_id is not None:
3750
3771
merger.set_other_revision(other_rev_id, this_tree.branch)
3752
merger.set_other(other_revision)
3773
merger.set_other(other_revision, possible_transports)
3753
3774
merger.pp.next_phase()
3754
3775
merger.set_base(base_revision)
3755
3776
if merger.base_rev_id == merger.other_rev_id: