# 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
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)
"""Config tests."""
-from config import SvnRepositoryConfig
+from bzrlib.branch import Branch
+from config import SvnRepositoryConfig, BranchConfig
from scheme import TrunkBranchingScheme
+from tests import TestCaseWithSubversionRepository
from bzrlib.tests import 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())
+
+
+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"))
+
+