623
623
possible_transports = []
624
624
if location is not None:
625
mergeable, location_transport = _get_mergeable_helper(location)
626
possible_transports.append(location_transport)
626
mergeable = bundle.read_mergeable_from_url(location,
627
possible_transports=possible_transports)
628
except errors.NotABundle:
628
631
stored_loc = branch_to.get_parent()
629
632
if location is None:
636
639
if not is_quiet():
637
640
self.outf.write("Using saved location: %s\n" % display_url)
638
641
location = stored_loc
639
location_transport = transport.get_transport(
640
location, possible_transports=possible_transports)
642
643
if mergeable is not None:
643
644
if revision is not None:
648
649
mergeable.get_merge_request(branch_to.repository)
649
650
branch_from = branch_to
651
branch_from = Branch.open_from_transport(location_transport)
652
branch_from = Branch.open(location,
653
possible_transports=possible_transports)
653
655
if branch_to.get_parent() is None or remember:
654
656
branch_to.set_parent(branch_from.base)
2860
2862
tree.lock_write()
2861
2863
cleanups.append(tree.unlock)
2862
2864
if location is not None:
2863
mergeable, other_transport = _get_mergeable_helper(location)
2866
mergeable = bundle.read_mergeable_from_url(location,
2867
possible_transports=possible_transports)
2868
except errors.NotABundle:
2865
2871
if uncommitted:
2866
2872
raise errors.BzrCommandError('Cannot use --uncommitted'
2867
2873
' with bundles or merge directives.')
2871
2877
'Cannot use -r with merge directives or bundles')
2872
2878
merger, verified = _mod_merge.Merger.from_mergeable(tree,
2874
possible_transports.append(other_transport)
2876
2881
if merger is None and uncommitted:
2877
2882
if revision is not None and len(revision) > 0:
4520
4525
cur_transport.ensure_base()
4523
def _get_mergeable_helper(location):
4524
"""Get a merge directive or bundle if 'location' points to one.
4526
Try try to identify a bundle and returns its mergeable form. If it's not,
4527
we return the tried transport anyway so that it can reused to access the
4530
:param location: can point to a bundle or a branch.
4532
:return: mergeable, transport
4535
url = urlutils.normalize_url(location)
4536
url, filename = urlutils.split(url, exclude_trailing_slash=False)
4537
location_transport = transport.get_transport(url)
4540
# There may be redirections but we ignore the intermediate
4541
# and final transports used
4542
read = bundle.read_mergeable_from_transport
4543
mergeable, t = read(location_transport, filename)
4544
except errors.NotABundle:
4545
# Continue on considering this url a Branch but adjust the
4546
# location_transport
4547
location_transport = location_transport.clone(filename)
4548
return mergeable, location_transport
4551
4528
# these get imported and then picked up by the scan for cmd_*
4552
4529
# TODO: Some more consistent way to split command definitions across files;
4553
4530
# we do need to load at least some information about them to know of