Rev 5755: Rename store.set to store.set_option as it's clearer in this context and will act as a safe-guard against unintended uses (set() will be used for stacks). in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Apr 4 17:34:37 UTC 2011


At file:///home/vila/src/bzr/experimental/config/

------------------------------------------------------------
revno: 5755
revision-id: v.ladeuil+lp at free.fr-20110404173437-qksec0538jc7496g
parent: v.ladeuil+lp at free.fr-20110404165254-4r7a8mw4dzbu4mg8
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-store
timestamp: Mon 2011-04-04 19:34:37 +0200
message:
  Rename store.set to store.set_option as it's clearer in this context and will act as a safe-guard against unintended uses (set() will be used for stacks).
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-04-04 16:52:54 +0000
+++ b/bzrlib/config.py	2011-04-04 17:34:37 +0000
@@ -2048,6 +2048,9 @@
         """
         raise NotImplementedError(self.get_sections)
 
+    def set_option(self, name, value, section_name=None):
+        raise NotImplementedError(self.set_option)
+
 
 class ConfigObjStore(Store):
 
@@ -2109,6 +2112,8 @@
         out = StringIO()
         self._config_obj.write(out)
         self.transport.put_bytes(self.file_name, out.getvalue())
+        # We don't need the transient content anymore
+        self._content = None
 
     def get_sections(self):
         """Get the configobj section in the file order.
@@ -2123,7 +2128,7 @@
         for section_name in cobj.sections:
             yield section_name, dict(cobj[section_name])
 
-    def set(self, name, value, section_name=None):
+    def set_option(self, name, value, section_name=None):
         # We need a loaded store
         self.load()
         if section_name is None:

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-04-04 16:52:54 +0000
+++ b/bzrlib/tests/test_config.py	2011-04-04 17:34:37 +0000
@@ -1987,15 +1987,15 @@
                                    'qux': {'foo_in_qux': 'quux'}}),
                           sections[3])
 
-    def test_set_in_default_section(self):
+    def test_set_option_in_default_section(self):
         store = self.get_store('foo.conf', '')
-        store.set('foo', 'bar')
+        store.set_option('foo', 'bar')
         store.save()
         self.assertFileEqual('foo = bar\n', 'foo.conf')
 
-    def test_set_in_named_section(self):
+    def test_set_option_in_named_section(self):
         store = self.get_store('foo.conf', '')
-        store.set('foo', 'bar', 'baz')
+        store.set_option('foo', 'bar', 'baz')
         store.save()
         self.assertFileEqual('[baz]\nfoo = bar\n', 'foo.conf')
 



More information about the bazaar-commits mailing list