/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/commands.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:
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
# TODO: Define arguments by objects, rather than just using names.
18
20
# Those objects can specify the expected type of the argument, which
19
21
# would help with validation and shell completion.  They could also provide
52
54
from . import errors, registry
53
55
 
54
56
 
55
 
class BzrOptionError(errors.CommandError):
 
57
class BzrOptionError(errors.BzrCommandError):
56
58
 
57
59
    _fmt = "Error in command line options"
58
60
 
298
300
        # No command found, see if this was a typo
299
301
        candidate = guess_command(cmd_name)
300
302
        if candidate is not None:
301
 
            raise errors.CommandError(
 
303
            raise errors.BzrCommandError(
302
304
                gettext('unknown command "%s". Perhaps you meant "%s"')
303
305
                % (cmd_name, candidate))
304
 
        raise errors.CommandError(gettext('unknown command "%s"')
 
306
        raise errors.BzrCommandError(gettext('unknown command "%s"')
305
307
                                     % cmd_name)
306
308
 
307
309
 
910
912
    try:
911
913
        options, args = parser.parse_args(args)
912
914
    except UnicodeEncodeError:
913
 
        raise errors.CommandError(
 
915
        raise errors.BzrCommandError(
914
916
            gettext('Only ASCII permitted in option names'))
915
917
 
916
918
    opts = dict((k, v) for k, v in options.__dict__.items() if
935
937
                argdict[argname + '_list'] = None
936
938
        elif ap[-1] == '+':
937
939
            if not args:
938
 
                raise errors.CommandError(gettext(
 
940
                raise errors.BzrCommandError(gettext(
939
941
                    "command {0!r} needs one or more {1}").format(
940
942
                    cmd, argname.upper()))
941
943
            else:
943
945
                args = []
944
946
        elif ap[-1] == '$':  # all but one
945
947
            if len(args) < 2:
946
 
                raise errors.CommandError(
 
948
                raise errors.BzrCommandError(
947
949
                    gettext("command {0!r} needs one or more {1}").format(
948
950
                        cmd, argname.upper()))
949
951
            argdict[argname + '_list'] = args[:-1]
952
954
            # just a plain arg
953
955
            argname = ap
954
956
            if not args:
955
 
                raise errors.CommandError(
 
957
                raise errors.BzrCommandError(
956
958
                    gettext("command {0!r} requires argument {1}").format(
957
959
                        cmd, argname.upper()))
958
960
            else:
959
961
                argdict[argname] = args.pop(0)
960
962
 
961
963
    if args:
962
 
        raise errors.CommandError(gettext(
 
964
        raise errors.BzrCommandError(gettext(
963
965
            "extra argument to command {0}: {1}").format(
964
966
            cmd, args[0]))
965
967
 
1155
1157
    debug.set_debug_flags_from_config()
1156
1158
 
1157
1159
    if not opt_no_plugins:
1158
 
        from breezy import config
1159
 
        c = config.GlobalConfig()
1160
 
        warn_load_problems = not c.suppress_warning('plugin_load_failure')
1161
 
        load_plugins(warn_load_problems=warn_load_problems)
 
1160
        load_plugins()
1162
1161
    else:
1163
1162
        disable_plugins()
1164
1163
 
1255
1254
 
1256
1255
def _specified_or_unicode_argv(argv):
1257
1256
    # For internal or testing use, argv can be passed.  Otherwise, get it from
1258
 
    # the process arguments.
 
1257
    # the process arguments in a unicode-safe way.
1259
1258
    if argv is None:
1260
 
        return sys.argv[1:]
 
1259
        return osutils.get_unicode_argv()
1261
1260
    new_argv = []
1262
1261
    try:
1263
1262
        # ensure all arguments are unicode strings