Merge lp:~vila/bzr/missing-stacks into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6092
Proposed branch: lp:~vila/bzr/missing-stacks
Merge into: lp:bzr
Diff against target: 129 lines (+56/-2)
3 files modified
bzrlib/config.py (+34/-0)
bzrlib/lock.py (+1/-1)
bzrlib/tests/test_config.py (+21/-1)
To merge this branch: bzr merge lp:~vila/bzr/missing-stacks
Reviewer Review Type Date Requested Status
Jonathan Riddell (community) Approve
Review via email: mp+71918@code.launchpad.net

Commit message

Add missing config store and stacks for control.conf and remote branches.

Description of the change

One store was missing for the stealth 'control.conf'.

This patch adds it as well as the missing stacks:

- control.conf gets its own stack as it seems to me it needs to
  be used in isolation (it contains only default_stacked_on anyway),

- remote branches needs a special stack because they ignore
  bazaar.conf and locations.conf (both locally and remotely).

To post a comment you must log in.
Revision history for this message
Jonathan Riddell (jr) wrote :

Fine but I'd like to see docstrings on the new classes

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/17/2011 6:20 PM, Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/missing-stacks
> into lp:bzr.
>
> Requested reviews: bzr-core (bzr-core)
>
> For more details, see:
> https://code.launchpad.net/~vila/bzr/missing-stacks/+merge/71918
>
> One store was missing for the stealth 'control.conf'.
>
> This patch adds it as well as the missing stacks:
>
> - control.conf gets its own stack as it seems to me it needs to be
> used in isolation (it contains only default_stacked_on anyway),
>
> - remote branches needs a special stack because they ignore
> bazaar.conf and locations.conf (both locally and remotely).

How do you mean they ignore bazaar.conf and locations.conf? I've
certainly set

 [bzr+ssh://host/path/to/branch]
 public_location = http://host/branch

In the past. That may not be working now, or whatever. But since
locations.conf exists to be able to override configuration settings
for remote branches, explicitly ignoring them seems really odd.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5Ux2oACgkQJdeBCYSNAAOyGgCeNviSyq0Zn3D0RV3m8tbiRUnV
500An08s/B80abXa55iv32zZ7NE7ILk9
=2d+D
-----END PGP SIGNATURE-----

Revision history for this message
Vincent Ladeuil (vila) wrote :

As mentioned on IRC: this reflects actual usage in code not a change in behaviour.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/config.py'
2--- bzrlib/config.py 2011-08-21 15:14:57 +0000
3+++ bzrlib/config.py 2011-08-22 07:55:59 +0000
4@@ -2812,6 +2812,14 @@
5 super(BranchStore, self).save()
6
7
8+class ControlStore(LockableIniFileStore):
9+
10+ def __init__(self, bzrdir):
11+ super(ControlStore, self).__init__(bzrdir.transport,
12+ 'control.conf',
13+ lock_dir_name='branch_lock')
14+
15+
16 class SectionMatcher(object):
17 """Select sections into a given Store.
18
19@@ -3048,6 +3056,7 @@
20
21
22 class GlobalStack(_CompatibleStack):
23+ """Global options only stack."""
24
25 def __init__(self):
26 # Get a GlobalStore
27@@ -3056,6 +3065,7 @@
28
29
30 class LocationStack(_CompatibleStack):
31+ """Per-location options falling back to global options stack."""
32
33 def __init__(self, location):
34 """Make a new stack for a location and global configuration.
35@@ -3067,7 +3077,9 @@
36 super(LocationStack, self).__init__(
37 [matcher.get_sections, gstore.get_sections], lstore)
38
39+
40 class BranchStack(_CompatibleStack):
41+ """Per-location options falling back to branch then global options stack."""
42
43 def __init__(self, branch):
44 bstore = BranchStore(branch)
45@@ -3080,6 +3092,28 @@
46 self.branch = branch
47
48
49+class RemoteControlStack(_CompatibleStack):
50+ """Remote control-only options stack."""
51+
52+ def __init__(self, bzrdir):
53+ cstore = ControlStore(bzrdir)
54+ super(RemoteControlStack, self).__init__(
55+ [cstore.get_sections],
56+ cstore)
57+ self.bzrdir = bzrdir
58+
59+
60+class RemoteBranchStack(_CompatibleStack):
61+ """Remote branch-only options stack."""
62+
63+ def __init__(self, branch):
64+ bstore = BranchStore(branch)
65+ super(RemoteBranchStack, self).__init__(
66+ [bstore.get_sections],
67+ bstore)
68+ self.branch = branch
69+
70+
71 class cmd_config(commands.Command):
72 __doc__ = """Display, set or remove a configuration option.
73
74
75=== modified file 'bzrlib/lock.py'
76--- bzrlib/lock.py 2011-06-28 21:47:24 +0000
77+++ bzrlib/lock.py 2011-08-22 07:55:59 +0000
78@@ -535,7 +535,7 @@
79 locked the same way), and -Drelock is set, then this will trace.note a
80 message about it.
81 """
82-
83+
84 _prev_lock = None
85
86 def _note_lock(self, lock_type):
87
88=== modified file 'bzrlib/tests/test_config.py'
89--- bzrlib/tests/test_config.py 2011-08-21 15:14:57 +0000
90+++ bzrlib/tests/test_config.py 2011-08-22 07:55:59 +0000
91@@ -116,6 +116,13 @@
92 config.test_store_builder_registry.register('branch', build_branch_store)
93
94
95+def build_control_store(test):
96+ build_backing_branch(test, 'branch')
97+ b = bzrdir.BzrDir.open('branch')
98+ return config.ControlStore(b)
99+config.test_store_builder_registry.register('control', build_control_store)
100+
101+
102 def build_remote_branch_store(test):
103 # There is only one permutation (but we won't be able to handle more with
104 # this design anyway)
105@@ -148,10 +155,23 @@
106 server_class) = transport_remote.get_test_permutations()[0]
107 build_backing_branch(test, 'branch', transport_class, server_class)
108 b = branch.Branch.open(test.get_url('branch'))
109- return config.BranchStack(b)
110+ return config.RemoteBranchStack(b)
111 config.test_stack_builder_registry.register('remote_branch',
112 build_remote_branch_stack)
113
114+def build_remote_control_stack(test):
115+ # There is only one permutation (but we won't be able to handle more with
116+ # this design anyway)
117+ (transport_class,
118+ server_class) = transport_remote.get_test_permutations()[0]
119+ # We need only a bzrdir for this, not a full branch, but it's not worth
120+ # creating a dedicated helper to create only the bzrdir
121+ build_backing_branch(test, 'branch', transport_class, server_class)
122+ b = branch.Branch.open(test.get_url('branch'))
123+ return config.RemoteControlStack(b.bzrdir)
124+config.test_stack_builder_registry.register('remote_control',
125+ build_remote_control_stack)
126+
127
128 sample_long_alias="log -r-15..-1 --line"
129 sample_config_text = u"""