~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Patch Queue Manager
  • Date: 2011-11-17 19:50:38 UTC
  • mfrom: (5268.8.23 switch-colocated)
  • Revision ID: pqm@pqm.ubuntu.com-20111117195038-1e3ypqmovs2bjhtp
(jelmer) Support switching to colocated branches in "bzr switch". (Jelmer
 Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6070
6070
            if '/' not in to_location and '\\' not in to_location:
6071
6071
                # This path is meant to be relative to the existing branch
6072
6072
                this_url = self._get_branch_location(control_dir)
6073
 
                to_location = urlutils.join(this_url, '..', to_location)
 
6073
                # Perhaps the target control dir supports colocated branches?
 
6074
                try:
 
6075
                    root = controldir.ControlDir.open(this_url,
 
6076
                        possible_transports=[control_dir.user_transport])
 
6077
                except errors.NotBranchError:
 
6078
                    colocated = False
 
6079
                else:
 
6080
                    colocated = root._format.colocated_branches
 
6081
                if colocated:
 
6082
                    to_location = urlutils.join_segment_parameters(this_url,
 
6083
                        {"branch": urlutils.escape(to_location)})
 
6084
                else:
 
6085
                    to_location = urlutils.join(
 
6086
                        this_url, '..', urlutils.escape(to_location))
6074
6087
            to_branch = branch.bzrdir.sprout(to_location,
6075
6088
                                 possible_transports=[branch.bzrdir.root_transport],
6076
6089
                                 source_branch=branch).open_branch()
6077
6090
        else:
 
6091
            # Perhaps it's a colocated branch?
6078
6092
            try:
6079
 
                to_branch = Branch.open(to_location)
6080
 
            except errors.NotBranchError:
6081
 
                this_url = self._get_branch_location(control_dir)
6082
 
                to_branch = Branch.open(
6083
 
                    urlutils.join(this_url, '..', to_location))
 
6093
                to_branch = control_dir.open_branch(to_location)
 
6094
            except (errors.NotBranchError, errors.NoColocatedBranchSupport):
 
6095
                try:
 
6096
                    to_branch = Branch.open(to_location)
 
6097
                except errors.NotBranchError:
 
6098
                    this_url = self._get_branch_location(control_dir)
 
6099
                    to_branch = Branch.open(
 
6100
                        urlutils.join(
 
6101
                            this_url, '..', urlutils.escape(to_location)))
6084
6102
        if revision is not None:
6085
6103
            revision = revision.as_revision_id(to_branch)
6086
6104
        switch.switch(control_dir, to_branch, force, revision_id=revision)