def install(): global _translation if not os.environ.get('LANGUAGE'): from breezy import config lang = config.GlobalConfig().get_user_option('language') if lang: os.environ['LANGUAGE'] = lang if sys.platform == 'win32': _check_win32_locale() _translation = _gettext.translation('qbrz', localedir=_get_locale_dir(), fallback=True)
def get_option(self, option): """Get the value for the config option, either from ~/.config/breezy/breezy.conf or from the command line. All loggerhead-specific settings start with 'http_' """ global_config = config.GlobalConfig().get_user_option('http_' + option) cmd_config = getattr(self._options, option) if global_config is not None and (cmd_config is None or cmd_config is False): return global_config else: return cmd_config
def test_wo_branch(self): bug_urls = [ 'https://launchpad.net/bugs/261234 fixed', 'http://bugs.python.org/issue5243 fixed', ] # w/o global options we can match only unique lp url self.assertEqual(['lp:261234'], bug_urls_to_ids(bug_urls)) # set some options cfg = config.GlobalConfig() cfg.set_user_option('bugtracker_py_url', 'http://bugs.python.org/issue{id}') cfg.set_user_option('bugzilla_kde_url', 'http://bugs.kde.org/') cfg.set_user_option('trac_mbz_url', 'http://bugs.musicbrainz.org/') self.assertEqual(['lp:261234', 'py:5243'], bug_urls_to_ids(bug_urls))
def test_get_global_bug_tags(self): # check empty bazaar.conf self.assertEqual({}, get_global_bug_tags()) # set some options cfg = config.GlobalConfig() cfg.set_user_option('bugtracker_py_url', 'http://bugs.python.org/issue{id}') cfg.set_user_option('bugzilla_kde_url', 'http://bugs.kde.org/') cfg.set_user_option('trac_mbz_url', 'http://bugs.musicbrainz.org/ticket/') self.assertEqual({ 'py': 'bugtracker', 'kde': "bugzilla", 'mbz': 'trac' }, get_global_bug_tags())
def test_w_branch(self): bug_urls = [ 'https://launchpad.net/bugs/261234 fixed', 'http://bugs.python.org/issue5243 fixed', 'http://bugs.kde.org/show_bug.cgi?id=169104 fixed', ] wt = self.make_branch_and_tree('.') branch = wt.branch # w/o user settings we can match only unique lp url self.assertEqual(['lp:261234'], bug_urls_to_ids(bug_urls, branch)) # set some bugtrackers g_cfg = config.GlobalConfig() g_cfg.set_user_option('bugtracker_py_url', 'http://bugs.python.org/issue{id}') b_cfg = branch.get_config() b_cfg.set_user_option('bugzilla_kde_url', 'http://bugs.kde.org/') self.assertEqual(['kde:169104', 'lp:261234', 'py:5243'], bug_urls_to_ids(bug_urls, branch))
def run_bzr(argv, load_plugins=load_plugins, disable_plugins=disable_plugins): """Execute a command. :param argv: The command-line arguments, without the program name from argv[0] These should already be decoded. All library/test code calling run_bzr should be passing valid strings (don't need decoding). :param load_plugins: What function to call when triggering plugin loading. This function should take no arguments and cause all plugins to be loaded. :param disable_plugins: What function to call when disabling plugin loading. This function should take no arguments and cause all plugin loading to be prohibited (so that code paths in your application that know about some plugins possibly being present will fail to import those plugins even if they are installed.) :return: Returns a command exit code or raises an exception. Special master options: these must come before the command because they control how the command is interpreted. --no-plugins Do not load plugin modules at all --no-aliases Do not allow aliases --builtin Only use builtin commands. (Plugins are still allowed to change other behaviour.) --profile Run under the Python hotshot profiler. --lsprof Run under the Python lsprof profiler. --coverage Generate code coverage report --concurrency Specify the number of processes that can be run concurrently (selftest). """ trace.mutter("breezy version: " + breezy.__version__) argv = _specified_or_unicode_argv(argv) trace.mutter("brz arguments: %r", argv) opt_lsprof = opt_profile = opt_no_plugins = opt_builtin = \ opt_coverage = opt_no_l10n = opt_no_aliases = False opt_lsprof_file = None # --no-plugins is handled specially at a very early stage. We need # to load plugins before doing other command parsing so that they # can override commands, but this needs to happen first. argv_copy = [] i = 0 override_config = [] while i < len(argv): a = argv[i] if a == '--profile': opt_profile = True elif a == '--lsprof': opt_lsprof = True elif a == '--lsprof-file': opt_lsprof = True opt_lsprof_file = argv[i + 1] i += 1 elif a == '--no-plugins': opt_no_plugins = True elif a == '--no-aliases': opt_no_aliases = True elif a == '--no-l10n': opt_no_l10n = True elif a == '--builtin': opt_builtin = True elif a == '--concurrency': os.environ['BRZ_CONCURRENCY'] = argv[i + 1] i += 1 elif a == '--coverage': opt_coverage = True elif a == '--profile-imports': pass # already handled in startup script Bug #588277 elif a.startswith('-D'): debug.debug_flags.add(a[2:]) elif a.startswith('-O'): override_config.append(a[2:]) else: argv_copy.append(a) i += 1 cmdline_overrides = breezy.get_global_state().cmdline_overrides cmdline_overrides._from_cmdline(override_config) debug.set_debug_flags_from_config() if not opt_no_plugins: from breezy import config c = config.GlobalConfig() warn_load_problems = not c.suppress_warning('plugin_load_failure') load_plugins(warn_load_problems=warn_load_problems) else: disable_plugins() argv = argv_copy if (not argv): get_cmd_object('help').run_argv_aliases([]) return 0 if argv[0] == '--version': get_cmd_object('version').run_argv_aliases([]) return 0 alias_argv = None if not opt_no_aliases: alias_argv = get_alias(argv[0]) if alias_argv: argv[0] = alias_argv.pop(0) cmd = argv.pop(0) cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin) if opt_no_l10n: cmd_obj.l10n = False run = cmd_obj.run_argv_aliases run_argv = [argv, alias_argv] try: # We can be called recursively (tests for example), but we don't want # the verbosity level to propagate. saved_verbosity_level = option._verbosity_level option._verbosity_level = 0 if opt_lsprof: if opt_coverage: trace.warning( '--coverage ignored, because --lsprof is in use.') ret = apply_lsprofiled(opt_lsprof_file, run, *run_argv) elif opt_profile: if opt_coverage: trace.warning( '--coverage ignored, because --profile is in use.') ret = apply_profiled(run, *run_argv) elif opt_coverage: ret = apply_coveraged(run, *run_argv) else: ret = run(*run_argv) return ret or 0 finally: # reset, in case we may do other commands later within the same # process. Commands that want to execute sub-commands must propagate # --verbose in their own way. if 'memory' in debug.debug_flags: trace.debug_memory('Process status after command:', short=False) option._verbosity_level = saved_verbosity_level # Reset the overrides cmdline_overrides._reset()
def username(self): return config.GlobalConfig().username()
def username(self): username = self._ui.config("username", "default") if username is not None: return username return _mod_bzr_config.GlobalConfig().username()
def __init__(self): self._config = config.GlobalConfig()
def get_global_bug_tags(): """Return bug tags collected from global config bazaar.conf""" cfg = config.GlobalConfig() keys = list(cfg._get_parser().get('DEFAULT', {}).keys()) return get_user_bug_trackers_tags(keys)