19
19
"""Configuration that affects the behaviour of Bazaar.
21
21
Currently this configuration resides in ~/.bazaar/bazaar.conf
22
and ~/.bazaar/locations.conf, which is written to by bzr.
22
and ~/.bazaar/locations.conf, which is written to by brz.
24
24
In bazaar.conf the following options may be set:
48
48
explanation of options
49
49
----------------------
50
50
editor - this option sets the pop up editor to use during commits.
51
email - this option sets the user id bzr will use when committing.
52
check_signatures - this option will control whether bzr will require good gpg
51
email - this option sets the user id brz will use when committing.
52
check_signatures - this option will control whether brz will require good gpg
53
53
signatures, ignore them, or check them if they are
54
54
present. Currently it is unused except that check_signatures
55
55
turns on create_signatures.
56
create_signatures - this option controls whether bzr will always create
56
create_signatures - this option controls whether brz will always create
57
57
gpg signatures or not on commits. There is an unused
58
58
option which in future is expected to work if
59
59
branch settings require signatures.
81
from bzrlib.decorators import needs_write_lock
82
from bzrlib.lazy_import import lazy_import
81
from breezy.decorators import needs_write_lock
82
from breezy.lazy_import import lazy_import
83
83
lazy_import(globals(), """
106
from bzrlib.i18n import gettext
107
from bzrlib.util.configobj import configobj
106
from breezy.i18n import gettext
107
from breezy.util.configobj import configobj
115
from bzrlib.symbol_versioning import (
115
from breezy.symbol_versioning import (
117
117
deprecated_method,
334
334
value = env[name]
336
336
# FIXME: This is a limited implementation, what we really need is a
337
# way to query the bzr config for the value of an option,
337
# way to query the brz config for the value of an option,
338
338
# respecting the scope rules (That is, once we implement fallback
339
339
# configs, getting the option value should restart from the top
340
340
# config, not the current one) -- vila 20101222
513
513
Something similar to 'Martin Pool <mbp@sourcefrog.net>'
515
$BZR_EMAIL can be set to override this, then
515
$BRZ_EMAIL can be set to override this, then
516
516
the concrete policy type is checked, and finally
517
517
$EMAIL is examined.
518
518
If no username can be found, errors.NoWhoami exception is raised.
520
v = os.environ.get('BZR_EMAIL')
520
v = os.environ.get('BRZ_EMAIL')
522
522
return v.decode(osutils.get_user_encoding())
523
523
v = self._get_user_id()
636
636
These are all empty initially, because by default nothing should get
639
super(_ConfigHooks, self).__init__('bzrlib.config', 'ConfigHooks')
639
super(_ConfigHooks, self).__init__('breezy.config', 'ConfigHooks')
640
640
self.add_hook('load',
641
641
'Invoked when a config store is loaded.'
642
642
' The signature is (store).',
671
671
These are all empty initially, because by default nothing should get
674
super(_OldConfigHooks, self).__init__('bzrlib.config', 'OldConfigHooks')
674
super(_OldConfigHooks, self).__init__('breezy.config', 'OldConfigHooks')
675
675
self.add_hook('load',
676
676
'Invoked when a config store is loaded.'
677
677
' The signature is (config).',
1515
1515
return osutils.pathjoin(base, ".bazaar")
1519
"""Return per-user configuration directory as unicode string
1521
By default this is %APPDATA%/breezy on Windows, $XDG_CONFIG_HOME/breezy on
1522
Mac OS X and Linux. If the breezy config directory doesn't exist but
1523
the bazaar one (see bazaar_config_dir()) does, use that instead.
1525
TODO: Global option --config-dir to override this.
1527
base = osutils.path_from_environ('BRZ_HOME')
1528
if sys.platform == 'win32':
1530
base = win32utils.get_appdata_location()
1532
base = win32utils.get_home_location()
1533
# GZ 2012-02-01: Really the two level subdirs only make sense inside
1534
# APPDATA, but hard to move. See bug 348640 for more.
1536
base = osutils.path_from_environ('XDG_CONFIG_HOME')
1538
base = osutils.pathjoin(osutils._get_home_dir(), ".config")
1539
breezy_dir = osutils.pathjoin(base, 'breezy')
1540
if osutils.isdir(breezy_dir):
1542
# If the breezy directory doesn't exist, but the bazaar one does, use that:
1543
bazaar_dir = bazaar_config_dir()
1544
if osutils.isdir(bazaar_dir):
1546
"Using Bazaar configuration directory (%s)", bazaar_dir)
1518
1551
def config_filename():
1519
1552
"""Return per-user configuration ini file filename."""
1520
1553
return osutils.pathjoin(config_dir(), 'bazaar.conf')
2020
2053
A credential store provides access to credentials via the password_encoding
2021
2054
field in authentication.conf sections.
2023
Except for stores provided by bzr itself, most stores are expected to be
2056
Except for stores provided by brz itself, most stores are expected to be
2024
2057
provided by plugins that will therefore use
2025
2058
register_lazy(password_encoding, module_name, member_name, help=help,
2026
2059
fallback=fallback) to install themselves.
2423
2456
def get_help_text(self, additional_see_also=None, plain=True):
2424
2457
result = self.help
2425
from bzrlib import help_topics
2458
from breezy import help_topics
2426
2459
result += help_topics._format_see_also(additional_see_also)
2428
2461
result = help_topics.help_as_plain_text(result)
2673
2706
Whether revisions associated with tags should be fetched.
2675
2708
option_registry.register_lazy(
2676
'bzr.transform.orphan_policy', 'bzrlib.transform', 'opt_transform_orphan')
2709
'bzr.transform.orphan_policy', 'breezy.transform', 'opt_transform_orphan')
2677
2710
option_registry.register(
2678
2711
Option('bzr.workingtree.worth_saving_limit', default=10,
2679
2712
from_unicode=int_from_store, invalid='warning',
2754
2787
Option('editor',
2755
2788
help='The command called to launch an editor to enter a message.'))
2756
2789
option_registry.register(
2757
Option('email', override_from_env=['BZR_EMAIL'], default=default_email,
2790
Option('email', override_from_env=['BRZ_EMAIL'], default=default_email,
2758
2791
help='The users identity'))
2759
2792
option_registry.register(
2760
2793
Option('gpg_signing_command',
2803
2836
Standard log formats are ``long``, ``short`` and ``line``. Additional formats
2804
2837
may be provided by plugins.
2806
option_registry.register_lazy('mail_client', 'bzrlib.mail_client',
2839
option_registry.register_lazy('mail_client', 'breezy.mail_client',
2807
2840
'opt_mail_client')
2808
2841
option_registry.register(
2809
2842
Option('output_encoding',
2828
2861
Each function takes branch, rev_id as parameters.
2830
option_registry.register_lazy('progress_bar', 'bzrlib.ui.text',
2863
option_registry.register_lazy('progress_bar', 'breezy.ui.text',
2831
2864
'opt_progress_bar')
2832
2865
option_registry.register(
2833
2866
Option('public_branch',
2866
2899
lost if the machine crashes. See also dirstate.fdatasync.
2868
2901
option_registry.register_lazy('smtp_server',
2869
'bzrlib.smtp_connection', 'smtp_server')
2902
'breezy.smtp_connection', 'smtp_server')
2870
2903
option_registry.register_lazy('smtp_password',
2871
'bzrlib.smtp_connection', 'smtp_password')
2904
'breezy.smtp_connection', 'smtp_password')
2872
2905
option_registry.register_lazy('smtp_username',
2873
'bzrlib.smtp_connection', 'smtp_username')
2906
'breezy.smtp_connection', 'smtp_username')
2874
2907
option_registry.register(
2875
2908
Option('selftest.timeout',
2916
2949
option_registry.register(
2917
2950
Option('validate_signatures_in_log', default=False,
2918
2951
from_unicode=bool_from_store, invalid='warning',
2919
help='''Whether to validate signatures in bzr log.'''))
2952
help='''Whether to validate signatures in brz log.'''))
2920
2953
option_registry.register_lazy('ssl.ca_certs',
2921
'bzrlib.transport.http._urllib2_wrappers', 'opt_ssl_ca_certs')
2954
'breezy.transport.http._urllib2_wrappers', 'opt_ssl_ca_certs')
2923
2956
option_registry.register_lazy('ssl.cert_reqs',
2924
'bzrlib.transport.http._urllib2_wrappers', 'opt_ssl_cert_reqs')
2957
'breezy.transport.http._urllib2_wrappers', 'opt_ssl_cert_reqs')
2927
2960
class Section(object):
3846
3879
def _get_overrides(self):
3847
3880
# FIXME: Hack around library_state.initialize never called
3848
if bzrlib.global_state is not None:
3849
return bzrlib.global_state.cmdline_overrides.get_sections()
3881
if breezy.global_state is not None:
3882
return breezy.global_state.cmdline_overrides.get_sections()
3852
3885
def get_shared_store(self, store, state=None):
4268
4301
# themselves. The builder will receive a test instance and should return a
4269
4302
# ready-to-use store or stack. Plugins that define new store/stacks can also
4270
4303
# register themselves here to be tested against the tests defined in
4271
# bzrlib.tests.test_config. Note that the builder can be called multiple times
4304
# breezy.tests.test_config. Note that the builder can be called multiple times
4272
4305
# for the same test.
4274
4307
# The registered object should be a callable receiving a test instance