/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: Jonathan Lange
  • Date: 2009-12-09 09:20:42 UTC
  • mfrom: (4881 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4907.
  • Revision ID: jml@canonical.com-20091209092042-s2zgqcf8f39yzxpj
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2006, 2008, 2009 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
45
45
    option,
46
46
    osutils,
47
47
    trace,
 
48
    ui,
48
49
    win32utils,
49
50
    )
50
51
""")
56
57
from bzrlib.symbol_versioning import (
57
58
    deprecated_function,
58
59
    deprecated_in,
 
60
    deprecated_method,
59
61
    suppress_deprecation_warnings,
60
62
    )
61
63
 
101
103
            registry.Registry.register(self, k_unsquished, cmd,
102
104
                                       override_existing=decorate, info=info)
103
105
        except KeyError:
104
 
            trace.log_error('Two plugins defined the same command: %r' % k)
105
 
            trace.log_error('Not loading the one in %r' %
106
 
                            sys.modules[cmd.__module__])
107
 
            trace.log_error('Previously this command was registered from %r' %
108
 
                            sys.modules[previous.__module__])
 
106
            trace.warning('Two plugins defined the same command: %r' % k)
 
107
            trace.warning('Not loading the one in %r' %
 
108
                sys.modules[cmd.__module__])
 
109
            trace.warning('Previously this command was registered from %r' %
 
110
                sys.modules[previous.__module__])
109
111
        return previous
110
112
 
111
113
    def register_lazy(self, command_name, aliases, module_name):
383
385
        # List of standard options directly supported
384
386
        self.supported_std_options = []
385
387
 
 
388
    @deprecated_method(deprecated_in((2, 1, 0)))
386
389
    def _maybe_expand_globs(self, file_list):
387
390
        """Glob expand file_list if the platform does not do that itself.
388
391
 
 
392
        Not used anymore, now that the bzr command-line parser globs on
 
393
        Windows.
 
394
 
389
395
        :return: A possibly empty list of unicode paths.
390
396
 
391
397
        Introduced in bzrlib 0.18.
392
398
        """
393
 
        if not file_list:
394
 
            file_list = []
395
 
        if sys.platform == 'win32':
396
 
            file_list = win32utils.glob_expand(file_list)
397
 
        return list(file_list)
 
399
        return file_list
398
400
 
399
401
    def _usage(self):
400
402
        """Return single-line grammar for this command.
457
459
        # so we get <https://bugs.launchpad.net/bzr/+bug/249908>.  -- mbp
458
460
        # 20090319
459
461
        options = option.get_optparser(self.options()).format_option_help()
 
462
        # XXX: According to the spec, ReST option lists actually don't support 
 
463
        # options like --1.9 so that causes syntax errors (in Sphinx at least).
 
464
        # As that pattern always appears in the commands that break, we trap
 
465
        # on that and then format that block of 'format' options as a literal
 
466
        # block.
 
467
        if not plain and options.find('  --1.9  ') != -1:
 
468
            options = options.replace(' format:\n', ' format::\n\n', 1)
460
469
        if options.startswith('Options:'):
461
470
            result += ':' + options
462
471
        elif options.startswith('options:'):
587
596
 
588
597
    def _setup_outf(self):
589
598
        """Return a file linked to stdout, which has proper encoding."""
590
 
        # Originally I was using self.stdout, but that looks
591
 
        # *way* too much like sys.stdout
592
 
        if self.encoding_type == 'exact':
593
 
            # force sys.stdout to be binary stream on win32
594
 
            if sys.platform == 'win32':
595
 
                fileno = getattr(sys.stdout, 'fileno', None)
596
 
                if fileno:
597
 
                    import msvcrt
598
 
                    msvcrt.setmode(fileno(), os.O_BINARY)
599
 
            self.outf = sys.stdout
600
 
            return
601
 
 
602
 
        output_encoding = osutils.get_terminal_encoding()
603
 
 
604
 
        self.outf = codecs.getwriter(output_encoding)(sys.stdout,
605
 
                        errors=self.encoding_type)
606
 
        # For whatever reason codecs.getwriter() does not advertise its encoding
607
 
        # it just returns the encoding of the wrapped file, which is completely
608
 
        # bogus. So set the attribute, so we can find the correct encoding later.
609
 
        self.outf.encoding = output_encoding
 
599
        self.outf = ui.ui_factory.make_output_stream(
 
600
            encoding_type=self.encoding_type)
610
601
 
611
602
    def run_argv_aliases(self, argv, alias_argv=None):
612
603
        """Parse the command line and run with extra aliases in alias_argv."""
932
923
 
933
924
    --coverage
934
925
        Generate line coverage report in the specified directory.
 
926
 
 
927
    --concurrency
 
928
        Specify the number of processes that can be run concurrently (selftest).
935
929
    """
936
930
    argv = list(argv)
937
931
    trace.mutter("bzr arguments: %r", argv)
962
956
            opt_no_aliases = True
963
957
        elif a == '--builtin':
964
958
            opt_builtin = True
 
959
        elif a == '--concurrency':
 
960
            os.environ['BZR_CONCURRENCY'] = argv[i + 1]
 
961
            i += 1
965
962
        elif a == '--coverage':
966
963
            opt_coverage_dir = argv[i + 1]
967
964
            i += 1
1028
1025
            ret = apply_coveraged(opt_coverage_dir, run, *run_argv)
1029
1026
        else:
1030
1027
            ret = run(*run_argv)
1031
 
        if 'memory' in debug.debug_flags:
1032
 
            trace.debug_memory('Process status after command:', short=False)
1033
1028
        return ret or 0
1034
1029
    finally:
1035
1030
        # reset, in case we may do other commands later within the same
1036
1031
        # process. Commands that want to execute sub-commands must propagate
1037
1032
        # --verbose in their own way.
 
1033
        if 'memory' in debug.debug_flags:
 
1034
            trace.debug_memory('Process status after command:', short=False)
1038
1035
        option._verbosity_level = saved_verbosity_level
1039
1036
 
1040
1037
 
1090
1087
 
1091
1088
    # Is this a final release version? If so, we should suppress warnings
1092
1089
    if bzrlib.version_info[3] == 'final':
1093
 
        suppress_deprecation_warnings(override=False)
 
1090
        suppress_deprecation_warnings(override=True)
1094
1091
    if argv is None:
1095
1092
        argv = osutils.get_unicode_argv()
1096
1093
    else:
1107
1104
        argv = new_argv
1108
1105
    ret = run_bzr_catch_errors(argv)
1109
1106
    trace.mutter("return code %d", ret)
 
1107
    osutils.report_extension_load_failures()
1110
1108
    return ret
1111
1109
 
1112
1110