~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-06 23:38:33 UTC
  • mfrom: (6463 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6464.
  • Revision ID: jelmer@samba.org-20120206233833-w0nbclw7d1xj4twj
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
                   turns on create_signatures.
56
56
create_signatures - this option controls whether bzr will always create
57
57
                    gpg signatures or not on commits.  There is an unused
58
 
                    option which in future is expected to work if               
 
58
                    option which in future is expected to work if
59
59
                    branch settings require signatures.
60
60
log_format - this option sets the default log format.  Possible values are
61
61
             long, short, line, or a plugin can register new formats.
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():
2683
2658
           help="""\
2684
2659
Whether revisions associated with tags should be fetched.
2685
2660
"""))
 
2661
option_registry.register_lazy(
 
2662
    'bzr.transform.orphan_policy', 'bzrlib.transform', 'opt_transform_orphan')
2686
2663
option_registry.register(
2687
2664
    Option('bzr.workingtree.worth_saving_limit', default=10,
2688
2665
           from_unicode=int_from_store,  invalid='warning',
2803
2780
Standard log formats are ``long``, ``short`` and ``line``. Additional formats
2804
2781
may be provided by plugins.
2805
2782
'''))
 
2783
option_registry.register_lazy('mail_client', 'bzrlib.mail_client',
 
2784
    'opt_mail_client')
2806
2785
option_registry.register(
2807
2786
    Option('output_encoding',
2808
2787
           help= 'Unicode encoding for output'