Rev 5362: Use _save=True for config objects that needs disk backup. in file:///home/vila/src/bzr/bugs/525571-lock-bazaar-conf-files/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Jul 22 07:53:03 BST 2010
At file:///home/vila/src/bzr/bugs/525571-lock-bazaar-conf-files/
------------------------------------------------------------
revno: 5362
revision-id: v.ladeuil+lp at free.fr-20100722065302-e9x2ij9o4ribaxzn
parent: v.ladeuil+lp at free.fr-20100721174302-g9rsvkujz2vn6fp3
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: further-cleanups
timestamp: Thu 2010-07-22 08:53:02 +0200
message:
Use _save=True for config objects that needs disk backup.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2010-07-21 17:43:02 +0000
+++ b/bzrlib/config.py 2010-07-22 06:53:02 +0000
@@ -529,9 +529,9 @@
class GlobalConfig(IniBasedConfig):
"""The configuration that should be used for a specific location."""
- def __init__(self, _content=None):
+ def __init__(self, _content=None, _save=False):
super(GlobalConfig, self).__init__(file_name=config_filename(),
- _content=_content)
+ _content=_content, _save=_save)
def get_editor(self):
return self._get_user_option('editor')
@@ -571,10 +571,10 @@
class LocationConfig(IniBasedConfig):
"""A configuration object that gives the policy for a location."""
- def __init__(self, location, _content=None):
+ def __init__(self, location, _content=None, _save=False):
super(LocationConfig, self).__init__(
file_name=locations_config_filename(),
- _content=_content)
+ _content=_content, _save=_save)
# local file locations are looked up by local path, rather than
# by file url. This is because the config file is a user
# file, and we would rather not expose the user to file urls.
=== modified file 'bzrlib/tests/blackbox/test_aliases.py'
--- a/bzrlib/tests/blackbox/test_aliases.py 2010-07-21 17:31:03 +0000
+++ b/bzrlib/tests/blackbox/test_aliases.py 2010-07-22 06:53:02 +0000
@@ -35,12 +35,11 @@
return self.run_bzr(args, **kwargs)[1]
- conf = config.GlobalConfig(_content='''[ALIASES]
+ conf = config.GlobalConfig(_save=True,_content='''[ALIASES]
c=cat
c1=cat -r 1
c2=cat -r 1 -r2
''')
- conf._write_config_file()
str1 = 'foo\n'
str2 = 'bar\n'
=== modified file 'bzrlib/tests/blackbox/test_help.py'
--- a/bzrlib/tests/blackbox/test_help.py 2010-07-21 17:23:56 +0000
+++ b/bzrlib/tests/blackbox/test_help.py 2010-07-22 06:53:02 +0000
@@ -161,12 +161,10 @@
def test_help_with_aliases(self):
original = self.run_bzr('help cat')[0]
- content = '''[ALIASES]
+ conf = config.GlobalConfig(_save=True, _content='''[ALIASES]
c=cat
cat=cat
-'''
- conf = config.GlobalConfig(_content=content)
- conf._write_config_file()
+''')
expected = original + "'bzr cat' is an alias for 'bzr cat'.\n"
self.assertEqual(expected, self.run_bzr('help cat')[0])
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2010-07-21 16:50:08 +0000
+++ b/bzrlib/tests/test_branch.py 2010-07-22 06:53:02 +0000
@@ -86,8 +86,7 @@
self.assertIsDirectory('.bzr/branch/lock/held', t)
def test_set_push_location(self):
- conf = config.LocationConfig('.', _content='# comment\n')
- conf._write_config_file()
+ conf = config.LocationConfig('.', _content='# comment\n', _save=True)
branch = self.make_branch('.', format='knit')
branch.set_push_location('foo')
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2010-07-21 17:43:02 +0000
+++ b/bzrlib/tests/test_config.py 2010-07-22 06:53:02 +0000
@@ -560,9 +560,8 @@
local_url = urlutils.local_path_to_url('branch')
conf = config.LocationConfig(
- local_url,
+ local_url, _save=True,
_content=('[%s]\nnickname = foobar' % (local_url,)))
- conf._write_config_file()
self.assertEqual('foobar', branch.nick)
def test_config_local_path(self):
@@ -572,8 +571,8 @@
local_path = osutils.getcwd().encode('utf8')
conf = config.LocationConfig(
- 'branch', _content='[%s/branch]\nnickname = barry' % (local_path,))
- conf._write_config_file()
+ 'branch', _save=True,
+ _content='[%s/branch]\nnickname = barry' % (local_path,))
self.assertEqual('barry', branch.nick)
def test_config_creates_local(self):
=== modified file 'bzrlib/tests/test_debug.py'
--- a/bzrlib/tests/test_debug.py 2010-07-21 16:44:01 +0000
+++ b/bzrlib/tests/test_debug.py 2010-07-22 06:53:02 +0000
@@ -33,8 +33,7 @@
self.try_debug_flags(['hpss'], 'debug_flags = hpss\n')
def try_debug_flags(self, expected_flags, conf_bytes):
- conf = config.GlobalConfig(_content=conf_bytes)
- conf._write_config_file()
+ conf = config.GlobalConfig(_content=conf_bytes, _save=True)
self.overrideAttr(debug, 'debug_flags', set())
debug.set_debug_flags_from_config()
self.assertEqual(set(expected_flags), debug.debug_flags)
=== modified file 'bzrlib/tests/test_msgeditor.py'
--- a/bzrlib/tests/test_msgeditor.py 2010-07-21 17:19:27 +0000
+++ b/bzrlib/tests/test_msgeditor.py 2010-07-22 06:53:02 +0000
@@ -241,8 +241,8 @@
os.environ['VISUAL'] = 'visual'
os.environ['EDITOR'] = 'editor'
- conf = config.GlobalConfig(_content='editor = config_editor\n')
- conf._write_config_file()
+ conf = config.GlobalConfig(_content='editor = config_editor\n',
+ _save=True)
editors = list(msgeditor._get_editor())
editors = [editor for (editor, cfg_src) in editors]
More information about the bazaar-commits
mailing list