1526
1526
def config_dir():
1527
"""Return per-user configuration directory.
1527
"""Return per-user configuration directory as unicode string
1529
1529
By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
1530
1530
and Linux. On Linux, if there is a $XDG_CONFIG_HOME/bazaar directory,
1533
1533
TODO: Global option --config-dir to override this.
1535
base = os.environ.get('BZR_HOME', None)
1535
base = osutils.path_from_environ('BZR_HOME')
1536
1536
if sys.platform == 'win32':
1537
# environ variables on Windows are in user encoding/mbcs. So decode
1539
if base is not None:
1540
base = base.decode('mbcs')
1542
base = win32utils.get_appdata_location_unicode()
1544
base = os.environ.get('HOME', None)
1545
if base is not None:
1546
base = base.decode('mbcs')
1548
raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
1538
base = win32utils.get_appdata_location()
1540
base = win32utils.get_home_location()
1541
# GZ 2012-02-01: Really the two level subdirs only make sense inside
1542
# APPDATA, but hard to move. See bug 348640 for more.
1550
1543
return osutils.pathjoin(base, 'bazaar', '2.0')
1552
if base is not None:
1553
base = base.decode(osutils._fs_enc)
1554
if sys.platform == 'darwin':
1556
# this takes into account $HOME
1557
base = os.path.expanduser("~")
1558
return osutils.pathjoin(base, '.bazaar')
1561
xdg_dir = os.environ.get('XDG_CONFIG_HOME', None)
1545
# GZ 2012-02-01: What should OSX use instead of XDG if anything?
1546
if sys.platform != 'darwin':
1547
xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
1562
1548
if xdg_dir is None:
1563
xdg_dir = osutils.pathjoin(os.path.expanduser("~"), ".config")
1549
xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
1564
1550
xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
1565
1551
if osutils.isdir(xdg_dir):
1567
1553
"Using configuration in XDG directory %s." % xdg_dir)
1569
base = os.path.expanduser("~")
1570
return osutils.pathjoin(base, ".bazaar")
1555
base = osutils._get_home_dir()
1556
return osutils.pathjoin(base, ".bazaar")
1573
1559
def config_filename():