/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/switch.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-05 07:32:38 UTC
  • mto: (7290.1.21 work)
  • mto: This revision was merged to the branch mainline in revision 7311.
  • Revision ID: jelmer@jelmer.uk-20190305073238-zlqn981opwnqsmzi
Add appveyor configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
# Original author: David Allouche
18
20
 
19
21
from . import (
38
40
 
39
41
 
40
42
def switch(control_dir, to_branch, force=False, quiet=False, revision_id=None,
41
 
           store_uncommitted=False, possible_transports=None):
 
43
           store_uncommitted=False):
42
44
    """Switch the branch associated with a checkout.
43
45
 
44
46
    :param control_dir: ControlDir of the checkout to change
65
67
        if tree is not None:
66
68
            parent_ids = tree.get_parent_ids()
67
69
            if len(parent_ids) > 1:
68
 
                raise errors.CommandError(
 
70
                raise errors.BzrCommandError(
69
71
                    gettext('Pending merges must be '
70
72
                            'committed or reverted before using switch.'))
71
73
 
137
139
            possible_transports = []
138
140
            try:
139
141
                if not force and _any_local_commits(b, possible_transports):
140
 
                    raise errors.CommandError(gettext(
 
142
                    raise errors.BzrCommandError(gettext(
141
143
                        'Cannot switch as local commits found in the checkout. '
142
144
                        'Commit these to the bound branch or use --force to '
143
145
                        'throw them away.'))
144
146
            except errors.BoundBranchConnectionFailure as e:
145
 
                raise errors.CommandError(gettext(
 
147
                raise errors.BzrCommandError(gettext(
146
148
                    'Unable to connect to current master branch %(target)s: '
147
149
                    '%(error)s To switch anyway, use --force.') %
148
150
                    e.__dict__)
149
 
            with b.lock_write():
 
151
            b.lock_write()
 
152
            try:
150
153
                b.set_bound_location(None)
151
154
                b.pull(to_branch, overwrite=True,
152
155
                       possible_transports=possible_transports)
153
156
                b.set_bound_location(to_branch.base)
154
157
                b.set_parent(b.get_master_branch().get_parent())
 
158
            finally:
 
159
                b.unlock()
155
160
        else:
156
161
            # If this is a standalone tree and the new branch
157
162
            # is derived from this one, create a lightweight checkout.
163
168
                    b.controldir.destroy_branch()
164
169
                    b.controldir.set_branch_reference(to_branch, name="")
165
170
                else:
166
 
                    raise errors.CommandError(
 
171
                    raise errors.BzrCommandError(
167
172
                        gettext('Cannot switch a branch, only a checkout.'))
168
173
 
169
174