Rev 6470: (gz) Make config.config_dir and related functions consistenly return unicode in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Feb 2 14:44:02 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/
------------------------------------------------------------
revno: 6470 [merge]
revision-id: pqm at pqm.ubuntu.com-20120202144401-4mpclwk81vmy8coe
parent: pqm at pqm.ubuntu.com-20120201174155-pjv6onozsfu709jg
parent: martin.packman at canonical.com-20120201170527-k2zjpg0x70i5zweg
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.5
timestamp: Thu 2012-02-02 14:44:01 +0000
message:
(gz) Make config.config_dir and related functions consistenly return unicode
(Martin Packman)
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2012-01-20 13:21:01 +0000
+++ b/bzrlib/config.py 2012-02-01 17:02:56 +0000
@@ -1524,7 +1524,7 @@
def config_dir():
- """Return per-user configuration directory.
+ """Return per-user configuration directory as unicode string
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,
@@ -1532,42 +1532,28 @@
TODO: Global option --config-dir to override this.
"""
- base = os.environ.get('BZR_HOME', None)
+ base = osutils.path_from_environ('BZR_HOME')
if sys.platform == 'win32':
- # environ variables on Windows are in user encoding/mbcs. So decode
- # before using one
- if base is not None:
- base = base.decode('mbcs')
- if base is None:
- base = win32utils.get_appdata_location_unicode()
- if base is None:
- base = os.environ.get('HOME', None)
- if base is not None:
- base = base.decode('mbcs')
- if base is None:
- raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
- ' or HOME set')
+ if base is None:
+ base = win32utils.get_appdata_location()
+ if base is None:
+ base = win32utils.get_home_location()
+ # GZ 2012-02-01: Really the two level subdirs only make sense inside
+ # APPDATA, but hard to move. See bug 348640 for more.
return osutils.pathjoin(base, 'bazaar', '2.0')
- else:
- if base is not None:
- base = base.decode(osutils._fs_enc)
- if 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 base is None:
+ # GZ 2012-02-01: What should OSX use instead of XDG if anything?
+ if sys.platform != 'darwin':
+ xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
if xdg_dir is None:
- xdg_dir = osutils.pathjoin(os.path.expanduser("~"), ".config")
+ xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".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")
+ base = osutils._get_home_dir()
+ return osutils.pathjoin(base, ".bazaar")
def config_filename():
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2012-01-09 12:20:41 +0000
+++ b/bzrlib/tests/test_config.py 2012-02-01 17:02:56 +0000
@@ -576,6 +576,9 @@
def test_config_dir(self):
self.assertEqual(config.config_dir(), self.bzr_home)
+ def test_config_dir_is_unicode(self):
+ self.assertIsInstance(config.config_dir(), unicode)
+
def test_config_filename(self):
self.assertEqual(config.config_filename(),
self.bzr_home + '/bazaar.conf')
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2012-02-01 17:41:55 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2012-02-02 14:44:01 +0000
@@ -90,6 +90,9 @@
.. Changes that may require updates in plugins or other code that uses
bzrlib.
+* ``config.config_dir`` and related functions now always return paths as
+ unicode. (Martin Packman, #825826)
+
* ``ControlDir`` now has a new method ``set_branch_reference`` which can
be used for setting branch references. (Jelmer Vernooij)
More information about the bazaar-commits
mailing list