Merge lp:~vila/bzr/1331999-test-config-warnings into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Richard Wilbur
Approved revision: no longer in the source branch.
Merged at revision: 6598
Proposed branch: lp:~vila/bzr/1331999-test-config-warnings
Merge into: lp:bzr
Diff against target: 44 lines (+9/-1)
2 files modified
bzrlib/config.py (+4/-1)
doc/en/release-notes/bzr-2.7.txt (+5/-0)
To merge this branch: bzr merge lp:~vila/bzr/1331999-test-config-warnings
Reviewer Review Type Date Requested Status
Richard Wilbur Approve
Review via email: mp+223701@code.launchpad.net

Commit message

Bzr config should save the changes explicitly when needed

Description of the change

An atexit handler is used to make bzrlib.config easier for users and save changes in any config store.

This has an side-effect for some blackbox tests and leads to warnings to stderr. It has recently been causing issues with autopkgtest.

Reproduced with:

$ ./bzr selftest -s bt.test_config -s bb.test_config
bzr selftest: /home/vila/src/bzr/bugs/1331999-test-config-warnings/bzr
   /home/vila/src/bzr/bugs/1331999-test-config-warnings/bzrlib
   bzr-2.7.0dev1 python-2.7.6 Linux-3.13.0-29-generic-x86_64-with-Ubuntu-14.04-trusty

----------------------------------------------------------------------
Ran 794 tests in 4.406s

OK
Option file in section /tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_branch_config_default/work/tree of file:///tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_branch_config_default/home/.bazaar/locations.conf was changed from locations to <CREATED>. The <DELETED> value will be saved.
Option file in section DEFAULT of file:///tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_bazaar_config_outside_branch/home/.bazaar/bazaar.conf was changed from bazaar to <CREATED>. The <DELETED> value will be saved.
Option file in section /tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_locations_config_inside_branch/work/tree of file:///tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_locations_config_inside_branch/home/.bazaar/locations.conf was changed from locations to <CREATED>. The <DELETED> value will be saved.
Option file in section /tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_branch_config_forcing_branch/work/tree of file:///tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_branch_config_forcing_branch/home/.bazaar/locations.conf was changed from locations to <CREATED>. The <DELETED> value will be saved.
Option file in section DEFAULT of file:///tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigRemoveOption.test_bazaar_config_inside_branch/home/.bazaar/bazaar.conf was changed from bazaar to <CREATED>. The <DELETED> value will be saved.
Option file in section /tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigActive.test_active_in_branch/work/tree of file:///tmp/testbzr-6xM4Mq.tmp/bzrlib.tests.blackbox.test_config.TestConfigActive.test_active_in_branch/home/.bazaar/locations.conf was changed from locations to <CREATED>. The <DELETED> value will be saved.

With this fix:

$ ./bzr selftest -s bt.test_config -s bb.test_config
bzr selftest: /home/vila/src/bzr/bugs/1331999-test-config-warnings/bzr
   /home/vila/src/bzr/bugs/1331999-test-config-warnings/bzrlib
   bzr-2.7.0dev1 python-2.7.6 Linux-3.13.0-29-generic-x86_64-with-Ubuntu-14.04-trusty

----------------------------------------------------------------------
Ran 794 tests in 4.705s

OK

To post a comment you must log in.
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Thanks Vincent, for the elegant fix!
+2
P.S. 'sections' looks like it was unused. Is that correct?

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

> Thanks Vincent, for the elegant fix!
> +2

Thanks ;)

> P.S. 'sections' looks like it was unused. Is that correct?

Yes.

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/config.py'
--- bzrlib/config.py 2014-02-14 10:29:49 +0000
+++ bzrlib/config.py 2014-06-19 09:58:21 +0000
@@ -3559,7 +3559,6 @@
3559 """3559 """
3560 location_parts = self.location.rstrip('/').split('/')3560 location_parts = self.location.rstrip('/').split('/')
3561 store = self.store3561 store = self.store
3562 sections = []
3563 # Later sections are more specific, they should be returned first3562 # Later sections are more specific, they should be returned first
3564 for _, section in reversed(list(store.get_sections())):3563 for _, section in reversed(list(store.get_sections())):
3565 if section.id is None:3564 if section.id is None:
@@ -4246,6 +4245,8 @@
4246 def _set_config_option(self, name, value, directory, scope):4245 def _set_config_option(self, name, value, directory, scope):
4247 conf = self._get_stack(directory, scope, write_access=True)4246 conf = self._get_stack(directory, scope, write_access=True)
4248 conf.set(name, value)4247 conf.set(name, value)
4248 # Explicitly save the changes
4249 conf.store.save_changes()
42494250
4250 def _remove_config_option(self, name, directory, scope):4251 def _remove_config_option(self, name, directory, scope):
4251 if name is None:4252 if name is None:
@@ -4254,6 +4255,8 @@
4254 conf = self._get_stack(directory, scope, write_access=True)4255 conf = self._get_stack(directory, scope, write_access=True)
4255 try:4256 try:
4256 conf.remove(name)4257 conf.remove(name)
4258 # Explicitly save the changes
4259 conf.store.save_changes()
4257 except KeyError:4260 except KeyError:
4258 raise errors.NoSuchConfigOption(name)4261 raise errors.NoSuchConfigOption(name)
42594262
42604263
=== modified file 'doc/en/release-notes/bzr-2.7.txt'
--- doc/en/release-notes/bzr-2.7.txt 2014-05-07 22:20:27 +0000
+++ doc/en/release-notes/bzr-2.7.txt 2014-06-19 09:58:21 +0000
@@ -72,6 +72,11 @@
72 suite. This can include new facilities for writing tests, fixes to 72 suite. This can include new facilities for writing tests, fixes to
73 spurious test failures and changes to the way things should be tested.73 spurious test failures and changes to the way things should be tested.
7474
75* Fix warnings on stderr caused by the atexit handler triggering for the
76 wrong reason: the 'config' command should explicitly save the changes when
77 modifying or removing an option and not rely on the atexit
78 handler. (Vincent Ladeuil, #1331999)
79
75* Handle (minor) incompatible change in python 2.7.6 leading to test80* Handle (minor) incompatible change in python 2.7.6 leading to test
76 failures. Only tests are affected. (Vincent Ladeuil, #1303879)81 failures. Only tests are affected. (Vincent Ladeuil, #1303879)
7782