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

  • Committer: Jelmer Vernooij
  • Date: 2012-02-06 11:36:02 UTC
  • mfrom: (6462 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6463.
  • Revision ID: jelmer@samba.org-20120206113602-yu3j0xe7qbk1szw9
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
    lazy_regex,
93
93
    library_state,
94
94
    lockdir,
95
 
    mail_client,
96
95
    mergetools,
97
96
    osutils,
98
97
    symbol_versioning,
240
239
        return diff.DiffFromTool.from_string(cmd, old_tree, new_tree,
241
240
                                             sys.stdout)
242
241
 
243
 
    def get_mail_client(self):
244
 
        """Get a mail client to use"""
245
 
        selected_client = self.get_user_option('mail_client')
246
 
        _registry = mail_client.mail_client_registry
247
 
        try:
248
 
            mail_client_class = _registry.get(selected_client)
249
 
        except KeyError:
250
 
            raise errors.UnknownMailClient(selected_client)
251
 
        return mail_client_class(self)
252
 
 
253
242
    def _get_signature_checking(self):
254
243
        """Template method to override signature checking policy."""
255
244
 
1524
1513
 
1525
1514
 
1526
1515
def config_dir():
1527
 
    """Return per-user configuration directory.
 
1516
    """Return per-user configuration directory as unicode string
1528
1517
 
1529
1518
    By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
1530
1519
    and Linux.  On Linux, if there is a $XDG_CONFIG_HOME/bazaar directory,
1532
1521
 
1533
1522
    TODO: Global option --config-dir to override this.
1534
1523
    """
1535
 
    base = os.environ.get('BZR_HOME', None)
 
1524
    base = osutils.path_from_environ('BZR_HOME')
1536
1525
    if sys.platform == 'win32':
1537
 
        # environ variables on Windows are in user encoding/mbcs. So decode
1538
 
        # before using one
1539
 
        if base is not None:
1540
 
            base = base.decode('mbcs')
1541
 
        if base is None:
1542
 
            base = win32utils.get_appdata_location_unicode()
1543
 
        if base is None:
1544
 
            base = os.environ.get('HOME', None)
1545
 
            if base is not None:
1546
 
                base = base.decode('mbcs')
1547
 
        if base is None:
1548
 
            raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
1549
 
                                  ' or HOME set')
 
1526
        if base is None:
 
1527
            base = win32utils.get_appdata_location()
 
1528
        if base is None:
 
1529
            base = win32utils.get_home_location()
 
1530
        # GZ 2012-02-01: Really the two level subdirs only make sense inside
 
1531
        #                APPDATA, but hard to move. See bug 348640 for more.
1550
1532
        return osutils.pathjoin(base, 'bazaar', '2.0')
1551
 
    else:
1552
 
        if base is not None:
1553
 
            base = base.decode(osutils._fs_enc)
1554
 
    if sys.platform == 'darwin':
1555
 
        if base is None:
1556
 
            # this takes into account $HOME
1557
 
            base = os.path.expanduser("~")
1558
 
        return osutils.pathjoin(base, '.bazaar')
1559
 
    else:
1560
 
        if base is None:
1561
 
            xdg_dir = os.environ.get('XDG_CONFIG_HOME', None)
 
1533
    if base is None:
 
1534
        # GZ 2012-02-01: What should OSX use instead of XDG if anything?
 
1535
        if sys.platform != 'darwin':
 
1536
            xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
1562
1537
            if xdg_dir is None:
1563
 
                xdg_dir = osutils.pathjoin(os.path.expanduser("~"), ".config")
 
1538
                xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
1564
1539
            xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
1565
1540
            if osutils.isdir(xdg_dir):
1566
1541
                trace.mutter(
1567
1542
                    "Using configuration in XDG directory %s." % xdg_dir)
1568
1543
                return xdg_dir
1569
 
            base = os.path.expanduser("~")
1570
 
        return osutils.pathjoin(base, ".bazaar")
 
1544
        base = osutils._get_home_dir()
 
1545
    return osutils.pathjoin(base, ".bazaar")
1571
1546
 
1572
1547
 
1573
1548
def config_filename():
2803
2778
Standard log formats are ``long``, ``short`` and ``line``. Additional formats
2804
2779
may be provided by plugins.
2805
2780
'''))
 
2781
option_registry.register_lazy('mail_client', 'bzrlib.mail_client',
 
2782
    'opt_mail_client')
2806
2783
option_registry.register(
2807
2784
    Option('output_encoding',
2808
2785
           help= 'Unicode encoding for output'
2909
2886
    ListOption('suppress_warnings',
2910
2887
           default=[],
2911
2888
           help="List of warning classes to suppress."))
 
2889
option_registry.register(
 
2890
    Option('validate_signatures_in_log', default=False,
 
2891
           from_unicode=bool_from_store, invalid='warning',
 
2892
           help='''Whether to validate signatures in bzr log.'''))
2912
2893
option_registry.register_lazy('ssl.ca_certs',
2913
2894
    'bzrlib.transport.http._urllib2_wrappers', 'opt_ssl_ca_certs')
2914
2895