Rev 6399: (vila) Migrate branch location options to config stacks. (Vincent Ladeuil) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 21 18:45:15 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6399 [merge]
revision-id: pqm at pqm.ubuntu.com-20111221184514-3hi4afgkekoz1uxf
parent: pqm at pqm.ubuntu.com-20111221182031-9gf8hr07o64jddxb
parent: v.ladeuil+lp at free.fr-20111221175320-fd0yu40ksjj44n60
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-12-21 18:45:14 +0000
message:
(vila) Migrate branch location options to config stacks. (Vincent Ladeuil)
modified:
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/test_branch.py test_branch.py-20060116013032-97819aa07b8ab3b5
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2011-12-19 11:49:56 +0000
+++ b/bzrlib/branch.py 2011-12-21 17:53:20 +0000
@@ -1169,18 +1169,20 @@
def _set_config_location(self, name, url, config=None,
make_relative=False):
if config is None:
- config = self.get_config()
+ config = self.get_config_stack()
if url is None:
url = ''
elif make_relative:
url = urlutils.relative_url(self.base, url)
- config.set_user_option(name, url, warn_masked=True)
+ config.set(name, url)
def _get_config_location(self, name, config=None):
if config is None:
- config = self.get_config()
- location = config.get_user_option(name)
- if location == '':
+ config = self.get_config_stack()
+ location = config.get(name)
+ # FIXME: There is a glitch around quoting/unquoting in config stores:
+ # an empty string can be seen as '""' instead of '' -- vila 2011-12-20
+ if location in ('', '""') :
location = None
return location
@@ -2967,28 +2969,27 @@
"""See Branch.set_push_location."""
self._master_branch_cache = None
result = None
- config = self.get_config()
+ conf = self.get_config_stack()
if location is None:
- if config.get_user_option('bound') != 'True':
+ if not conf.get('bound'):
return False
else:
- config.set_user_option('bound', 'False', warn_masked=True)
+ conf.set('bound', 'False')
return True
else:
self._set_config_location('bound_location', location,
- config=config)
- config.set_user_option('bound', 'True', warn_masked=True)
+ config=conf)
+ conf.set('bound', 'True')
return True
def _get_bound_location(self, bound):
"""Return the bound location in the config file.
Return None if the bound parameter does not match"""
- config = self.get_config()
- config_bound = (config.get_user_option('bound') == 'True')
- if config_bound != bound:
+ conf = self.get_config_stack()
+ if conf.get('bound') != bound:
return None
- return self._get_config_location('bound_location', config=config)
+ return self._get_config_location('bound_location', config=conf)
def get_bound_location(self):
"""See Branch.set_push_location."""
@@ -3004,9 +3005,9 @@
## self._check_stackable_repo()
# stacked_on_location is only ever defined in branch.conf, so don't
# waste effort reading the whole stack of config files.
- config = self.get_config()._get_branch_data_config()
+ conf = _mod_config.BranchOnlyStack(self)
stacked_url = self._get_config_location('stacked_on_location',
- config=config)
+ config=conf)
if stacked_url is None:
raise errors.NotStacked(self)
return stacked_url
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-12-21 14:25:26 +0000
+++ b/bzrlib/config.py 2011-12-21 17:53:20 +0000
@@ -2506,7 +2506,6 @@
_list_converter_config.reset()
_list_converter_config._parse([u"list=%s" % (unicode_str,)])
maybe_list = _list_converter_config['list']
- # ConfigObj return '' instead of u''. Use 'str' below to catch all cases.
if isinstance(maybe_list, basestring):
if maybe_list:
# A single value, most probably the user forgot (or didn't care to
@@ -2591,6 +2590,27 @@
A negative value means disable the size check.
"""))
option_registry.register(
+ Option('bound',
+ default=None, from_unicode=bool_from_store,
+ help="""\
+Is the branch bound to ``bound_location``.
+
+If set to "True", the branch should act as a checkout, and push each commit to
+the bound_location. This option is normally set by ``bind``/``unbind``.
+
+See also: bound_location.
+"""))
+option_registry.register(
+ Option('bound_location',
+ default=None,
+ help="""\
+The location that commits should go to when acting as a checkout.
+
+This option is normally set by ``bind``.
+
+See also: bound.
+"""))
+option_registry.register(
Option('bzr.workingtree.worth_saving_limit', default=10,
from_unicode=int_from_store, invalid='warning',
help='''\
@@ -2710,6 +2730,15 @@
help= 'Unicode encoding for output'
' (terminal encoding if not specified).'))
option_registry.register(
+ Option('parent_location',
+ default=None,
+ help="""\
+The location of the default branch for pull or merge.
+
+This option is normally set when creating a branch, the first ``pull`` or by
+``pull --remember``.
+"""))
+option_registry.register(
Option('post_commit', default=None,
help='''\
Post commit functions.
@@ -2719,6 +2748,23 @@
Each function takes branch, rev_id as parameters.
'''))
option_registry.register(
+ Option('public_branch',
+ default=None,
+ help="""\
+A publically-accessible version of this branch.
+
+This implies that the branch setting this option is not publically-accessible.
+Used and set by ``bzr send``.
+"""))
+option_registry.register(
+ Option('push_location',
+ default=None,
+ help="""\
+The location of the default branch for push.
+
+This option is normally set by the first ``push`` or ``push --remember``.
+"""))
+option_registry.register(
Option('push_strict', default=None,
from_unicode=bool_from_store,
help='''\
@@ -2757,7 +2803,7 @@
The default value for ``send --strict``.
If present, defines the ``--strict`` option default value for checking
-uncommitted changes before pushing.
+uncommitted changes before sending a bundle.
'''))
option_registry.register(
@@ -2765,6 +2811,19 @@
default=300.0, from_unicode=float_from_store,
help="If we wait for a new request from a client for more than"
" X seconds, consider the client idle, and hangup."))
+option_registry.register(
+ Option('stacked_on_location',
+ default=None,
+ help="""The location where this branch is stacked on."""))
+option_registry.register(
+ Option('submit_branch',
+ default=None,
+ help="""\
+The branch you intend to submit your current work to.
+
+This is automatically set by ``bzr send`` and ``bzr merge``, and is also used
+by the ``submit:`` revision spec.
+"""))
class Section(object):
@@ -3650,20 +3709,21 @@
self.bzrdir = bzrdir
-class RemoteBranchStack(_CompatibleStack):
- """Remote branch-only options stack."""
+class BranchOnlyStack(_CompatibleStack):
+ """Branch-only options stack."""
- # FIXME 2011-11-22 JRV This should probably be renamed to avoid confusion
- # with the stack used for remote branches. RemoteBranchStack only uses
- # branch.conf and is used only for the stack options.
+ # FIXME: _BranchOnlyStack only uses branch.conf and is used only for the
+ # stacked_on_location options waiting for http://pad.lv/832042 to be fixed.
+ # -- vila 2011-12-16
def __init__(self, branch):
bstore = branch._get_config_store()
- super(RemoteBranchStack, self).__init__(
+ super(BranchOnlyStack, self).__init__(
[NameMatcher(bstore, None).get_sections],
bstore)
self.branch = branch
+
# Use a an empty dict to initialize an empty configobj avoiding all
# parsing and encoding checks
_quoting_config = configobj.ConfigObj(
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2011-12-21 16:58:53 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2011-12-21 18:45:14 +0000
@@ -282,7 +282,7 @@
# being too low. If rpc_count increases, more network roundtrips have
# become necessary for this use case. Please do not adjust this number
# upwards without agreement from bzr's network support maintainers.
- self.assertLength(13, self.hpss_calls)
+ self.assertLength(14, self.hpss_calls)
remote = branch.Branch.open('public')
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2011-12-15 12:59:56 +0000
+++ b/bzrlib/tests/test_branch.py 2011-12-20 14:04:21 +0000
@@ -403,22 +403,6 @@
def test_light_checkout_with_references(self):
self.do_checkout_test(lightweight=True)
- def test_set_push(self):
- branch = self.make_branch('source', format=self.get_format_name())
- 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 TestBranch6(TestBranch67, tests.TestCaseWithTransport):
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-12-21 15:18:21 +0000
+++ b/bzrlib/tests/test_config.py 2011-12-21 17:53:20 +0000
@@ -145,16 +145,16 @@
config.test_stack_builder_registry.register('branch', build_branch_stack)
-def build_remote_branch_stack(test):
+def build_branch_only_stack(test):
# There is only one permutation (but we won't be able to handle more with
# this design anyway)
(transport_class,
server_class) = transport_remote.get_test_permutations()[0]
build_backing_branch(test, 'branch', transport_class, server_class)
b = branch.Branch.open(test.get_url('branch'))
- return config.RemoteBranchStack(b)
-config.test_stack_builder_registry.register('remote_branch',
- build_remote_branch_stack)
+ return config.BranchOnlyStack(b)
+config.test_stack_builder_registry.register('branch_only',
+ build_branch_only_stack)
def build_remote_control_stack(test):
# There is only one permutation (but we won't be able to handle more with
More information about the bazaar-commits
mailing list