Rev 2589: Warn when setting config values that will be masked (#122286) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jul 5 02:55:50 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2589
revision-id: pqm at pqm.ubuntu.com-20070705015547-qyj4nsc5w3y53b4w
parent: pqm at pqm.ubuntu.com-20070705010427-0839hywgo4ioup2t
parent: aaron.bentley at utoronto.ca-20070705012321-nk0ej02hpmmpbwqw
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-07-05 02:55:47 +0100
message:
Warn when setting config values that will be masked (#122286)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_branch.py test_branch.py-20060116013032-97819aa07b8ab3b5
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.37
merged: aaron.bentley at utoronto.ca-20070705012321-nk0ej02hpmmpbwqw
parent: aaron.bentley at utoronto.ca-20070705012238-qijvh8pbcr1w0t5l
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: Aaron's mergeable stuff
timestamp: Wed 2007-07-04 21:23:21 -0400
message:
Don't treat a format string as a normal string
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.36
merged: aaron.bentley at utoronto.ca-20070705012238-qijvh8pbcr1w0t5l
parent: abentley at panoramicfeedback.com-20070704145353-x7dyeulxly2rosyi
parent: pqm at pqm.ubuntu.com-20070705010427-0839hywgo4ioup2t
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: Aaron's mergeable stuff
timestamp: Wed 2007-07-04 21:22:38 -0400
message:
Merge bzr.dev
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.35
merged: abentley at panoramicfeedback.com-20070704145353-x7dyeulxly2rosyi
parent: abentley at panoramicfeedback.com-20070704144945-xid3fviyyz77o949
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: Aaron's mergeable stuff
timestamp: Wed 2007-07-04 10:53:53 -0400
message:
Warn when setting config values that will be masked (#122286)
------------------------------------------------------------
revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.34
merged: abentley at panoramicfeedback.com-20070704144945-xid3fviyyz77o949
parent: abentley at panoramicfeedback.com-20070622152719-b843debqfvuykj0y
parent: pqm at pqm.ubuntu.com-20070704095320-41p0gvstimqqzvtx
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: Aaron's mergeable stuff
timestamp: Wed 2007-07-04 10:49:45 -0400
message:
Merge bzr.dev
=== modified file 'NEWS'
--- a/NEWS 2007-07-05 01:04:27 +0000
+++ b/NEWS 2007-07-05 01:22:38 +0000
@@ -30,6 +30,9 @@
* Don't use the '-f' strace option during tests.
(Vincent Ladeuil, #102019).
+ * Warn when setting ``push_location`` to a value that will be masked by
+ locations.conf. (Aaron Bentley, #122286)
+
IMPROVEMENTS:
* The --lsprof-file option now dumps a text rendering of the profiling
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2007-06-28 05:19:04 +0000
+++ b/bzrlib/branch.py 2007-07-04 14:53:53 +0000
@@ -172,7 +172,7 @@
return self.get_config().get_nickname()
def _set_nick(self, nick):
- self.get_config().set_user_option('nickname', nick)
+ self.get_config().set_user_option('nickname', nick, warn_masked=True)
nick = property(_get_nick, _set_nick)
@@ -584,7 +584,7 @@
url = ''
elif make_relative:
url = urlutils.relative_url(self.base, url)
- config.set_user_option(name, url)
+ config.set_user_option(name, url, warn_masked=True)
def _get_config_location(self, name, config=None):
if config is None:
@@ -610,7 +610,8 @@
pattern is that the user can override it by specifying a
location.
"""
- self.get_config().set_user_option('submit_branch', location)
+ self.get_config().set_user_option('submit_branch', location,
+ warn_masked=True)
def get_public_branch(self):
"""Return the public location of the branch.
@@ -2031,12 +2032,12 @@
if config.get_user_option('bound') != 'True':
return False
else:
- config.set_user_option('bound', 'False')
+ config.set_user_option('bound', 'False', warn_masked=True)
return True
else:
self._set_config_location('bound_location', location,
config=config)
- config.set_user_option('bound', 'True')
+ config.set_user_option('bound', 'True', warn_masked=True)
return True
def _get_bound_location(self, bound):
@@ -2062,7 +2063,8 @@
value = 'True'
else:
value = 'False'
- self.get_config().set_user_option('append_revisions_only', value)
+ self.get_config().set_user_option('append_revisions_only', value,
+ warn_masked=True)
def _get_append_revisions_only(self):
value = self.get_config().get_user_option('append_revisions_only')
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2007-06-18 20:39:06 +0000
+++ b/bzrlib/config.py 2007-07-05 01:23:21 +0000
@@ -77,6 +77,7 @@
errors,
osutils,
symbol_versioning,
+ trace,
urlutils,
win32utils,
)
@@ -639,13 +640,29 @@
return value
return None
- def set_user_option(self, name, value, store=STORE_BRANCH):
+ def set_user_option(self, name, value, store=STORE_BRANCH,
+ warn_masked=False):
if store == STORE_BRANCH:
self._get_branch_data_config().set_option(value, name)
elif store == STORE_GLOBAL:
self._get_global_config().set_user_option(name, value)
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)
+
def _gpg_signing_command(self):
"""See Config.gpg_signing_command."""
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2007-06-28 03:08:53 +0000
+++ b/bzrlib/tests/test_branch.py 2007-07-04 14:53:53 +0000
@@ -27,7 +27,9 @@
from bzrlib import (
branch as _mod_branch,
bzrdir,
+ config,
errors,
+ trace,
urlutils,
)
from bzrlib.branch import (
@@ -281,6 +283,22 @@
def test_light_checkout_with_references(self):
self.do_checkout_test(lightweight=True)
+ def test_set_push(self):
+ branch = self.make_branch('source', format='dirstate-tags')
+ branch.get_config().set_user_option('push_location', 'old',
+ store=config.STORE_LOCATION)
+ warnings = []
+ def warning(*args):
+ warnings.append(args[0] % args[1:])
+ _warning = trace.warning
+ trace.warning = warning
+ try:
+ branch.set_push_location('new')
+ finally:
+ trace.warning = _warning
+ self.assertEqual(warnings[0], 'Value "new" is masked by "old" from '
+ 'locations.conf')
+
class TestBranchReference(TestCaseWithTransport):
"""Tests for the branch reference facility."""
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2007-06-28 22:22:53 +0000
+++ b/bzrlib/tests/test_config.py 2007-07-04 14:53:53 +0000
@@ -28,6 +28,7 @@
errors,
osutils,
urlutils,
+ trace,
)
from bzrlib.branch import Branch
from bzrlib.bzrdir import BzrDir
@@ -413,6 +414,43 @@
b = self.make_branch('!repo')
self.assertEqual('!repo', b.get_config().get_nickname())
+ def test_warn_if_masked(self):
+ _warning = trace.warning
+ warnings = []
+ def warning(*args):
+ warnings.append(args[0] % args[1:])
+
+ def set_option(store, warn_masked=True):
+ warnings[:] = []
+ conf.set_user_option('example_option', repr(store), store=store,
+ warn_masked=warn_masked)
+ def assertWarning(warning):
+ if warning is None:
+ self.assertEqual(0, len(warnings))
+ else:
+ self.assertEqual(1, len(warnings))
+ self.assertEqual(warning, warnings[0])
+ trace.warning = warning
+ try:
+ branch = self.make_branch('.')
+ conf = branch.get_config()
+ set_option(config.STORE_GLOBAL)
+ assertWarning(None)
+ set_option(config.STORE_BRANCH)
+ assertWarning(None)
+ set_option(config.STORE_GLOBAL)
+ assertWarning('Value "4" is masked by "3" from branch.conf')
+ set_option(config.STORE_GLOBAL, warn_masked=False)
+ assertWarning(None)
+ set_option(config.STORE_LOCATION)
+ assertWarning(None)
+ set_option(config.STORE_BRANCH)
+ assertWarning('Value "3" is masked by "0" from locations.conf')
+ set_option(config.STORE_BRANCH, warn_masked=False)
+ assertWarning(None)
+ finally:
+ trace.warning = _warning
+
class TestGlobalConfigItems(TestCase):
@@ -776,7 +814,6 @@
self.my_location_config._get_option_policy(
'http://www.example.com/norecurse', 'normal_option'),
config.POLICY_NORECURSE)
-
def test_post_commit_default(self):
self.get_branch_config('/a/c')
More information about the bazaar-commits
mailing list