1515
1515
def config_dir():
1516
"""Return per-user configuration directory.
1516
"""Return per-user configuration directory as unicode string
1518
1518
By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
1519
1519
and Linux. On Linux, if there is a $XDG_CONFIG_HOME/bazaar directory,
1522
1522
TODO: Global option --config-dir to override this.
1524
base = os.environ.get('BZR_HOME', None)
1524
base = osutils.path_from_environ('BZR_HOME')
1525
1525
if sys.platform == 'win32':
1526
# environ variables on Windows are in user encoding/mbcs. So decode
1528
if base is not None:
1529
base = base.decode('mbcs')
1531
base = win32utils.get_appdata_location_unicode()
1533
base = os.environ.get('HOME', None)
1534
if base is not None:
1535
base = base.decode('mbcs')
1537
raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
1527
base = win32utils.get_appdata_location()
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.
1539
1532
return osutils.pathjoin(base, 'bazaar', '2.0')
1541
if base is not None:
1542
base = base.decode(osutils._fs_enc)
1543
if sys.platform == 'darwin':
1545
# this takes into account $HOME
1546
base = os.path.expanduser("~")
1547
return osutils.pathjoin(base, '.bazaar')
1550
xdg_dir = os.environ.get('XDG_CONFIG_HOME', 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')
1551
1537
if xdg_dir is None:
1552
xdg_dir = osutils.pathjoin(os.path.expanduser("~"), ".config")
1538
xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
1553
1539
xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
1554
1540
if osutils.isdir(xdg_dir):
1556
1542
"Using configuration in XDG directory %s." % xdg_dir)
1558
base = os.path.expanduser("~")
1559
return osutils.pathjoin(base, ".bazaar")
1544
base = osutils._get_home_dir()
1545
return osutils.pathjoin(base, ".bazaar")
1562
1548
def config_filename():