Support set_user_option() on Subversion branch BranchConfig.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 12 Apr 2008 15:23:48 +0000 (17:23 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 12 Apr 2008 15:23:48 +0000 (17:23 +0200)
NEWS
config.py
tests/test_config.py

diff --git a/NEWS b/NEWS
index 3feac71eb4c86e2c2dc02524914b429b5f3d4592..e2c0ed8c98045d92eb00fbfa908ee2b284405191 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,8 @@ bzr-svn 0.4.10  UNRELEASED
 
    * Use different cache for experimental versions of bzr-svn.
 
 
    * Use different cache for experimental versions of bzr-svn.
 
+   * Support set_user_option() on Subversion branch BranchConfig. (#195962)
+
   INTERNALS
 
    * Branching from a Subversion repository will now fetch right-hand side 
   INTERNALS
 
    * Branching from a Subversion repository will now fetch right-hand side 
index a15707c10c21726742b1674bf7088f2b67bd54df..987bba43ee90dd0429b46e0c3c6daddaf621ea66 100644 (file)
--- a/config.py
+++ b/config.py
@@ -15,8 +15,8 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """Stores per-repository settings."""
 
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 """Stores per-repository settings."""
 
-from bzrlib import osutils, urlutils
-from bzrlib.config import IniBasedConfig, config_dir, ensure_config_dir_exists, GlobalConfig, LocationConfig, Config
+from bzrlib import osutils, urlutils, trace
+from bzrlib.config import IniBasedConfig, config_dir, ensure_config_dir_exists, GlobalConfig, LocationConfig, Config, STORE_BRANCH, STORE_GLOBAL, STORE_LOCATION
 
 import os
 
 
 import os
 
@@ -212,3 +212,26 @@ class BranchConfig(Config):
             except svn.core.SubversionException:
                 return None
         return None
             except svn.core.SubversionException:
                 return None
         return None
+
+    def set_user_option(self, name, value, store=STORE_LOCATION,
+        warn_masked=False):
+        if store == STORE_GLOBAL:
+            self._get_global_config().set_user_option(name, value)
+        elif store == STORE_BRANCH:
+            raise NotImplementedError("Saving in branch config not supported for Subversion branches")
+        else:
+            self._get_location_config().set_user_option(name, value, store)
+        if not warn_masked:
+            return
+        if store in (STORE_GLOBAL, STORE_BRANCH):
+            mask_value = self._get_location_config().get_user_option(name)
+            if mask_value is not None:
+                trace.warning('Value "%s" is masked by "%s" from'
+                              ' locations.conf', value, mask_value)
+            else:
+                if store == STORE_GLOBAL:
+                    branch_config = self._get_branch_data_config()
+                    mask_value = branch_config.get_user_option(name)
+                    if mask_value is not None:
+                        trace.warning('Value "%s" is masked by "%s" from'
+                                      ' branch.conf', value, mask_value)
index 55b7f95186079c588b124097825719b6d07dfee5..58a199b7fd40dba11f5b5a0f52ba074b8459e8e0 100644 (file)
 
 """Config tests."""
 
 
 """Config tests."""
 
-from config import SvnRepositoryConfig
+from bzrlib.branch import Branch
+from config import SvnRepositoryConfig, BranchConfig
 from scheme import TrunkBranchingScheme
 from scheme import TrunkBranchingScheme
+from tests import TestCaseWithSubversionRepository
 
 from bzrlib.tests import TestCaseInTempDir
 
 
 from bzrlib.tests import TestCaseInTempDir
 
@@ -101,3 +103,16 @@ class ReposConfigTests(TestCaseInTempDir):
         self.assertEquals(True, c.get_supports_change_revprop())
         c.set_user_option("supports-change-revprop", "False")
         self.assertEquals(False, c.get_supports_change_revprop())
         self.assertEquals(True, c.get_supports_change_revprop())
         c.set_user_option("supports-change-revprop", "False")
         self.assertEquals(False, c.get_supports_change_revprop())
+
+
+class BranchConfigTests(TestCaseWithSubversionRepository):
+    def setUp(self):
+        super(BranchConfigTests, self).setUp()
+        self.repos_url = self.make_client("d", "dc")
+        self.config = BranchConfig(Branch.open(self.repos_url))
+
+    def test_set_option(self):
+        self.config.set_user_option("append_revisions_only", "True")
+        self.assertEquals("True", self.config.get_user_option("append_revisions_only"))
+
+