/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from .i18n import gettext
29
29
from .trace import note
30
30
 
 
31
 
31
32
def _run_post_switch_hooks(control_dir, to_branch, force, revision_id):
32
33
    from .branch import SwitchHookParams
33
34
    hooks = Branch.hooks['post_switch']
37
38
    for hook in hooks:
38
39
        hook(params)
39
40
 
 
41
 
40
42
def switch(control_dir, to_branch, force=False, quiet=False, revision_id=None,
41
43
           store_uncommitted=False):
42
44
    """Switch the branch associated with a checkout.
62
64
    _update(tree, source_repository, quiet, revision_id, store_uncommitted)
63
65
    _run_post_switch_hooks(control_dir, to_branch, force, revision_id)
64
66
 
 
67
 
65
68
def _check_pending_merges(control, force=False):
66
69
    """Check that there are no outstanding pending merges before switching.
67
70
 
79
82
    existing_pending_merges = tree.get_parent_ids()[1:]
80
83
    if len(existing_pending_merges) > 0:
81
84
        raise errors.BzrCommandError(gettext('Pending merges must be '
82
 
            'committed or reverted before using switch.'))
 
85
                                             'committed or reverted before using switch.'))
83
86
 
84
87
 
85
88
def _set_branch_location(control, to_branch, force=False):
110
113
                        'throw them away.'))
111
114
            except errors.BoundBranchConnectionFailure as e:
112
115
                raise errors.BzrCommandError(gettext(
113
 
                        'Unable to connect to current master branch %(target)s: '
114
 
                        '%(error)s To switch anyway, use --force.') %
115
 
                        e.__dict__)
 
116
                    'Unable to connect to current master branch %(target)s: '
 
117
                    '%(error)s To switch anyway, use --force.') %
 
118
                    e.__dict__)
116
119
            b.lock_write()
117
120
            try:
118
121
                b.set_bound_location(None)
128
131
            with b.lock_read():
129
132
                graph = b.repository.get_graph(to_branch.repository)
130
133
                if (b.controldir._format.colocated_branches and
131
 
                     (force or graph.is_ancestor(b.last_revision(),
132
 
                        to_branch.last_revision()))):
 
134
                    (force or graph.is_ancestor(
 
135
                        b.last_revision(), to_branch.last_revision()))):
133
136
                    b.controldir.destroy_branch()
134
137
                    b.controldir.set_branch_reference(to_branch, name="")
135
138
                else:
136
 
                    raise errors.BzrCommandError(gettext('Cannot switch a branch, '
137
 
                        'only a checkout.'))
 
139
                    raise errors.BzrCommandError(
 
140
                        gettext('Cannot switch a branch, only a checkout.'))
138
141
 
139
142
 
140
143
def _any_local_commits(this_branch, possible_transports):
169
172
            revision_id = to_branch.last_revision()
170
173
        if tree.last_revision() == revision_id:
171
174
            if not quiet:
172
 
                note(gettext("Tree is up to date at revision %d."), to_branch.revno())
 
175
                note(gettext("Tree is up to date at revision %d."),
 
176
                     to_branch.revno())
173
177
        else:
174
178
            base_tree = source_repository.revision_tree(tree.last_revision())
175
179
            merge.Merge3Merger(tree, tree, base_tree,