/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/plugins/rewrite/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 20:02:36 UTC
  • mto: (7490.7.7 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200322200236-fsbl91ktcn6fcbdd
Fix tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Bazaar command-line subcommands."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from ...commands import (
20
22
    Command,
21
23
    display_command,
22
24
    )
23
25
from ...errors import (
24
 
    CommandError,
 
26
    BzrCommandError,
25
27
    ConflictsInTree,
26
28
    NoSuchFile,
27
29
    NoWorkingTree,
45
47
        # Start executing plan from current Branch.last_revision()
46
48
        rebase(wt.branch.repository, replace_map, replayer)
47
49
    except ConflictsInTree:
48
 
        raise CommandError(gettext(
 
50
        raise BzrCommandError(gettext(
49
51
            "A conflict occurred replaying a commit."
50
52
            " Resolve the conflict and run 'brz rebase-continue' or "
51
53
            "run 'brz rebase-abort'."))
126
128
            rebase_todo,
127
129
            )
128
130
        if revision is not None and pending_merges:
129
 
            raise CommandError(gettext(
 
131
            raise BzrCommandError(gettext(
130
132
                "--revision and --pending-merges are mutually exclusive"))
131
133
 
132
134
        wt = WorkingTree.open_containing(directory)[0]
139
141
                else:
140
142
                    upstream_location = wt.branch.get_parent()
141
143
                    if upstream_location is None:
142
 
                        raise CommandError(gettext("No upstream branch specified."))
 
144
                        raise BzrCommandError(gettext("No upstream branch specified."))
143
145
                    note(gettext("Rebasing on %s"), upstream_location)
144
146
            upstream = Branch.open_containing(upstream_location)[0]
145
147
            upstream_repository = upstream.repository
146
148
            upstream_revision = upstream.last_revision()
147
149
            # Abort if there already is a plan file
148
150
            if state.has_plan():
149
 
                raise CommandError(gettext(
 
151
                raise BzrCommandError(gettext(
150
152
                    "A rebase operation was interrupted. "
151
153
                    "Continue using 'brz rebase-continue' or abort using 'brz "
152
154
                    "rebase-abort'"))
163
165
                    if revision[1] is not None:
164
166
                        stop_revid = revision[1].as_revision_id(wt.branch)
165
167
                else:
166
 
                    raise CommandError(gettext(
 
168
                    raise BzrCommandError(gettext(
167
169
                        "--revision takes only one or two arguments"))
168
170
 
169
171
            if pending_merges:
170
172
                wt_parents = wt.get_parent_ids()
171
173
                if len(wt_parents) in (0, 1):
172
 
                    raise CommandError(gettext("No pending merges present."))
 
174
                    raise BzrCommandError(gettext("No pending merges present."))
173
175
                elif len(wt_parents) > 2:
174
 
                    raise CommandError(gettext(
 
176
                    raise BzrCommandError(gettext(
175
177
                        "Rebasing more than one pending merge not supported"))
176
178
                stop_revid = wt_parents[1]
177
179
                assert stop_revid is not None, "stop revid invalid"
259
261
            try:
260
262
                last_rev_info = state.read_plan()[0]
261
263
            except NoSuchFile:
262
 
                raise CommandError("No rebase to abort")
 
264
                raise BzrCommandError("No rebase to abort")
263
265
            complete_revert(wt, [last_rev_info[1]])
264
266
            state.remove_plan()
265
267
        finally:
289
291
            replayer = WorkingTreeRevisionRewriter(wt, state, merge_type=merge_type)
290
292
            # Abort if there are any conflicts
291
293
            if len(wt.conflicts()) != 0:
292
 
                raise CommandError(gettext(
 
294
                raise BzrCommandError(gettext(
293
295
                    "There are still conflicts present. "
294
296
                    "Resolve the conflicts and then run "
295
297
                    "'brz resolve' and try again."))
297
299
            try:
298
300
                replace_map = state.read_plan()[1]
299
301
            except NoSuchFile:
300
 
                raise CommandError(gettext("No rebase to continue"))
 
302
                raise BzrCommandError(gettext("No rebase to continue"))
301
303
            oldrevid = state.read_active_revid()
302
304
            if oldrevid is not None:
303
305
                oldrev = wt.branch.repository.get_revision(oldrevid)
332
334
            try:
333
335
                replace_map = state.read_plan()[1]
334
336
            except NoSuchFile:
335
 
                raise CommandError(gettext("No rebase in progress"))
 
337
                raise BzrCommandError(gettext("No rebase in progress"))
336
338
            currentrevid = state.read_active_revid()
337
339
            if currentrevid is not None:
338
340
                note(gettext("Currently replaying: %s") % currentrevid)
380
382
                for revno in range(from_revno, to_revno + 1):
381
383
                    todo.append(from_branch.get_rev_id(revno))
382
384
            else:
383
 
                raise CommandError(gettext(
 
385
                raise BzrCommandError(gettext(
384
386
                    "--revision takes only one or two arguments"))
385
387
        else:
386
 
            raise CommandError(gettext("--revision is mandatory"))
 
388
            raise BzrCommandError(gettext("--revision is mandatory"))
387
389
 
388
390
        wt = WorkingTree.open(directory)
389
391
        wt.lock_write()
473
475
        stored_loc = branch_to.get_parent()
474
476
        if new_base is None:
475
477
            if stored_loc is None:
476
 
                raise CommandError(gettext(
 
478
                raise BzrCommandError(gettext(
477
479
                    "No pull location known or specified."))
478
480
            else:
479
481
                display_url = urlutils.unescape_for_display(