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

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
222
222
    Use of all_command_names() is encouraged rather than builtin_command_names
223
223
    and/or plugin_command_names.
224
224
    """
225
 
    _register_builtin_commands()
226
225
    return builtin_command_registry.keys()
227
226
 
228
227
 
398
397
            will not mangled.
399
398
 
400
399
    :cvar hooks: An instance of CommandHooks.
401
 
    :ivar __doc__: The help shown by 'bzr help command' for this command.
402
 
        This is set by assigning explicitly to __doc__ so that -OO can
403
 
        be used::
404
 
 
405
 
        class Foo(Command):
406
 
            __doc__ = "My help goes here"
407
400
    """
408
401
    aliases = []
409
402
    takes_args = []
414
407
 
415
408
    def __init__(self):
416
409
        """Construct an instance of this command."""
 
410
        if self.__doc__ == Command.__doc__:
 
411
            warn("No help message set for %r" % self)
417
412
        # List of standard options directly supported
418
413
        self.supported_std_options = []
419
414
        self._setup_run()
487
482
            message explaining how to obtain full help.
488
483
        """
489
484
        doc = self.help()
490
 
        if not doc:
491
 
            doc = "No help for this command."
 
485
        if doc is None:
 
486
            raise NotImplementedError("sorry, no detailed help yet for %r" % self.name())
492
487
 
493
488
        # Extract the summary (purpose) and sections out from the text
494
489
        purpose,sections,order = self._get_help_parts(doc)
687
682
 
688
683
        self._setup_outf()
689
684
 
690
 
        try:
691
 
            return self.run(**all_cmd_args)
692
 
        finally:
693
 
            # reset it, so that other commands run in the same process won't
694
 
            # inherit state. Before we reset it, log any activity, so that it
695
 
            # gets properly tracked.
696
 
            ui.ui_factory.log_transport_activity(
697
 
                display=('bytes' in debug.debug_flags))
698
 
            trace.set_verbosity_level(0)
 
685
        return self.run(**all_cmd_args)
699
686
 
700
687
    def _setup_run(self):
701
688
        """Wrap the defined run method on self with a cleanup.
818
805
    else:
819
806
        args = argv
820
807
 
821
 
    # for python 2.5 and later, optparse raises this exception if a non-ascii
822
 
    # option name is given.  See http://bugs.python.org/issue2931
823
 
    try:
824
 
        options, args = parser.parse_args(args)
825
 
    except UnicodeEncodeError,e:
826
 
        raise errors.BzrCommandError('Only ASCII permitted in option names')
827
 
 
 
808
    options, args = parser.parse_args(args)
828
809
    opts = dict([(k, v) for k, v in options.__dict__.iteritems() if
829
810
                 v is not option.OptionParser.DEFAULT_VALUE])
830
811
    return args, opts
1069
1050
        elif a == '--coverage':
1070
1051
            opt_coverage_dir = argv[i + 1]
1071
1052
            i += 1
1072
 
        elif a == '--profile-imports':
1073
 
            pass # already handled in startup script Bug #588277
1074
1053
        elif a.startswith('-D'):
1075
1054
            debug.debug_flags.add(a[2:])
1076
1055
        else:
1098
1077
    if not opt_no_aliases:
1099
1078
        alias_argv = get_alias(argv[0])
1100
1079
        if alias_argv:
 
1080
            user_encoding = osutils.get_user_encoding()
 
1081
            alias_argv = [a.decode(user_encoding) for a in alias_argv]
1101
1082
            argv[0] = alias_argv.pop(0)
1102
1083
 
1103
1084
    cmd = argv.pop(0)
 
1085
    # We want only 'ascii' command names, but the user may have typed
 
1086
    # in a Unicode name. In that case, they should just get a
 
1087
    # 'command not found' error later.
 
1088
 
1104
1089
    cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
1105
1090
    run = cmd_obj.run_argv_aliases
1106
1091
    run_argv = [argv, alias_argv]
1205
1190
    argv = _specified_or_unicode_argv(argv)
1206
1191
    _register_builtin_commands()
1207
1192
    ret = run_bzr_catch_errors(argv)
 
1193
    bzrlib.ui.ui_factory.log_transport_activity(
 
1194
        display=('bytes' in debug.debug_flags))
1208
1195
    trace.mutter("return code %d", ret)
1209
1196
    return ret
1210
1197