/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/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-13 23:57:28 UTC
  • mfrom: (7490 work)
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200213235728-m6ds0mm3mbs4y182
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""builtin brz commands"""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
import errno
20
22
import os
21
23
import sys
260
262
    if revisions is None:
261
263
        return None
262
264
    if len(revisions) != 1:
263
 
        raise errors.CommandError(gettext(
 
265
        raise errors.BzrCommandError(gettext(
264
266
            'brz %s --revision takes exactly one revision identifier') % (
265
267
                command_name,))
266
268
    return revisions[0]
396
398
        from .status import show_tree_status
397
399
 
398
400
        if revision and len(revision) > 2:
399
 
            raise errors.CommandError(
 
401
            raise errors.BzrCommandError(
400
402
                gettext('brz status --revision takes exactly'
401
403
                        ' one or two revision specifiers'))
402
404
 
441
443
    @display_command
442
444
    def run(self, revision_id=None, revision=None, directory=u'.'):
443
445
        if revision_id is not None and revision is not None:
444
 
            raise errors.CommandError(gettext('You can only supply one of'
 
446
            raise errors.BzrCommandError(gettext('You can only supply one of'
445
447
                                                 ' revision_id or --revision'))
446
448
        if revision_id is None and revision is None:
447
 
            raise errors.CommandError(
 
449
            raise errors.BzrCommandError(
448
450
                gettext('You must supply either --revision or a revision_id'))
449
451
 
450
452
        b = controldir.ControlDir.open_containing_tree_or_branch(directory)[1]
451
453
 
452
454
        revisions = getattr(b.repository, "revisions", None)
453
455
        if revisions is None:
454
 
            raise errors.CommandError(
 
456
            raise errors.BzrCommandError(
455
457
                gettext('Repository %r does not support '
456
458
                        'access to raw revision texts') % b.repository)
457
459
 
465
467
                    msg = gettext(
466
468
                        "The repository {0} contains no revision {1}.").format(
467
469
                            b.repository.base, revision_id.decode('utf-8'))
468
 
                    raise errors.CommandError(msg)
 
470
                    raise errors.BzrCommandError(msg)
469
471
            elif revision is not None:
470
472
                for rev in revision:
471
473
                    if rev is None:
472
 
                        raise errors.CommandError(
 
474
                        raise errors.BzrCommandError(
473
475
                            gettext('You cannot specify a NULL revision.'))
474
476
                    rev_id = rev.as_revision_id(b)
475
477
                    self.print_revision(revisions, rev_id)
501
503
            try:
502
504
                working = d.open_workingtree()
503
505
            except errors.NoWorkingTree:
504
 
                raise errors.CommandError(
 
506
                raise errors.BzrCommandError(
505
507
                    gettext("No working tree to remove"))
506
508
            except errors.NotLocalUrl:
507
 
                raise errors.CommandError(
 
509
                raise errors.BzrCommandError(
508
510
                    gettext("You cannot remove the working tree"
509
511
                            " of a remote path"))
510
512
            if not force:
514
516
                    raise errors.ShelvedChanges(working)
515
517
 
516
518
            if working.user_url != working.branch.user_url:
517
 
                raise errors.CommandError(
 
519
                raise errors.BzrCommandError(
518
520
                    gettext("You cannot remove the working tree"
519
521
                            " from a lightweight checkout"))
520
522
 
555
557
                pass  # There seems to be a real error here, so we'll reset
556
558
            else:
557
559
                # Refuse
558
 
                raise errors.CommandError(gettext(
 
560
                raise errors.BzrCommandError(gettext(
559
561
                    'The tree does not appear to be corrupt. You probably'
560
562
                    ' want "brz revert" instead. Use "--force" if you are'
561
563
                    ' sure you want to reset the working tree.'))
571
573
                                '-r -1 to set the state to the last commit')
572
574
            else:
573
575
                extra = ''
574
 
            raise errors.CommandError(
 
576
            raise errors.BzrCommandError(
575
577
                gettext('failed to reset the tree state{0}').format(extra))
576
578
 
577
579
 
591
593
    @display_command
592
594
    def run(self, tree=False, location=u'.', revision=None):
593
595
        if revision is not None and tree:
594
 
            raise errors.CommandError(
 
596
            raise errors.BzrCommandError(
595
597
                gettext("--tree and --revision can not be used together"))
596
598
 
597
599
        if tree:
607
609
            self.enter_context(b.lock_read())
608
610
            if revision:
609
611
                if len(revision) != 1:
610
 
                    raise errors.CommandError(gettext(
 
612
                    raise errors.BzrCommandError(gettext(
611
613
                        "Revision numbers only make sense for single "
612
614
                        "revisions, not ranges"))
613
615
                revid = revision[0].as_revision_id(b)
871
873
    def run(self, revision=None, show_ids=False, kind=None, include_root=False,
872
874
            file_list=None):
873
875
        if kind and kind not in ['file', 'directory', 'symlink']:
874
 
            raise errors.CommandError(
 
876
            raise errors.BzrCommandError(
875
877
                gettext('invalid kind %r specified') % (kind,))
876
878
 
877
879
        revision = _get_one_revision('inventory', revision)
934
936
        if names_list is None:
935
937
            names_list = []
936
938
        if len(names_list) < 2:
937
 
            raise errors.CommandError(gettext("missing file argument"))
 
939
            raise errors.BzrCommandError(gettext("missing file argument"))
938
940
        tree, rel_names = WorkingTree.open_containing_paths(
939
941
            names_list, canonicalize=False)
940
942
        for file_name in rel_names[0:-1]:
941
943
            if file_name == '':
942
 
                raise errors.CommandError(
 
944
                raise errors.BzrCommandError(
943
945
                    gettext("can not copy root of branch"))
944
946
        self.enter_context(tree.lock_tree_write())
945
947
        into_existing = osutils.isdir(names_list[-1])
947
949
            try:
948
950
                (src, dst) = rel_names
949
951
            except IndexError:
950
 
                raise errors.CommandError(
 
952
                raise errors.BzrCommandError(
951
953
                    gettext('to copy multiple files the'
952
954
                            ' destination must be a versioned'
953
955
                            ' directory'))
961
963
            try:
962
964
                src_kind = tree.stored_kind(src)
963
965
            except errors.NoSuchFile:
964
 
                raise errors.CommandError(
 
966
                raise errors.BzrCommandError(
965
967
                    gettext('Could not copy %s => %s: %s is not versioned.')
966
968
                    % (src, dst, src))
967
969
            if src_kind is None:
968
 
                raise errors.CommandError(
 
970
                raise errors.BzrCommandError(
969
971
                    gettext('Could not copy %s => %s . %s is not versioned\\.'
970
972
                            % (src, dst, src)))
971
973
            if src_kind == 'directory':
972
 
                raise errors.CommandError(
 
974
                raise errors.BzrCommandError(
973
975
                    gettext('Could not copy %s => %s . %s is a directory.'
974
976
                            % (src, dst, src)))
975
977
            dst_parent = osutils.split(dst)[0]
977
979
                try:
978
980
                    dst_parent_kind = tree.stored_kind(dst_parent)
979
981
                except errors.NoSuchFile:
980
 
                    raise errors.CommandError(
 
982
                    raise errors.BzrCommandError(
981
983
                        gettext('Could not copy %s => %s: %s is not versioned.')
982
984
                        % (src, dst, dst_parent))
983
985
                if dst_parent_kind != 'directory':
984
 
                    raise errors.CommandError(
 
986
                    raise errors.BzrCommandError(
985
987
                        gettext('Could not copy to %s: %s is not a directory.')
986
988
                        % (dst_parent, dst_parent))
987
989
 
1023
1025
        if auto:
1024
1026
            return self.run_auto(names_list, after, dry_run)
1025
1027
        elif dry_run:
1026
 
            raise errors.CommandError(gettext('--dry-run requires --auto.'))
 
1028
            raise errors.BzrCommandError(gettext('--dry-run requires --auto.'))
1027
1029
        if names_list is None:
1028
1030
            names_list = []
1029
1031
        if len(names_list) < 2:
1030
 
            raise errors.CommandError(gettext("missing file argument"))
 
1032
            raise errors.BzrCommandError(gettext("missing file argument"))
1031
1033
        tree, rel_names = WorkingTree.open_containing_paths(
1032
1034
            names_list, canonicalize=False)
1033
1035
        for file_name in rel_names[0:-1]:
1034
1036
            if file_name == '':
1035
 
                raise errors.CommandError(
 
1037
                raise errors.BzrCommandError(
1036
1038
                    gettext("can not move root of branch"))
1037
1039
        self.enter_context(tree.lock_tree_write())
1038
1040
        self._run(tree, names_list, rel_names, after)
1039
1041
 
1040
1042
    def run_auto(self, names_list, after, dry_run):
1041
1043
        if names_list is not None and len(names_list) > 1:
1042
 
            raise errors.CommandError(
 
1044
            raise errors.BzrCommandError(
1043
1045
                gettext('Only one path may be specified to --auto.'))
1044
1046
        if after:
1045
 
            raise errors.CommandError(
 
1047
            raise errors.BzrCommandError(
1046
1048
                gettext('--after cannot be specified with --auto.'))
1047
1049
        work_tree, file_list = WorkingTree.open_containing_paths(
1048
1050
            names_list, default_directory='.')
1079
1081
                    self.outf.write("%s => %s\n" % (src, dest))
1080
1082
        else:
1081
1083
            if len(names_list) != 2:
1082
 
                raise errors.CommandError(gettext('to mv multiple files the'
 
1084
                raise errors.BzrCommandError(gettext('to mv multiple files the'
1083
1085
                                                     ' destination must be a versioned'
1084
1086
                                                     ' directory'))
1085
1087
 
1222
1224
        stored_loc = branch_to.get_parent()
1223
1225
        if location is None:
1224
1226
            if stored_loc is None:
1225
 
                raise errors.CommandError(gettext("No pull location known or"
 
1227
                raise errors.BzrCommandError(gettext("No pull location known or"
1226
1228
                                                     " specified."))
1227
1229
            else:
1228
1230
                display_url = urlutils.unescape_for_display(stored_loc,
1235
1237
        revision = _get_one_revision('pull', revision)
1236
1238
        if mergeable is not None:
1237
1239
            if revision is not None:
1238
 
                raise errors.CommandError(gettext(
 
1240
                raise errors.BzrCommandError(gettext(
1239
1241
                    'Cannot use -r with merge directives or bundles'))
1240
1242
            mergeable.install_revisions(branch_to.repository)
1241
1243
            base_revision_id, revision_id, verified = \
1390
1392
                    # error by the feedback given to them. RBC 20080227.
1391
1393
                    stacked_on = parent_url
1392
1394
            if not stacked_on:
1393
 
                raise errors.CommandError(gettext(
 
1395
                raise errors.BzrCommandError(gettext(
1394
1396
                    "Could not determine branch to refer to."))
1395
1397
 
1396
1398
        # Get the destination location
1399
1401
            if stored_loc is None:
1400
1402
                parent_loc = br_from.get_parent()
1401
1403
                if parent_loc:
1402
 
                    raise errors.CommandError(gettext(
 
1404
                    raise errors.BzrCommandError(gettext(
1403
1405
                        "No push location known or specified. To push to the "
1404
1406
                        "parent branch (at %s), use 'brz push :parent'." %
1405
1407
                        urlutils.unescape_for_display(parent_loc,
1406
1408
                                                      self.outf.encoding)))
1407
1409
                else:
1408
 
                    raise errors.CommandError(gettext(
 
1410
                    raise errors.BzrCommandError(gettext(
1409
1411
                        "No push location known or specified."))
1410
1412
            else:
1411
1413
                display_url = urlutils.unescape_for_display(stored_loc,
1434
1436
    parameter, as in "branch foo/bar -r 5".
1435
1437
    """
1436
1438
 
1437
 
    aliase = ['sprout']
1438
1439
    _see_also = ['checkout']
1439
1440
    takes_args = ['from_location', 'to_location?']
1440
1441
    takes_options = ['revision',
1462
1463
                            help="Bind new branch to from location."),
1463
1464
                     Option('no-recurse-nested',
1464
1465
                            help='Do not recursively check out nested trees.'),
1465
 
                     Option('colocated-branch', short_name='b',
1466
 
                            type=str, help='Name of colocated branch to sprout.'),
1467
1466
                     ]
1468
1467
 
1469
1468
    def run(self, from_location, to_location=None, revision=None,
1470
1469
            hardlink=False, stacked=False, standalone=False, no_tree=False,
1471
1470
            use_existing_dir=False, switch=False, bind=False,
1472
 
            files_from=None, no_recurse_nested=False, colocated_branch=None):
 
1471
            files_from=None, no_recurse_nested=False):
1473
1472
        from breezy import switch as _mod_switch
1474
1473
        accelerator_tree, br_from = controldir.ControlDir.open_tree_or_branch(
1475
 
            from_location, name=colocated_branch)
 
1474
            from_location)
1476
1475
        if no_recurse_nested:
1477
1476
            recurse = 'none'
1478
1477
        else:
1504
1503
                    to_transport)
1505
1504
            except errors.NotBranchError:
1506
1505
                if not use_existing_dir:
1507
 
                    raise errors.CommandError(gettext('Target directory "%s" '
 
1506
                    raise errors.BzrCommandError(gettext('Target directory "%s" '
1508
1507
                                                         'already exists.') % to_location)
1509
1508
                else:
1510
1509
                    to_dir = None
1516
1515
                else:
1517
1516
                    raise errors.AlreadyBranchError(to_location)
1518
1517
        except errors.NoSuchFile:
1519
 
            raise errors.CommandError(gettext('Parent of "%s" does not exist.')
 
1518
            raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
1520
1519
                                         % to_location)
1521
1520
        else:
1522
1521
            to_dir = None
1537
1536
                to_transport.delete_tree('.')
1538
1537
                msg = gettext("The branch {0} has no revision {1}.").format(
1539
1538
                    from_location, revision)
1540
 
                raise errors.CommandError(msg)
 
1539
                raise errors.BzrCommandError(msg)
1541
1540
        else:
1542
1541
            try:
1543
1542
                to_repo = to_dir.open_repository()
1593
1592
        if recursive:
1594
1593
            t = transport.get_transport(location, purpose='read')
1595
1594
            if not t.listable():
1596
 
                raise errors.CommandError(
 
1595
                raise errors.BzrCommandError(
1597
1596
                    "Can't scan this type of location.")
1598
1597
            for b in controldir.ControlDir.find_branches(t):
1599
1598
                self.outf.write("%s\n" % urlutils.unescape_for_display(
1698
1697
                               accelerator_tree, hardlink)
1699
1698
 
1700
1699
 
1701
 
class cmd_clone(Command):
1702
 
    __doc__ = """Clone a control directory.
1703
 
    """
1704
 
 
1705
 
    takes_args = ['from_location', 'to_location?']
1706
 
    takes_options = ['revision',
1707
 
                     Option('no-recurse-nested',
1708
 
                            help='Do not recursively check out nested trees.'),
1709
 
                     ]
1710
 
 
1711
 
    def run(self, from_location, to_location=None, revision=None, no_recurse_nested=False):
1712
 
        accelerator_tree, br_from = controldir.ControlDir.open_tree_or_branch(
1713
 
            from_location)
1714
 
        if no_recurse_nested:
1715
 
            recurse = 'none'
1716
 
        else:
1717
 
            recurse = 'down'
1718
 
        revision = _get_one_revision('branch', revision)
1719
 
        self.enter_context(br_from.lock_read())
1720
 
        if revision is not None:
1721
 
            revision_id = revision.as_revision_id(br_from)
1722
 
        else:
1723
 
            # FIXME - wt.last_revision, fallback to branch, fall back to
1724
 
            # None or perhaps NULL_REVISION to mean copy nothing
1725
 
            # RBC 20060209
1726
 
            revision_id = br_from.last_revision()
1727
 
        if to_location is None:
1728
 
            to_location = urlutils.derive_to_location(from_location)
1729
 
        target_controldir = br_from.controldir.clone(to_location, revision_id=revision_id)
1730
 
        note(gettext('Created new control directory.'))
1731
 
 
1732
 
 
1733
1700
class cmd_renames(Command):
1734
1701
    __doc__ = """Show list of renamed files.
1735
1702
    """
1798
1765
 
1799
1766
    def run(self, dir=None, revision=None, show_base=None):
1800
1767
        if revision is not None and len(revision) != 1:
1801
 
            raise errors.CommandError(gettext(
 
1768
            raise errors.BzrCommandError(gettext(
1802
1769
                "brz update --revision takes exactly one revision"))
1803
1770
        if dir is None:
1804
1771
            tree = WorkingTree.open_containing('.')[0]
1806
1773
            tree, relpath = WorkingTree.open_containing(dir)
1807
1774
            if relpath:
1808
1775
                # See bug 557886.
1809
 
                raise errors.CommandError(gettext(
 
1776
                raise errors.BzrCommandError(gettext(
1810
1777
                    "brz update can only update a whole tree, "
1811
1778
                    "not a file or subdirectory"))
1812
1779
        branch = tree.branch
1852
1819
                old_tip=old_tip,
1853
1820
                show_base=show_base)
1854
1821
        except errors.NoSuchRevision as e:
1855
 
            raise errors.CommandError(gettext(
 
1822
            raise errors.BzrCommandError(gettext(
1856
1823
                "branch has no revision %s\n"
1857
1824
                "brz update --revision only works"
1858
1825
                " for a revision in the branch history")
1954
1921
                                      specific_files=file_list).added
1955
1922
            file_list = sorted([f.path[1] for f in added], reverse=True)
1956
1923
            if len(file_list) == 0:
1957
 
                raise errors.CommandError(gettext('No matching files.'))
 
1924
                raise errors.BzrCommandError(gettext('No matching files.'))
1958
1925
        elif file_list is None:
1959
1926
            # missing files show up in iter_changes(basis) as
1960
1927
            # versioned-with-no-kind.
2116
2083
            to_transport.ensure_base()
2117
2084
        except errors.NoSuchFile:
2118
2085
            if not create_prefix:
2119
 
                raise errors.CommandError(gettext("Parent directory of %s"
 
2086
                raise errors.BzrCommandError(gettext("Parent directory of %s"
2120
2087
                                                     " does not exist."
2121
2088
                                                     "\nYou may supply --create-prefix to create all"
2122
2089
                                                     " leading parent directories.")
2151
2118
            try:
2152
2119
                branch.set_append_revisions_only(True)
2153
2120
            except errors.UpgradeRequired:
2154
 
                raise errors.CommandError(gettext('This branch format cannot be set'
 
2121
                raise errors.BzrCommandError(gettext('This branch format cannot be set'
2155
2122
                                                     ' to append-revisions-only.  Try --default.'))
2156
2123
        if not is_quiet():
2157
2124
            from .info import describe_layout, describe_format
2395
2362
        elif u':' in prefix:
2396
2363
            old_label, new_label = prefix.split(u":")
2397
2364
        else:
2398
 
            raise errors.CommandError(gettext(
 
2365
            raise errors.BzrCommandError(gettext(
2399
2366
                '--prefix expects two values separated by a colon'
2400
2367
                ' (eg "old/:new/")'))
2401
2368
 
2402
2369
        if revision and len(revision) > 2:
2403
 
            raise errors.CommandError(gettext('brz diff --revision takes exactly'
 
2370
            raise errors.BzrCommandError(gettext('brz diff --revision takes exactly'
2404
2371
                                                 ' one or two revision specifiers'))
2405
2372
 
2406
2373
        if using is not None and format is not None:
2407
 
            raise errors.CommandError(gettext(
 
2374
            raise errors.BzrCommandError(gettext(
2408
2375
                '{0} and {1} are mutually exclusive').format(
2409
2376
                '--using', '--format'))
2410
2377
 
2529
2496
        return int(limitstring)
2530
2497
    except ValueError:
2531
2498
        msg = gettext("The limit argument must be an integer.")
2532
 
        raise errors.CommandError(msg)
 
2499
        raise errors.BzrCommandError(msg)
2533
2500
 
2534
2501
 
2535
2502
def _parse_levels(s):
2537
2504
        return int(s)
2538
2505
    except ValueError:
2539
2506
        msg = gettext("The levels argument must be an integer.")
2540
 
        raise errors.CommandError(msg)
 
2507
        raise errors.BzrCommandError(msg)
2541
2508
 
2542
2509
 
2543
2510
class cmd_log(Command):
2804
2771
            include_merged = False
2805
2772
        if (exclude_common_ancestry
2806
2773
                and (revision is None or len(revision) != 2)):
2807
 
            raise errors.CommandError(gettext(
 
2774
            raise errors.BzrCommandError(gettext(
2808
2775
                '--exclude-common-ancestry requires -r with two revisions'))
2809
2776
        if include_merged:
2810
2777
            if levels is None:
2811
2778
                levels = 0
2812
2779
            else:
2813
 
                raise errors.CommandError(gettext(
 
2780
                raise errors.BzrCommandError(gettext(
2814
2781
                    '{0} and {1} are mutually exclusive').format(
2815
2782
                    '--levels', '--include-merged'))
2816
2783
 
2818
2785
            if len(change) > 1:
2819
2786
                raise errors.RangeInChangeOption()
2820
2787
            if revision is not None:
2821
 
                raise errors.CommandError(gettext(
 
2788
                raise errors.BzrCommandError(gettext(
2822
2789
                    '{0} and {1} are mutually exclusive').format(
2823
2790
                    '--revision', '--change'))
2824
2791
            else:
2825
2792
                revision = change
2826
2793
 
2827
 
        files = []
 
2794
        file_ids = []
2828
2795
        filter_by_dir = False
2829
2796
        if file_list:
2830
2797
            # find the file ids to log and check for directory filtering
2831
2798
            b, file_info_list, rev1, rev2 = _get_info_for_log_files(
2832
2799
                revision, file_list, self._exit_stack)
2833
 
            for relpath, kind in file_info_list:
2834
 
                if not kind:
2835
 
                    raise errors.CommandError(gettext(
 
2800
            for relpath, file_id, kind in file_info_list:
 
2801
                if file_id is None:
 
2802
                    raise errors.BzrCommandError(gettext(
2836
2803
                        "Path unknown at end or start of revision range: %s") %
2837
2804
                        relpath)
2838
2805
                # If the relpath is the top of the tree, we log everything
2839
2806
                if relpath == '':
2840
 
                    files = []
 
2807
                    file_ids = []
2841
2808
                    break
2842
2809
                else:
2843
 
                    files.append(relpath)
 
2810
                    file_ids.append(file_id)
2844
2811
                filter_by_dir = filter_by_dir or (
2845
2812
                    kind in ['directory', 'tree-reference'])
2846
2813
        else:
2871
2838
            delta_type = 'full'
2872
2839
        if not show_diff:
2873
2840
            diff_type = None
2874
 
        elif files:
 
2841
        elif file_ids:
2875
2842
            diff_type = 'partial'
2876
2843
        else:
2877
2844
            diff_type = 'full'
2903
2870
        # original algorithm - per-file-graph - for the "single
2904
2871
        # file that isn't a directory without showing a delta" case.
2905
2872
        partial_history = revision and b.repository._format.supports_chks
2906
 
        match_using_deltas = (len(files) != 1 or filter_by_dir
 
2873
        match_using_deltas = (len(file_ids) != 1 or filter_by_dir
2907
2874
                              or delta_type or partial_history)
2908
2875
 
2909
2876
        match_dict = {}
2919
2886
            match_dict['bugs'] = match_bugs
2920
2887
 
2921
2888
        # Build the LogRequest and execute it
2922
 
        if len(files) == 0:
2923
 
            files = None
 
2889
        if len(file_ids) == 0:
 
2890
            file_ids = None
2924
2891
        rqst = make_log_request_dict(
2925
 
            direction=direction, specific_files=files,
 
2892
            direction=direction, specific_fileids=file_ids,
2926
2893
            start_revision=rev1, end_revision=rev2, limit=limit,
2927
2894
            message_search=message, delta_type=delta_type,
2928
2895
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
2950
2917
            # b is taken from revision[0].get_branch(), and
2951
2918
            # show_log will use its revision_history. Having
2952
2919
            # different branches will lead to weird behaviors.
2953
 
            raise errors.CommandError(gettext(
 
2920
            raise errors.BzrCommandError(gettext(
2954
2921
                "brz %s doesn't accept two revisions in different"
2955
2922
                " branches.") % command_name)
2956
2923
        if start_spec.spec is None:
2966
2933
        else:
2967
2934
            rev2 = end_spec.in_history(branch)
2968
2935
    else:
2969
 
        raise errors.CommandError(gettext(
 
2936
        raise errors.BzrCommandError(gettext(
2970
2937
            'brz %s --revision takes one or two values.') % command_name)
2971
2938
    return rev1, rev2
2972
2939
 
3046
3013
            null=False, kind=None, show_ids=False, path=None, directory=None):
3047
3014
 
3048
3015
        if kind and kind not in ('file', 'directory', 'symlink', 'tree-reference'):
3049
 
            raise errors.CommandError(gettext('invalid kind specified'))
 
3016
            raise errors.BzrCommandError(gettext('invalid kind specified'))
3050
3017
 
3051
3018
        if verbose and null:
3052
 
            raise errors.CommandError(
 
3019
            raise errors.BzrCommandError(
3053
3020
                gettext('Cannot set both --verbose and --null'))
3054
3021
        all = not (unknown or versioned or ignored)
3055
3022
 
3059
3026
            fs_path = '.'
3060
3027
        else:
3061
3028
            if from_root:
3062
 
                raise errors.CommandError(gettext('cannot specify both --from-root'
 
3029
                raise errors.BzrCommandError(gettext('cannot specify both --from-root'
3063
3030
                                                     ' and PATH'))
3064
3031
            fs_path = path
3065
3032
        tree, branch, relpath = \
3236
3203
                self.outf.write("%s\n" % pattern)
3237
3204
            return
3238
3205
        if not name_pattern_list:
3239
 
            raise errors.CommandError(gettext("ignore requires at least one "
 
3206
            raise errors.BzrCommandError(gettext("ignore requires at least one "
3240
3207
                                                 "NAME_PATTERN or --default-rules."))
3241
3208
        name_pattern_list = [globbing.normalize_pattern(p)
3242
3209
                             for p in name_pattern_list]
3255
3222
        for name_pattern in name_pattern_list:
3256
3223
            if (name_pattern[0] == '/' or
3257
3224
                    (len(name_pattern) > 1 and name_pattern[1] == ':')):
3258
 
                raise errors.CommandError(gettext(
 
3225
                raise errors.BzrCommandError(gettext(
3259
3226
                    "NAME_PATTERN should not be an absolute path"))
3260
3227
        tree, relpath = WorkingTree.open_containing(directory)
3261
3228
        ignores.tree_ignores_add_patterns(tree, name_pattern_list)
3316
3283
        try:
3317
3284
            revno = int(revno)
3318
3285
        except ValueError:
3319
 
            raise errors.CommandError(gettext("not a valid revision-number: %r")
 
3286
            raise errors.BzrCommandError(gettext("not a valid revision-number: %r")
3320
3287
                                         % revno)
3321
3288
        revid = WorkingTree.open_containing(
3322
3289
            directory)[0].branch.get_rev_id(revno)
3387
3354
 
3388
3355
        if uncommitted:
3389
3356
            if tree is None:
3390
 
                raise errors.CommandError(
 
3357
                raise errors.BzrCommandError(
3391
3358
                    gettext("--uncommitted requires a working tree"))
3392
3359
            export_tree = tree
3393
3360
        else:
3415
3382
            export(export_tree, dest, format, root, subdir,
3416
3383
                   per_file_timestamps=per_file_timestamps)
3417
3384
        except errors.NoSuchExportFormat as e:
3418
 
            raise errors.CommandError(
 
3385
            raise errors.BzrCommandError(
3419
3386
                gettext('Unsupported export format: %s') % e.format)
3420
3387
 
3421
3388
 
3443
3410
    def run(self, filename, revision=None, name_from_revision=False,
3444
3411
            filters=False, directory=None):
3445
3412
        if revision is not None and len(revision) != 1:
3446
 
            raise errors.CommandError(gettext("brz cat --revision takes exactly"
 
3413
            raise errors.BzrCommandError(gettext("brz cat --revision takes exactly"
3447
3414
                                                 " one revision specifier"))
3448
3415
        tree, branch, relpath = \
3449
3416
            _open_directory_or_containing_tree_or_branch(filename, directory)
3462
3429
        if name_from_revision:
3463
3430
            # Try in revision if requested
3464
3431
            if not rev_tree.is_versioned(relpath):
3465
 
                raise errors.CommandError(gettext(
 
3432
                raise errors.BzrCommandError(gettext(
3466
3433
                    "{0!r} is not present in revision {1}").format(
3467
3434
                        filename, rev_tree.get_revision_id()))
3468
3435
            rev_tree_path = relpath
3476
3443
            if rev_tree_path is None:
3477
3444
                # Path didn't exist in working tree
3478
3445
                if not rev_tree.is_versioned(relpath):
3479
 
                    raise errors.CommandError(gettext(
 
3446
                    raise errors.BzrCommandError(gettext(
3480
3447
                        "{0!r} is not present in revision {1}").format(
3481
3448
                            filename, rev_tree.get_revision_id()))
3482
3449
                else:
3619
3586
                    default_bugtracker = branch_config.get(
3620
3587
                        "bugtracker")
3621
3588
                if default_bugtracker is None:
3622
 
                    raise errors.CommandError(gettext(
 
3589
                    raise errors.BzrCommandError(gettext(
3623
3590
                        "No tracker specified for bug %s. Use the form "
3624
3591
                        "'tracker:id' or specify a default bug tracker "
3625
3592
                        "using the `bugtracker` option.\nSee "
3628
3595
                tag = default_bugtracker
3629
3596
                bug_id = tokens[0]
3630
3597
            elif len(tokens) != 2:
3631
 
                raise errors.CommandError(gettext(
 
3598
                raise errors.BzrCommandError(gettext(
3632
3599
                    "Invalid bug %s. Must be in the form of 'tracker:id'. "
3633
3600
                    "See \"brz help bugs\" for more information on this "
3634
3601
                    "feature.\nCommit refused.") % bug)
3637
3604
            try:
3638
3605
                yield bugtracker.get_bug_url(tag, branch, bug_id), status
3639
3606
            except bugtracker.UnknownBugTrackerAbbreviation:
3640
 
                raise errors.CommandError(gettext(
 
3607
                raise errors.BzrCommandError(gettext(
3641
3608
                    'Unrecognized bug %s. Commit refused.') % bug)
3642
3609
            except bugtracker.MalformedBugIdentifier as e:
3643
 
                raise errors.CommandError(gettext(
 
3610
                raise errors.BzrCommandError(gettext(
3644
3611
                    u"%s\nCommit refused.") % (e,))
3645
3612
 
3646
3613
    def run(self, message=None, file=None, verbose=False, selected_list=None,
3667
3634
            try:
3668
3635
                commit_stamp, offset = timestamp.parse_patch_date(commit_time)
3669
3636
            except ValueError as e:
3670
 
                raise errors.CommandError(gettext(
 
3637
                raise errors.BzrCommandError(gettext(
3671
3638
                    "Could not parse --commit-time: " + str(e)))
3672
3639
 
3673
3640
        properties = {}
3711
3678
                message = message.replace('\r\n', '\n')
3712
3679
                message = message.replace('\r', '\n')
3713
3680
            if file:
3714
 
                raise errors.CommandError(gettext(
 
3681
                raise errors.BzrCommandError(gettext(
3715
3682
                    "please specify either --message or --file"))
3716
3683
 
3717
3684
        def get_message(commit_obj):
3742
3709
                    my_message = edit_commit_message_encoded(text,
3743
3710
                                                             start_message=start_message)
3744
3711
                if my_message is None:
3745
 
                    raise errors.CommandError(gettext("please specify a commit"
 
3712
                    raise errors.BzrCommandError(gettext("please specify a commit"
3746
3713
                                                         " message with either --message or --file"))
3747
3714
                if my_message == "":
3748
 
                    raise errors.CommandError(gettext("Empty commit message specified."
 
3715
                    raise errors.BzrCommandError(gettext("Empty commit message specified."
3749
3716
                                                         " Please specify a commit message with either"
3750
3717
                                                         " --message or --file or leave a blank message"
3751
3718
                                                         " with --message \"\"."))
3765
3732
                        exclude=tree.safe_relpath_files(exclude),
3766
3733
                        lossy=lossy)
3767
3734
        except PointlessCommit:
3768
 
            raise errors.CommandError(gettext("No changes to commit."
 
3735
            raise errors.BzrCommandError(gettext("No changes to commit."
3769
3736
                                                 " Please 'brz add' the files you want to commit, or use"
3770
3737
                                                 " --unchanged to force an empty commit."))
3771
3738
        except ConflictsInTree:
3772
 
            raise errors.CommandError(gettext('Conflicts detected in working '
 
3739
            raise errors.BzrCommandError(gettext('Conflicts detected in working '
3773
3740
                                                 'tree.  Use "brz conflicts" to list, "brz resolve FILE" to'
3774
3741
                                                 ' resolve.'))
3775
3742
        except StrictCommitFailed:
3776
 
            raise errors.CommandError(gettext("Commit refused because there are"
 
3743
            raise errors.BzrCommandError(gettext("Commit refused because there are"
3777
3744
                                                 " unknown files in the working tree."))
3778
3745
        except errors.BoundBranchOutOfDate as e:
3779
3746
            e.extra_help = (gettext("\n"
3955
3922
            return
3956
3923
 
3957
3924
        if email:
3958
 
            raise errors.CommandError(gettext("--email can only be used to display existing "
 
3925
            raise errors.BzrCommandError(gettext("--email can only be used to display existing "
3959
3926
                                                 "identity"))
3960
3927
 
3961
3928
        # display a warning if an email address isn't included in the given name.
4045
4012
 
4046
4013
    def remove_alias(self, alias_name):
4047
4014
        if alias_name is None:
4048
 
            raise errors.CommandError(gettext(
 
4015
            raise errors.BzrCommandError(gettext(
4049
4016
                'brz alias --remove expects an alias to remove.'))
4050
4017
        # If alias is not found, print something like:
4051
4018
        # unalias: foo: not found
4140
4107
            return test_server.FakeNFSServer
4141
4108
        msg = "No known transport type %s. Supported types are: sftp\n" %\
4142
4109
            (typestring)
4143
 
        raise errors.CommandError(msg)
 
4110
        raise errors.BzrCommandError(msg)
4144
4111
 
4145
4112
    hidden = True
4146
4113
    takes_args = ['testspecs*']
4224
4191
 
4225
4192
        try:
4226
4193
            from . import tests
4227
 
        except ImportError as e:
4228
 
            raise errors.CommandError("tests not available. Install the "
 
4194
        except ImportError:
 
4195
            raise errors.BzrCommandError("tests not available. Install the "
4229
4196
                                         "breezy tests to run the breezy testsuite.")
4230
4197
 
4231
4198
        if testspecs_list is not None:
4236
4203
            try:
4237
4204
                from .tests import SubUnitBzrRunnerv1
4238
4205
            except ImportError:
4239
 
                raise errors.CommandError(gettext(
 
4206
                raise errors.BzrCommandError(gettext(
4240
4207
                    "subunit not available. subunit needs to be installed "
4241
4208
                    "to use --subunit."))
4242
4209
            self.additional_selftest_args['runner_class'] = SubUnitBzrRunnerv1
4253
4220
            try:
4254
4221
                from .tests import SubUnitBzrRunnerv2
4255
4222
            except ImportError:
4256
 
                raise errors.CommandError(gettext(
 
4223
                raise errors.BzrCommandError(gettext(
4257
4224
                    "subunit not available. subunit "
4258
4225
                    "needs to be installed to use --subunit2."))
4259
4226
            self.additional_selftest_args['runner_class'] = SubUnitBzrRunnerv2
4262
4229
            self.additional_selftest_args.setdefault(
4263
4230
                'suite_decorators', []).append(parallel)
4264
4231
        if benchmark:
4265
 
            raise errors.CommandError(gettext(
 
4232
            raise errors.BzrCommandError(gettext(
4266
4233
                "--benchmark is no longer supported from brz 2.2; "
4267
4234
                "use bzr-usertest instead"))
4268
4235
        test_suite_factory = None
4490
4457
 
4491
4458
        tree = WorkingTree.open_containing(directory)[0]
4492
4459
        if tree.branch.last_revision() == _mod_revision.NULL_REVISION:
4493
 
            raise errors.CommandError(gettext('Merging into empty branches not currently supported, '
 
4460
            raise errors.BzrCommandError(gettext('Merging into empty branches not currently supported, '
4494
4461
                                                 'https://bugs.launchpad.net/bzr/+bug/308562'))
4495
4462
 
4496
4463
        # die as quickly as possible if there are uncommitted changes
4512
4479
                mergeable = None
4513
4480
            else:
4514
4481
                if uncommitted:
4515
 
                    raise errors.CommandError(gettext('Cannot use --uncommitted'
 
4482
                    raise errors.BzrCommandError(gettext('Cannot use --uncommitted'
4516
4483
                                                         ' with bundles or merge directives.'))
4517
4484
 
4518
4485
                if revision is not None:
4519
 
                    raise errors.CommandError(gettext(
 
4486
                    raise errors.BzrCommandError(gettext(
4520
4487
                        'Cannot use -r with merge directives or bundles'))
4521
4488
                merger, verified = _mod_merge.Merger.from_mergeable(tree,
4522
4489
                                                                    mergeable)
4523
4490
 
4524
4491
        if merger is None and uncommitted:
4525
4492
            if revision is not None and len(revision) > 0:
4526
 
                raise errors.CommandError(gettext('Cannot use --uncommitted and'
 
4493
                raise errors.BzrCommandError(gettext('Cannot use --uncommitted and'
4527
4494
                                                     ' --revision at the same time.'))
4528
4495
            merger = self.get_merger_from_uncommitted(tree, location, None)
4529
4496
            allow_pending = False
4549
4516
            return 0
4550
4517
        if pull and not preview:
4551
4518
            if merger.interesting_files is not None:
4552
 
                raise errors.CommandError(
 
4519
                raise errors.BzrCommandError(
4553
4520
                    gettext('Cannot pull individual files'))
4554
4521
            if (merger.base_rev_id == tree.last_revision()):
4555
4522
                result = tree.pull(merger.other_branch, False,
4557
4524
                result.report(self.outf)
4558
4525
                return 0
4559
4526
        if merger.this_basis is None:
4560
 
            raise errors.CommandError(gettext(
 
4527
            raise errors.BzrCommandError(gettext(
4561
4528
                "This branch has no commits."
4562
4529
                " (perhaps you would prefer 'brz pull')"))
4563
4530
        if preview:
4616
4583
    def sanity_check_merger(self, merger):
4617
4584
        if (merger.show_base and
4618
4585
                merger.merge_type is not _mod_merge.Merge3Merger):
4619
 
            raise errors.CommandError(gettext("Show-base is not supported for this"
 
4586
            raise errors.BzrCommandError(gettext("Show-base is not supported for this"
4620
4587
                                                 " merge type. %s") % merger.merge_type)
4621
4588
        if merger.reprocess is None:
4622
4589
            if merger.show_base:
4625
4592
                # Use reprocess if the merger supports it
4626
4593
                merger.reprocess = merger.merge_type.supports_reprocess
4627
4594
        if merger.reprocess and not merger.merge_type.supports_reprocess:
4628
 
            raise errors.CommandError(gettext("Conflict reduction is not supported"
 
4595
            raise errors.BzrCommandError(gettext("Conflict reduction is not supported"
4629
4596
                                                 " for merge type %s.") %
4630
4597
                                         merger.merge_type)
4631
4598
        if merger.reprocess and merger.show_base:
4632
 
            raise errors.CommandError(gettext("Cannot do conflict reduction and"
 
4599
            raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4633
4600
                                                 " show base."))
4634
4601
 
4635
4602
        if (merger.merge_type.requires_file_merge_plan and
4637
4604
             not getattr(merger.other_tree, 'plan_file_merge', None) or
4638
4605
             (merger.base_tree is not None and
4639
4606
                 not getattr(merger.base_tree, 'plan_file_merge', None)))):
4640
 
            raise errors.CommandError(
 
4607
            raise errors.BzrCommandError(
4641
4608
                gettext('Plan file merge unsupported: '
4642
4609
                        'Merge type incompatible with tree formats.'))
4643
4610
 
4748
4715
            stored_location_type = "parent"
4749
4716
        mutter("%s", stored_location)
4750
4717
        if stored_location is None:
4751
 
            raise errors.CommandError(
 
4718
            raise errors.BzrCommandError(
4752
4719
                gettext("No location specified or remembered"))
4753
4720
        display_url = urlutils.unescape_for_display(stored_location, 'utf-8')
4754
4721
        note(gettext("{0} remembered {1} location {2}").format(verb_string,
4795
4762
        self.enter_context(tree.lock_write())
4796
4763
        parents = tree.get_parent_ids()
4797
4764
        if len(parents) != 2:
4798
 
            raise errors.CommandError(
 
4765
            raise errors.BzrCommandError(
4799
4766
                gettext("Sorry, remerge only works after normal"
4800
4767
                        " merges.  Not cherrypicking or multi-merges."))
4801
4768
        interesting_files = None
5070
5037
        if other_branch is None:
5071
5038
            other_branch = parent
5072
5039
            if other_branch is None:
5073
 
                raise errors.CommandError(gettext("No peer location known"
 
5040
                raise errors.BzrCommandError(gettext("No peer location known"
5074
5041
                                                     " or specified."))
5075
5042
            display_url = urlutils.unescape_for_display(parent,
5076
5043
                                                        self.outf.encoding)
5318
5285
 
5319
5286
    def run(self, revision_id_list=None, revision=None, directory=u'.'):
5320
5287
        if revision_id_list is not None and revision is not None:
5321
 
            raise errors.CommandError(
 
5288
            raise errors.BzrCommandError(
5322
5289
                gettext('You can only supply one of revision_id or --revision'))
5323
5290
        if revision_id_list is None and revision is None:
5324
 
            raise errors.CommandError(
 
5291
            raise errors.BzrCommandError(
5325
5292
                gettext('You must supply either --revision or a revision_id'))
5326
5293
        b = WorkingTree.open_containing(directory)[0].branch
5327
5294
        self.enter_context(b.lock_write())
5349
5316
                if to_revid is None:
5350
5317
                    to_revno = b.revno()
5351
5318
                if from_revno is None or to_revno is None:
5352
 
                    raise errors.CommandError(
 
5319
                    raise errors.BzrCommandError(
5353
5320
                        gettext('Cannot sign a range of non-revision-history revisions'))
5354
5321
                with WriteGroup(b.repository):
5355
5322
                    for revno in range(from_revno, to_revno + 1):
5356
5323
                        b.repository.sign_revision(b.get_rev_id(revno),
5357
5324
                                                   gpg_strategy)
5358
5325
            else:
5359
 
                raise errors.CommandError(
 
5326
                raise errors.BzrCommandError(
5360
5327
                    gettext('Please supply either one revision, or a range.'))
5361
5328
 
5362
5329
 
5382
5349
            try:
5383
5350
                location = b.get_old_bound_location()
5384
5351
            except errors.UpgradeRequired:
5385
 
                raise errors.CommandError(
 
5352
                raise errors.BzrCommandError(
5386
5353
                    gettext('No location supplied.  '
5387
5354
                            'This format does not remember old locations.'))
5388
5355
            else:
5389
5356
                if location is None:
5390
5357
                    if b.get_bound_location() is not None:
5391
 
                        raise errors.CommandError(
 
5358
                        raise errors.BzrCommandError(
5392
5359
                            gettext('Branch is already bound'))
5393
5360
                    else:
5394
 
                        raise errors.CommandError(
 
5361
                        raise errors.BzrCommandError(
5395
5362
                            gettext('No location supplied'
5396
5363
                                    ' and no previous location known'))
5397
5364
        b_other = Branch.open(location)
5398
5365
        try:
5399
5366
            b.bind(b_other)
5400
5367
        except errors.DivergedBranches:
5401
 
            raise errors.CommandError(
 
5368
            raise errors.BzrCommandError(
5402
5369
                gettext('These branches have diverged.'
5403
5370
                        ' Try merging, and then bind again.'))
5404
5371
        if b.get_config().has_explicit_nickname():
5419
5386
    def run(self, directory=u'.'):
5420
5387
        b, relpath = Branch.open_containing(directory)
5421
5388
        if not b.unbind():
5422
 
            raise errors.CommandError(gettext('Local branch is not bound'))
 
5389
            raise errors.BzrCommandError(gettext('Local branch is not bound'))
5423
5390
 
5424
5391
 
5425
5392
class cmd_uncommit(Command):
5678
5645
        containing_tree = WorkingTree.open_containing(parent_dir)[0]
5679
5646
        repo = containing_tree.branch.repository
5680
5647
        if not repo.supports_rich_root():
5681
 
            raise errors.CommandError(gettext(
 
5648
            raise errors.BzrCommandError(gettext(
5682
5649
                "Can't join trees because %s doesn't support rich root data.\n"
5683
5650
                "You can use brz upgrade on the repository.")
5684
5651
                % (repo,))
5688
5655
            except BadReferenceTarget as e:
5689
5656
                # XXX: Would be better to just raise a nicely printable
5690
5657
                # exception from the real origin.  Also below.  mbp 20070306
5691
 
                raise errors.CommandError(
 
5658
                raise errors.BzrCommandError(
5692
5659
                    gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5693
5660
        else:
5694
5661
            try:
5695
5662
                containing_tree.subsume(sub_tree)
5696
5663
            except errors.BadSubsumeSource as e:
5697
 
                raise errors.CommandError(
 
5664
                raise errors.BzrCommandError(
5698
5665
                    gettext("Cannot join {0}.  {1}").format(tree, e.reason))
5699
5666
 
5700
5667
 
5786
5753
        if submit_branch is None:
5787
5754
            submit_branch = branch.get_parent()
5788
5755
        if submit_branch is None:
5789
 
            raise errors.CommandError(
 
5756
            raise errors.BzrCommandError(
5790
5757
                gettext('No submit branch specified or known'))
5791
5758
 
5792
5759
        stored_public_branch = branch.get_public_branch()
5796
5763
            # FIXME: Should be done only if we succeed ? -- vila 2012-01-03
5797
5764
            branch.set_public_branch(public_branch)
5798
5765
        if not include_bundle and public_branch is None:
5799
 
            raise errors.CommandError(
 
5766
            raise errors.BzrCommandError(
5800
5767
                gettext('No public branch specified or known'))
5801
5768
        base_revision_id = None
5802
5769
        if revision is not None:
5803
5770
            if len(revision) > 2:
5804
 
                raise errors.CommandError(
 
5771
                raise errors.BzrCommandError(
5805
5772
                    gettext('brz merge-directive takes '
5806
5773
                            'at most two one revision identifiers'))
5807
5774
            revision_id = revision[-1].as_revision_id(branch)
5811
5778
            revision_id = branch.last_revision()
5812
5779
        revision_id = ensure_null(revision_id)
5813
5780
        if revision_id == NULL_REVISION:
5814
 
            raise errors.CommandError(gettext('No revisions to bundle.'))
 
5781
            raise errors.BzrCommandError(gettext('No revisions to bundle.'))
5815
5782
        directive = merge_directive.MergeDirective2.from_objects(
5816
5783
            branch.repository, revision_id, time.time(),
5817
5784
            osutils.local_time_offset(), submit_branch,
6058
6025
        self.enter_context(branch.lock_write())
6059
6026
        if delete:
6060
6027
            if tag_name is None:
6061
 
                raise errors.CommandError(
 
6028
                raise errors.BzrCommandError(
6062
6029
                    gettext("No tag specified to delete."))
6063
6030
            branch.tags.delete_tag(tag_name)
6064
6031
            note(gettext('Deleted tag %s.') % tag_name)
6065
6032
        else:
6066
6033
            if revision:
6067
6034
                if len(revision) != 1:
6068
 
                    raise errors.CommandError(gettext(
 
6035
                    raise errors.BzrCommandError(gettext(
6069
6036
                        "Tags can only be placed on a single revision, "
6070
6037
                        "not on a range"))
6071
6038
                revision_id = revision[0].as_revision_id(branch)
6074
6041
            if tag_name is None:
6075
6042
                tag_name = branch.automatic_tag_name(revision_id)
6076
6043
                if tag_name is None:
6077
 
                    raise errors.CommandError(gettext(
 
6044
                    raise errors.BzrCommandError(gettext(
6078
6045
                        "Please specify a tag name."))
6079
6046
            try:
6080
6047
                existing_target = branch.tags.lookup_tag(tag_name)
6238
6205
            stacked_on=None, unstacked=None):
6239
6206
        directory = controldir.ControlDir.open(location)
6240
6207
        if stacked_on and unstacked:
6241
 
            raise errors.CommandError(
 
6208
            raise errors.BzrCommandError(
6242
6209
                gettext("Can't use both --stacked-on and --unstacked"))
6243
6210
        elif stacked_on is not None:
6244
6211
            reconfigure.ReconfigureStackedOn().apply(directory, stacked_on)
6253
6220
            if stacked_on or unstacked:
6254
6221
                return
6255
6222
            else:
6256
 
                raise errors.CommandError(gettext('No target configuration '
 
6223
                raise errors.BzrCommandError(gettext('No target configuration '
6257
6224
                                                     'specified'))
6258
6225
        reconfiguration = None
6259
6226
        if tree_type == 'branch':
6332
6299
        possible_transports = [control_dir.root_transport]
6333
6300
        if to_location is None:
6334
6301
            if revision is None:
6335
 
                raise errors.CommandError(gettext('You must supply either a'
 
6302
                raise errors.BzrCommandError(gettext('You must supply either a'
6336
6303
                                                     ' revision or a location'))
6337
6304
            to_location = tree_location
6338
6305
        try:
6346
6313
            possible_transports.append(branch.user_transport)
6347
6314
        if create_branch:
6348
6315
            if branch is None:
6349
 
                raise errors.CommandError(
 
6316
                raise errors.BzrCommandError(
6350
6317
                    gettext('cannot create branch without source branch'))
6351
6318
            to_location = lookup_new_sibling_branch(
6352
6319
                control_dir, to_location,
6374
6341
                          store_uncommitted=store,
6375
6342
                          possible_transports=possible_transports)
6376
6343
        except controldir.BranchReferenceLoop:
6377
 
            raise errors.CommandError(
 
6344
            raise errors.BzrCommandError(
6378
6345
                gettext('switching would create a branch reference loop. '
6379
6346
                        'Use the "bzr up" command to switch to a '
6380
6347
                        'different revision.'))
6486
6453
            name = current_view
6487
6454
        if delete:
6488
6455
            if file_list:
6489
 
                raise errors.CommandError(gettext(
 
6456
                raise errors.BzrCommandError(gettext(
6490
6457
                    "Both --delete and a file list specified"))
6491
6458
            elif switch:
6492
 
                raise errors.CommandError(gettext(
 
6459
                raise errors.BzrCommandError(gettext(
6493
6460
                    "Both --delete and --switch specified"))
6494
6461
            elif all:
6495
6462
                tree.views.set_view_info(None, {})
6496
6463
                self.outf.write(gettext("Deleted all views.\n"))
6497
6464
            elif name is None:
6498
 
                raise errors.CommandError(
 
6465
                raise errors.BzrCommandError(
6499
6466
                    gettext("No current view to delete"))
6500
6467
            else:
6501
6468
                tree.views.delete_view(name)
6502
6469
                self.outf.write(gettext("Deleted '%s' view.\n") % name)
6503
6470
        elif switch:
6504
6471
            if file_list:
6505
 
                raise errors.CommandError(gettext(
 
6472
                raise errors.BzrCommandError(gettext(
6506
6473
                    "Both --switch and a file list specified"))
6507
6474
            elif all:
6508
 
                raise errors.CommandError(gettext(
 
6475
                raise errors.BzrCommandError(gettext(
6509
6476
                    "Both --switch and --all specified"))
6510
6477
            elif switch == 'off':
6511
6478
                if current_view is None:
6512
 
                    raise errors.CommandError(
 
6479
                    raise errors.BzrCommandError(
6513
6480
                        gettext("No current view to disable"))
6514
6481
                tree.views.set_view_info(None, view_dict)
6515
6482
                self.outf.write(gettext("Disabled '%s' view.\n") %
6536
6503
                # No name given and no current view set
6537
6504
                name = 'my'
6538
6505
            elif name == 'off':
6539
 
                raise errors.CommandError(gettext(
 
6506
                raise errors.BzrCommandError(gettext(
6540
6507
                    "Cannot change the 'off' pseudo view"))
6541
6508
            tree.views.set_view(name, sorted(file_list))
6542
6509
            view_str = views.view_display_str(tree.views.lookup_view())
6603
6570
                active_branch = None
6604
6571
            if (active_branch is not None and
6605
6572
                    br.control_url == active_branch.control_url):
6606
 
                raise errors.CommandError(
 
6573
                raise errors.BzrCommandError(
6607
6574
                    gettext("Branch is active. Use --force to remove it."))
6608
6575
        br.controldir.destroy_branch(br.name)
6609
6576
 
6972
6939
            path_list = ['.']
6973
6940
        else:
6974
6941
            if from_root:
6975
 
                raise errors.CommandError(
 
6942
                raise errors.BzrCommandError(
6976
6943
                    'cannot specify both --from-root and PATH.')
6977
6944
 
6978
6945
        if files_with_matches and files_without_match:
6979
 
            raise errors.CommandError(
 
6946
            raise errors.BzrCommandError(
6980
6947
                'cannot specify both '
6981
6948
                '-l/--files-with-matches and -L/--files-without-matches.')
6982
6949
 
6989
6956
            color = 'never'
6990
6957
 
6991
6958
        if color not in ['always', 'never', 'auto']:
6992
 
            raise errors.CommandError('Valid values for --color are '
 
6959
            raise errors.BzrCommandError('Valid values for --color are '
6993
6960
                                         '"always", "never" or "auto".')
6994
6961
 
6995
6962
        if levels is None: