~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-03-25 08:34:30 UTC
  • mfrom: (3251.4.12 pull-lp)
  • Revision ID: pqm@pqm.ubuntu.com-20080325083430-0w0gjtnkegce7718
Allow pulling from lp: urls (abentley, #181945)

Show diffs side-by-side

added added

removed removed

Lines of Context:
622
622
 
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)
 
625
            try:
 
626
                mergeable = bundle.read_mergeable_from_url(location,
 
627
                    possible_transports=possible_transports)
 
628
            except errors.NotABundle:
 
629
                mergeable = None
627
630
 
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)
641
642
 
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
650
651
        else:
651
 
            branch_from = Branch.open_from_transport(location_transport)
 
652
            branch_from = Branch.open(location,
 
653
                possible_transports=possible_transports)
652
654
 
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)
2864
 
                if mergeable:
 
2865
                try:
 
2866
                    mergeable = bundle.read_mergeable_from_url(location,
 
2867
                        possible_transports=possible_transports)
 
2868
                except errors.NotABundle:
 
2869
                    mergeable = None
 
2870
                else:
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,
2873
2879
                       mergeable, pb)
2874
 
                possible_transports.append(other_transport)
2875
2880
 
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()
4521
4526
 
4522
4527
 
4523
 
def _get_mergeable_helper(location):
4524
 
    """Get a merge directive or bundle if 'location' points to one.
4525
 
 
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
4528
 
    branch
4529
 
 
4530
 
    :param location: can point to a bundle or a branch.
4531
 
 
4532
 
    :return: mergeable, transport
4533
 
    """
4534
 
    mergeable = None
4535
 
    url = urlutils.normalize_url(location)
4536
 
    url, filename = urlutils.split(url, exclude_trailing_slash=False)
4537
 
    location_transport = transport.get_transport(url)
4538
 
    if filename:
4539
 
        try:
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
4549
 
 
4550
 
 
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