/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/config.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 19:09:26 UTC
  • mfrom: (6622.1.36 breezy)
  • Revision ID: jelmer@jelmer.uk-20170521190926-5vtz8xaf0e9ylrpc
Merge rename to breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
"""Configuration that affects the behaviour of Bazaar.
20
20
 
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.
23
23
 
24
24
In bazaar.conf the following options may be set:
25
25
[DEFAULT]
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.
77
77
import os
78
78
import sys
79
79
 
80
 
import bzrlib
81
 
from bzrlib.decorators import needs_write_lock
82
 
from bzrlib.lazy_import import lazy_import
 
80
import breezy
 
81
from breezy.decorators import needs_write_lock
 
82
from breezy.lazy_import import lazy_import
83
83
lazy_import(globals(), """
84
84
import base64
85
85
import fnmatch
86
86
import re
87
87
 
88
 
from bzrlib import (
 
88
from breezy import (
89
89
    atomicfile,
90
90
    controldir,
91
91
    debug,
103
103
    urlutils,
104
104
    win32utils,
105
105
    )
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
108
108
""")
109
 
from bzrlib import (
 
109
from breezy import (
110
110
    commands,
111
111
    hooks,
112
112
    lazy_regex,
113
113
    registry,
114
114
    )
115
 
from bzrlib.symbol_versioning import (
 
115
from breezy.symbol_versioning import (
116
116
    deprecated_in,
117
117
    deprecated_method,
118
118
    )
208
208
        raise NotImplementedError(self.config_id)
209
209
 
210
210
    def get_change_editor(self, old_tree, new_tree):
211
 
        from bzrlib import diff
 
211
        from breezy import diff
212
212
        cmd = self._get_change_editor()
213
213
        if cmd is None:
214
214
            return None
334
334
            value = env[name]
335
335
        else:
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
512
512
 
513
513
        Something similar to 'Martin Pool <mbp@sourcefrog.net>'
514
514
 
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.
519
519
        """
520
 
        v = os.environ.get('BZR_EMAIL')
 
520
        v = os.environ.get('BRZ_EMAIL')
521
521
        if v:
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
637
637
        notified.
638
638
        """
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
672
672
        notified.
673
673
        """
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).',
1484
1484
        osutils.copy_ownership_from_path(path)
1485
1485
 
1486
1486
 
1487
 
def config_dir():
 
1487
def bazaar_config_dir():
1488
1488
    """Return per-user configuration directory as unicode string
1489
1489
 
1490
1490
    By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
1515
1515
    return osutils.pathjoin(base, ".bazaar")
1516
1516
 
1517
1517
 
 
1518
def config_dir():
 
1519
    """Return per-user configuration directory as unicode string
 
1520
 
 
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.
 
1524
 
 
1525
    TODO: Global option --config-dir to override this.
 
1526
    """
 
1527
    base = osutils.path_from_environ('BRZ_HOME')
 
1528
    if sys.platform == 'win32':
 
1529
        if base is None:
 
1530
            base = win32utils.get_appdata_location()
 
1531
        if base is None:
 
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.
 
1535
    if base is None:
 
1536
        base = osutils.path_from_environ('XDG_CONFIG_HOME')
 
1537
        if base is None:
 
1538
            base = osutils.pathjoin(osutils._get_home_dir(), ".config")
 
1539
    breezy_dir = osutils.pathjoin(base, 'breezy')
 
1540
    if osutils.isdir(breezy_dir):
 
1541
        return 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):
 
1545
        trace.mutter(
 
1546
            "Using Bazaar configuration directory (%s)", bazaar_dir)
 
1547
        return bazaar_dir
 
1548
    return breezy_dir
 
1549
 
 
1550
 
1518
1551
def config_filename():
1519
1552
    """Return per-user configuration ini file filename."""
1520
1553
    return osutils.pathjoin(config_dir(), 'bazaar.conf')
1582
1615
 
1583
1616
 
1584
1617
def default_email():
1585
 
    v = os.environ.get('BZR_EMAIL')
 
1618
    v = os.environ.get('BRZ_EMAIL')
1586
1619
    if v:
1587
1620
        return v.decode(osutils.get_user_encoding())
1588
1621
    v = os.environ.get('EMAIL')
2020
2053
    A credential store provides access to credentials via the password_encoding
2021
2054
    field in authentication.conf sections.
2022
2055
 
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.
2422
2455
 
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)
2427
2460
        if plain:
2428
2461
            result = help_topics.help_as_plain_text(result)
2673
2706
Whether revisions associated with tags should be fetched.
2674
2707
"""))
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.
2805
2838
'''))
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',
2827
2860
 
2828
2861
Each function takes branch, rev_id as parameters.
2829
2862
'''))
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.
2867
2900
'''))
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',
2876
2909
        default='600',
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')
2922
2955
 
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')
2925
2958
 
2926
2959
 
2927
2960
class Section(object):
3845
3878
 
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()
3850
3883
        return []
3851
3884
 
3852
3885
    def get_shared_store(self, store, state=None):
3863
3896
            otherwise.
3864
3897
        """
3865
3898
        if state is None:
3866
 
            state = bzrlib.global_state
 
3899
            state = breezy.global_state
3867
3900
        if state is None:
3868
3901
            global _shared_stores_at_exit_installed
3869
3902
            stores = _shared_stores
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.
4273
4306
 
4274
4307
# The registered object should be a callable receiving a test instance