Rev 5553: (spiv) Support configuration files located in $XDG_CONFIG_HOME/bazaar (Neil in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Nov 29 01:23:57 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5553 [merge]
revision-id: pqm at pqm.ubuntu.com-20101129012353-9fn17vlqdmipx4a9
parent: pqm at pqm.ubuntu.com-20101126174205-7df8czxme4tjes2b
parent: andrew.bennetts at canonical.com-20101129003403-z5a6z1zk6vab8typ
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-11-29 01:23:53 +0000
message:
(spiv) Support configuration files located in $XDG_CONFIG_HOME/bazaar (Neil
Martinsen-Burrell) (Andrew Bennetts)
added:
doc/developers/xdg_config_spec.txt xdg_config_spec.txt-20101101151358-mqniaqpr56xpb5gu-1
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
doc/en/whats-new/whats-new-in-2.3.txt whatsnewin2.3.txt-20100818072501-x2h25r7jbnknvy30-1
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2010-11-17 15:51:10 +0000
+++ b/bzrlib/config.py 2010-11-29 01:23:53 +0000
@@ -1123,7 +1123,9 @@
def config_dir():
"""Return per-user configuration directory.
- By default this is ~/.bazaar/
+ By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
+ and Linux. On Linux, if there is a $XDG_CONFIG_HOME/bazaar directory,
+ that will be used instead.
TODO: Global option --config-dir to override this.
"""
@@ -1137,8 +1139,23 @@
raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
' or HOME set')
return osutils.pathjoin(base, 'bazaar', '2.0')
+ elif sys.platform == 'darwin':
+ if base is None:
+ # this takes into account $HOME
+ base = os.path.expanduser("~")
+ return osutils.pathjoin(base, '.bazaar')
else:
if base is None:
+
+ xdg_dir = os.environ.get('XDG_CONFIG_HOME', None)
+ if xdg_dir is None:
+ xdg_dir = osutils.pathjoin(os.path.expanduser("~"), ".config")
+ xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
+ if osutils.isdir(xdg_dir):
+ trace.mutter(
+ "Using configuration in XDG directory %s." % xdg_dir)
+ return xdg_dir
+
base = os.path.expanduser("~")
return osutils.pathjoin(base, ".bazaar")
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2010-11-17 15:52:03 +0000
+++ b/bzrlib/tests/test_config.py 2010-11-29 01:23:53 +0000
@@ -432,6 +432,34 @@
'/home/bogus/.cache')
+class TestXDGConfigDir(tests.TestCaseInTempDir):
+ # must be in temp dir because config tests for the existence of the bazaar
+ # subdirectory of $XDG_CONFIG_HOME
+
+ def setUp(self):
+ if sys.platform in ('darwin', 'win32'):
+ raise tests.TestNotApplicable(
+ 'XDG config dir not used on this platform')
+ super(TestXDGConfigDir, self).setUp()
+ os.environ['HOME'] = self.test_home_dir
+ # BZR_HOME overrides everything we want to test so unset it.
+ del os.environ['BZR_HOME']
+
+ def test_xdg_config_dir_exists(self):
+ """When ~/.config/bazaar exists, use it as the config dir."""
+ newdir = osutils.pathjoin(self.test_home_dir, '.config', 'bazaar')
+ os.makedirs(newdir)
+ self.assertEqual(config.config_dir(), newdir)
+
+ def test_xdg_config_home(self):
+ """When XDG_CONFIG_HOME is set, use it."""
+ xdgconfigdir = osutils.pathjoin(self.test_home_dir, 'xdgconfig')
+ os.environ['XDG_CONFIG_HOME'] = xdgconfigdir
+ newdir = osutils.pathjoin(xdgconfigdir, 'bazaar')
+ os.makedirs(newdir)
+ self.assertEqual(config.config_dir(), newdir)
+
+
class TestIniConfig(tests.TestCaseInTempDir):
def make_config_parser(self, s):
=== added file 'doc/developers/xdg_config_spec.txt'
--- a/doc/developers/xdg_config_spec.txt 1970-01-01 00:00:00 +0000
+++ b/doc/developers/xdg_config_spec.txt 2010-11-27 05:38:41 +0000
@@ -0,0 +1,27 @@
+Transitioning Unix installs to the XDG Base Directory Specification
+===================================================================
+
+Currently, Bazaar stores its configuration files and plugins under the
+directory ~/.bazaar on unix installs. On Windows, this is
+%APPDATA%/Bazaar/2.0 and on Mac OS X, the directory is ~/.bazaar. With the
+XDG Base Directory specification
+(http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html), many
+Linux and Unix platforms have tried to centralize configuration files under a
+specific directory referred to as $XDG_CONFIG_HOME. This has a default value
+of ~/.config.
+
+Bazaar would like to be a good Unix citizen by using these standard locations
+for configuration files. As such, we should support that location, but not
+require it. Note that the following descriptions do not apply
+to Windows or Mac OS X which should use their own native configuration
+locations. (On Windows, we currently do this by working under %APPDATA%. The
+Mac OS X equivalent would be ~/Library/Application Support/Bazaar but there is
+also cultural support for ~/.bazaar on that platform.)
+
+* If $XDG_CONFIG_HOME/bazaar exists, use the files there for configuration,
+ noting in the log that we are doing so. This allows individuals who would
+ like to use the XDG specification to do so.
+* Due to a lack of consensus on where plugins should live under the XDG Base
+ Directory spec, continue to look for plugins in ~/.bazaar/plugins. To
+ change this directory to something not under ~/.bazaar, use the environment
+ variable $BZR_PLUGIN_PATH.
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt 2010-11-26 15:57:20 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt 2010-11-29 01:23:53 +0000
@@ -39,6 +39,9 @@
number of remaining conflicts. This provides a better feedback about the
whole resolution process. (Vincent Ladeuil)
+* Read configuration files in $XDG_CONFIG_HOME/bazaar on Unix if there is
+ already a directory there. (Neil Martinsen-Burrell, #195397)
+
Bug Fixes
*********
=== modified file 'doc/en/whats-new/whats-new-in-2.3.txt'
--- a/doc/en/whats-new/whats-new-in-2.3.txt 2010-11-22 03:35:24 +0000
+++ b/doc/en/whats-new/whats-new-in-2.3.txt 2010-11-29 01:23:53 +0000
@@ -38,6 +38,13 @@
get the old behavior, one can use ``bzr tags --sort=alpha``.
(Neil Martinsen-Burrell, #640760)
+* On platforms other than Windows and Mac OS X, Bazaar will use configuration
+ files that live in $XDG_CONFIG_HOME/bazaar if that directory exists. This
+ allows interested individuals to conform to the XDG Base Directory
+ specification. The plugin location has not changed and is still
+ ~/.bazaar/plugins. To use a different directory for plugins, use the
+ environment variable BZR_PLUGIN_PATH. (Neil Martinsen-Burrell, #195397)
+
Launchpad integration
*********************
More information about the bazaar-commits
mailing list