596
596
branch_to = Branch.open_containing(directory)[0]
599
# The user may provide a bundle or branch as 'location' We first try to
600
# identify a bundle, if it's not, we try to preserve connection used by
601
# the transport to access the branch.
602
598
if location is not None:
603
url = urlutils.normalize_url(location)
604
url, filename = urlutils.split(url, exclude_trailing_slash=False)
605
location_transport = transport.get_transport(url)
608
read_bundle = bundle.read_mergeable_from_transport
609
# There may be redirections but we ignore the intermediate
610
# and final transports used
611
mergeable, t = read_bundle(location_transport, filename)
612
except errors.NotABundle:
613
# Continue on considering this url a Branch but adjust the
615
location_transport = location_transport.clone(filename)
617
# A directory was provided, location_transport is correct
599
mergeable, location_transport = _get_bundle_helper(location)
620
601
stored_loc = branch_to.get_parent()
621
602
if location is None:
2672
2653
other_transport = None
2673
2654
other_revision_id = None
2674
2655
possible_transports = []
2675
# The user may provide a bundle or branch as 'branch' We first try to
2676
# identify a bundle, if it's not, we try to preserve connection used by
2677
# the transport to access the branch.
2678
2657
if branch is not None:
2679
url = urlutils.normalize_url(branch)
2680
url, filename = urlutils.split(url, exclude_trailing_slash=False)
2681
other_transport = transport.get_transport(url)
2684
read_bundle = bundle.read_mergeable_from_transport
2685
# There may be redirections but we ignore the intermediate
2686
# and final transports used
2687
mergeable, t = read_bundle(other_transport, filename)
2688
except errors.NotABundle:
2689
# Continue on considering this url a Branch but adjust the
2691
other_transport = other_transport.clone(filename)
2693
if revision is not None:
2694
raise errors.BzrCommandError('Cannot use -r with merge'
2695
' directives or bundles')
2696
other_revision_id = mergeable.install_revisions(
2697
tree.branch.repository)
2698
revision = [RevisionSpec.from_string(
2699
'revid:' + other_revision_id)]
2700
possible_transports.append(other_transport)
2658
mergeable, other_transport = _get_bundle_helper(branch)
2660
if revision is not None:
2661
raise errors.BzrCommandError('Cannot use -r with merge'
2662
' directives or bundles')
2663
other_revision_id = mergeable.install_revisions(
2664
tree.branch.repository)
2665
revision = [RevisionSpec.from_string('revid:'
2666
+ other_revision_id)]
2667
possible_transports.append(other_transport)
2702
2669
if revision is None \
2703
2670
or len(revision) < 1 or revision[0].needs_branch():
2766
2733
conflict_count = _merge_helper(
2767
other, base, possible_transports,
2768
2735
other_rev_id=other_revision_id,
2769
2736
check_clean=(not force),
2770
2737
merge_type=merge_type,
2774
2741
this_dir=directory,
2775
2742
pb=pb, file_list=interesting_files,
2776
change_reporter=change_reporter)
2743
change_reporter=change_reporter,
2744
possible_transports=possible_transports)
2779
2747
if conflict_count != 0:
3052
3020
" or specified.")
3053
3021
display_url = urlutils.unescape_for_display(parent,
3054
3022
self.outf.encoding)
3055
self.outf.write("Using last location: " + display_url + '\n')
3023
self.outf.write("Using last location: " + display_url + "\n")
3057
3025
remote_branch = Branch.open(other_branch)
3058
3026
if remote_branch.base == local_branch.base:
3755
3723
# command-line interpretation helper for merge-related commands
3756
def _merge_helper(other_revision, base_revision, possible_transports=None,
3724
def _merge_helper(other_revision, base_revision,
3757
3725
check_clean=True, ignore_zero=False,
3758
3726
this_dir=None, backup_files=False,
3759
3727
merge_type=None,
3871
3840
cur_transport.ensure_base()
3843
def _get_bundle_helper(location):
3844
"""Get a bundle if 'location' points to one.
3846
Try try to identify a bundle and returns its mergeable form. If it's not,
3847
we return the tried transport anyway so that it can reused to access the
3850
:param location: can point to a bundle or a branch.
3852
:return: mergeable, transport
3855
url = urlutils.normalize_url(location)
3856
url, filename = urlutils.split(url, exclude_trailing_slash=False)
3857
location_transport = transport.get_transport(url)
3860
# There may be redirections but we ignore the intermediate
3861
# and final transports used
3862
read = bundle.read_mergeable_from_transport
3863
mergeable, t = read(location_transport, filename)
3864
except errors.NotABundle:
3865
# Continue on considering this url a Branch but adjust the
3866
# location_transport
3867
location_transport = location_transport.clone(filename)
3868
return mergeable, location_transport
3874
3871
# Compatibility
3875
3872
merge = _merge_helper