Status: | Merged |
---|---|
Approved by: | bzr PQM |
Approved revision: | not available |
Merged at revision: | not available |
Proposed branch: | lp:~mbp/bzr/components |
Merge into: | lp:bzr |
Diff against target: |
846 lines (+215/-94) 20 files modified
NEWS (+8/-0) bzrlib/branch.py (+32/-34) bzrlib/builtins.py (+1/-3) bzrlib/bzrdir.py (+57/-14) bzrlib/check.py (+3/-3) bzrlib/errors.py (+3/-3) bzrlib/info.py (+6/-7) bzrlib/reconcile.py (+1/-1) bzrlib/reconfigure.py (+5/-6) bzrlib/remote.py (+17/-4) bzrlib/repofmt/weaverepo.py (+1/-1) bzrlib/repository.py (+14/-7) bzrlib/smart/bzrdir.py (+1/-1) bzrlib/tests/per_branch/test_branch.py (+13/-0) bzrlib/tests/per_bzrdir/test_bzrdir.py (+12/-0) bzrlib/tests/per_repository/test_repository.py (+15/-0) bzrlib/tests/per_workingtree/test_workingtree.py (+13/-0) bzrlib/tests/test_foreign.py (+1/-0) bzrlib/upgrade.py (+2/-3) bzrlib/workingtree.py (+10/-7) |
To merge this branch: | bzr merge lp:~mbp/bzr/components |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
Andrew Bennetts | Approve | ||
Review via email: mp+23827@code.launchpad.net |
Commit message
(mbp) add ControlComponent base class
Description of the change
This adds a consistent interface for getting the control_transport and url (ie ends in .bzr/...) and the user_transport and url (doesn't) across branch, repository and bzrdir. At the moment there is some undesirable random variation across classes, and the names are not very obvious. This is a root cause behind us sometimes showing users urls containing .bzr when we don't really mean too.
I think those names are pretty clear but better suggestions are welcome.
As a followon I need to do this for wts but I thought I'd send this up to start with.
Andrew Bennetts (spiv) wrote : | # |
I know you want to do workingtrees before you land this, but also don't forget to write a NEWS entry.
Vincent Ladeuil (vila) wrote : | # |
Sounds good, please land.
bzr PQM (bzr-pqm) wrote : | # |
Successful steps
Failure output:
All lines of log output:
Executing star-merge http://
['Conflicts during merge: ', 'Text conflict in NEWS']
Preview Diff
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2010-04-27 18:09:12 +0000 | |||
3 | +++ NEWS 2010-04-28 07:06:33 +0000 | |||
4 | @@ -64,6 +64,14 @@ | |||
5 | 64 | API Changes | 64 | API Changes |
6 | 65 | *********** | 65 | *********** |
7 | 66 | 66 | ||
8 | 67 | * `BzrDir`, `Branch`, `Repository` and `WorkingTree` now all support `user_url`, | ||
9 | 68 | `user_transport`, `control_url` and `control_transport` members pointing | ||
10 | 69 | respectively to the directory containing the ``.bzr`` control directory, | ||
11 | 70 | and to the directory within ``.bzr`` used for the particular component. | ||
12 | 71 | All of them inherit from `ControlComponent` which provides default | ||
13 | 72 | implementations. | ||
14 | 73 | (Martin Pool) | ||
15 | 74 | |||
16 | 67 | Internals | 75 | Internals |
17 | 68 | ********* | 76 | ********* |
18 | 69 | 77 | ||
19 | 70 | 78 | ||
20 | === modified file 'bzrlib/branch.py' | |||
21 | --- bzrlib/branch.py 2010-04-23 07:15:23 +0000 | |||
22 | +++ bzrlib/branch.py 2010-04-28 07:06:33 +0000 | |||
23 | @@ -63,23 +63,12 @@ | |||
24 | 63 | BZR_BRANCH_FORMAT_6 = "Bazaar Branch Format 6 (bzr 0.15)\n" | 63 | BZR_BRANCH_FORMAT_6 = "Bazaar Branch Format 6 (bzr 0.15)\n" |
25 | 64 | 64 | ||
26 | 65 | 65 | ||
40 | 66 | # TODO: Maybe include checks for common corruption of newlines, etc? | 66 | class Branch(bzrdir.ControlComponent): |
28 | 67 | |||
29 | 68 | # TODO: Some operations like log might retrieve the same revisions | ||
30 | 69 | # repeatedly to calculate deltas. We could perhaps have a weakref | ||
31 | 70 | # cache in memory to make this faster. In general anything can be | ||
32 | 71 | # cached in memory between lock and unlock operations. .. nb thats | ||
33 | 72 | # what the transaction identity map provides | ||
34 | 73 | |||
35 | 74 | |||
36 | 75 | ###################################################################### | ||
37 | 76 | # branch objects | ||
38 | 77 | |||
39 | 78 | class Branch(object): | ||
41 | 79 | """Branch holding a history of revisions. | 67 | """Branch holding a history of revisions. |
42 | 80 | 68 | ||
45 | 81 | base | 69 | :ivar base: |
46 | 82 | Base directory/url of the branch. | 70 | Base directory/url of the branch; using control_url and |
47 | 71 | control_transport is more standardized. | ||
48 | 83 | 72 | ||
49 | 84 | hooks: An instance of BranchHooks. | 73 | hooks: An instance of BranchHooks. |
50 | 85 | """ | 74 | """ |
51 | @@ -87,6 +76,14 @@ | |||
52 | 87 | # - RBC 20060112 | 76 | # - RBC 20060112 |
53 | 88 | base = None | 77 | base = None |
54 | 89 | 78 | ||
55 | 79 | @property | ||
56 | 80 | def control_transport(self): | ||
57 | 81 | return self._transport | ||
58 | 82 | |||
59 | 83 | @property | ||
60 | 84 | def user_transport(self): | ||
61 | 85 | return self.bzrdir.user_transport | ||
62 | 86 | |||
63 | 90 | def __init__(self, *ignored, **ignored_too): | 87 | def __init__(self, *ignored, **ignored_too): |
64 | 91 | self.tags = self._format.make_tags(self) | 88 | self.tags = self._format.make_tags(self) |
65 | 92 | self._revision_history_cache = None | 89 | self._revision_history_cache = None |
66 | @@ -107,7 +104,7 @@ | |||
67 | 107 | """Activate the branch/repository from url as a fallback repository.""" | 104 | """Activate the branch/repository from url as a fallback repository.""" |
68 | 108 | repo = self._get_fallback_repository(url) | 105 | repo = self._get_fallback_repository(url) |
69 | 109 | if repo.has_same_location(self.repository): | 106 | if repo.has_same_location(self.repository): |
71 | 110 | raise errors.UnstackableLocationError(self.base, url) | 107 | raise errors.UnstackableLocationError(self.user_url, url) |
72 | 111 | self.repository.add_fallback_repository(repo) | 108 | self.repository.add_fallback_repository(repo) |
73 | 112 | 109 | ||
74 | 113 | def break_lock(self): | 110 | def break_lock(self): |
75 | @@ -594,11 +591,11 @@ | |||
76 | 594 | :param other: The branch to bind to | 591 | :param other: The branch to bind to |
77 | 595 | :type other: Branch | 592 | :type other: Branch |
78 | 596 | """ | 593 | """ |
80 | 597 | raise errors.UpgradeRequired(self.base) | 594 | raise errors.UpgradeRequired(self.user_url) |
81 | 598 | 595 | ||
82 | 599 | def set_append_revisions_only(self, enabled): | 596 | def set_append_revisions_only(self, enabled): |
83 | 600 | if not self._format.supports_set_append_revisions_only(): | 597 | if not self._format.supports_set_append_revisions_only(): |
85 | 601 | raise errors.UpgradeRequired(self.base) | 598 | raise errors.UpgradeRequired(self.user_url) |
86 | 602 | if enabled: | 599 | if enabled: |
87 | 603 | value = 'True' | 600 | value = 'True' |
88 | 604 | else: | 601 | else: |
89 | @@ -652,7 +649,7 @@ | |||
90 | 652 | def get_old_bound_location(self): | 649 | def get_old_bound_location(self): |
91 | 653 | """Return the URL of the branch we used to be bound to | 650 | """Return the URL of the branch we used to be bound to |
92 | 654 | """ | 651 | """ |
94 | 655 | raise errors.UpgradeRequired(self.base) | 652 | raise errors.UpgradeRequired(self.user_url) |
95 | 656 | 653 | ||
96 | 657 | def get_commit_builder(self, parents, config=None, timestamp=None, | 654 | def get_commit_builder(self, parents, config=None, timestamp=None, |
97 | 658 | timezone=None, committer=None, revprops=None, | 655 | timezone=None, committer=None, revprops=None, |
98 | @@ -736,7 +733,7 @@ | |||
99 | 736 | stacking. | 733 | stacking. |
100 | 737 | """ | 734 | """ |
101 | 738 | if not self._format.supports_stacking(): | 735 | if not self._format.supports_stacking(): |
103 | 739 | raise errors.UnstackableBranchFormat(self._format, self.base) | 736 | raise errors.UnstackableBranchFormat(self._format, self.user_url) |
104 | 740 | # XXX: Changing from one fallback repository to another does not check | 737 | # XXX: Changing from one fallback repository to another does not check |
105 | 741 | # that all the data you need is present in the new fallback. | 738 | # that all the data you need is present in the new fallback. |
106 | 742 | # Possibly it should. | 739 | # Possibly it should. |
107 | @@ -893,7 +890,7 @@ | |||
108 | 893 | 890 | ||
109 | 894 | def unbind(self): | 891 | def unbind(self): |
110 | 895 | """Older format branches cannot bind or unbind.""" | 892 | """Older format branches cannot bind or unbind.""" |
112 | 896 | raise errors.UpgradeRequired(self.base) | 893 | raise errors.UpgradeRequired(self.user_url) |
113 | 897 | 894 | ||
114 | 898 | def last_revision(self): | 895 | def last_revision(self): |
115 | 899 | """Return last revision id, or NULL_REVISION.""" | 896 | """Return last revision id, or NULL_REVISION.""" |
116 | @@ -1059,7 +1056,7 @@ | |||
117 | 1059 | try: | 1056 | try: |
118 | 1060 | return urlutils.join(self.base[:-1], parent) | 1057 | return urlutils.join(self.base[:-1], parent) |
119 | 1061 | except errors.InvalidURLJoin, e: | 1058 | except errors.InvalidURLJoin, e: |
121 | 1062 | raise errors.InaccessibleParent(parent, self.base) | 1059 | raise errors.InaccessibleParent(parent, self.user_url) |
122 | 1063 | 1060 | ||
123 | 1064 | def _get_parent_location(self): | 1061 | def _get_parent_location(self): |
124 | 1065 | raise NotImplementedError(self._get_parent_location) | 1062 | raise NotImplementedError(self._get_parent_location) |
125 | @@ -1564,7 +1561,7 @@ | |||
126 | 1564 | elsewhere) | 1561 | elsewhere) |
127 | 1565 | :return: a branch in this format | 1562 | :return: a branch in this format |
128 | 1566 | """ | 1563 | """ |
130 | 1567 | mutter('creating branch %r in %s', self, a_bzrdir.transport.base) | 1564 | mutter('creating branch %r in %s', self, a_bzrdir.user_url) |
131 | 1568 | branch_transport = a_bzrdir.get_branch_transport(self, name=name) | 1565 | branch_transport = a_bzrdir.get_branch_transport(self, name=name) |
132 | 1569 | lock_map = { | 1566 | lock_map = { |
133 | 1570 | 'metadir': ('lock', lockdir.LockDir), | 1567 | 'metadir': ('lock', lockdir.LockDir), |
134 | @@ -1957,8 +1954,8 @@ | |||
135 | 1957 | if format.__class__ != self.__class__: | 1954 | if format.__class__ != self.__class__: |
136 | 1958 | raise AssertionError("wrong format %r found for %r" % | 1955 | raise AssertionError("wrong format %r found for %r" % |
137 | 1959 | (format, self)) | 1956 | (format, self)) |
138 | 1957 | transport = a_bzrdir.get_branch_transport(None, name=name) | ||
139 | 1960 | try: | 1958 | try: |
140 | 1961 | transport = a_bzrdir.get_branch_transport(None, name=name) | ||
141 | 1962 | control_files = lockable_files.LockableFiles(transport, 'lock', | 1959 | control_files = lockable_files.LockableFiles(transport, 'lock', |
142 | 1963 | lockdir.LockDir) | 1960 | lockdir.LockDir) |
143 | 1964 | return self._branch_class()(_format=self, | 1961 | return self._branch_class()(_format=self, |
144 | @@ -2162,10 +2159,10 @@ | |||
145 | 2162 | # this format does not implement branch itself, thus the implicit | 2159 | # this format does not implement branch itself, thus the implicit |
146 | 2163 | # creation contract must see it as uninitializable | 2160 | # creation contract must see it as uninitializable |
147 | 2164 | raise errors.UninitializableFormat(self) | 2161 | raise errors.UninitializableFormat(self) |
149 | 2165 | mutter('creating branch reference in %s', a_bzrdir.transport.base) | 2162 | mutter('creating branch reference in %s', a_bzrdir.user_url) |
150 | 2166 | branch_transport = a_bzrdir.get_branch_transport(self, name=name) | 2163 | branch_transport = a_bzrdir.get_branch_transport(self, name=name) |
151 | 2167 | branch_transport.put_bytes('location', | 2164 | branch_transport.put_bytes('location', |
153 | 2168 | target_branch.bzrdir.root_transport.base) | 2165 | target_branch.bzrdir.user_url) |
154 | 2169 | branch_transport.put_bytes('format', self.get_format_string()) | 2166 | branch_transport.put_bytes('format', self.get_format_string()) |
155 | 2170 | branch = self.open( | 2167 | branch = self.open( |
156 | 2171 | a_bzrdir, name, _found=True, | 2168 | a_bzrdir, name, _found=True, |
157 | @@ -2293,9 +2290,10 @@ | |||
158 | 2293 | 2290 | ||
159 | 2294 | def __str__(self): | 2291 | def __str__(self): |
160 | 2295 | if self.name is None: | 2292 | if self.name is None: |
162 | 2296 | return '%s(%r)' % (self.__class__.__name__, self.base) | 2293 | return '%s(%s)' % (self.__class__.__name__, self.user_url) |
163 | 2297 | else: | 2294 | else: |
165 | 2298 | return '%s(%r,%r)' % (self.__class__.__name__, self.base, self.name) | 2295 | return '%s(%s,%s)' % (self.__class__.__name__, self.user_url, |
166 | 2296 | self.name) | ||
167 | 2299 | 2297 | ||
168 | 2300 | __repr__ = __str__ | 2298 | __repr__ = __str__ |
169 | 2301 | 2299 | ||
170 | @@ -2516,7 +2514,7 @@ | |||
171 | 2516 | return result | 2514 | return result |
172 | 2517 | 2515 | ||
173 | 2518 | def get_stacked_on_url(self): | 2516 | def get_stacked_on_url(self): |
175 | 2519 | raise errors.UnstackableBranchFormat(self._format, self.base) | 2517 | raise errors.UnstackableBranchFormat(self._format, self.user_url) |
176 | 2520 | 2518 | ||
177 | 2521 | def set_push_location(self, location): | 2519 | def set_push_location(self, location): |
178 | 2522 | """See Branch.set_push_location.""" | 2520 | """See Branch.set_push_location.""" |
179 | @@ -2712,7 +2710,7 @@ | |||
180 | 2712 | if _mod_revision.is_null(last_revision): | 2710 | if _mod_revision.is_null(last_revision): |
181 | 2713 | return | 2711 | return |
182 | 2714 | if last_revision not in self._lefthand_history(revision_id): | 2712 | if last_revision not in self._lefthand_history(revision_id): |
184 | 2715 | raise errors.AppendRevisionsOnlyViolation(self.base) | 2713 | raise errors.AppendRevisionsOnlyViolation(self.user_url) |
185 | 2716 | 2714 | ||
186 | 2717 | def _gen_revision_history(self): | 2715 | def _gen_revision_history(self): |
187 | 2718 | """Generate the revision history from last revision | 2716 | """Generate the revision history from last revision |
188 | @@ -2818,7 +2816,7 @@ | |||
189 | 2818 | if branch_location is None: | 2816 | if branch_location is None: |
190 | 2819 | return Branch.reference_parent(self, file_id, path, | 2817 | return Branch.reference_parent(self, file_id, path, |
191 | 2820 | possible_transports) | 2818 | possible_transports) |
193 | 2821 | branch_location = urlutils.join(self.base, branch_location) | 2819 | branch_location = urlutils.join(self.user_url, branch_location) |
194 | 2822 | return Branch.open(branch_location, | 2820 | return Branch.open(branch_location, |
195 | 2823 | possible_transports=possible_transports) | 2821 | possible_transports=possible_transports) |
196 | 2824 | 2822 | ||
197 | @@ -2939,7 +2937,7 @@ | |||
198 | 2939 | """ | 2937 | """ |
199 | 2940 | 2938 | ||
200 | 2941 | def get_stacked_on_url(self): | 2939 | def get_stacked_on_url(self): |
202 | 2942 | raise errors.UnstackableBranchFormat(self._format, self.base) | 2940 | raise errors.UnstackableBranchFormat(self._format, self.user_url) |
203 | 2943 | 2941 | ||
204 | 2944 | 2942 | ||
205 | 2945 | ###################################################################### | 2943 | ###################################################################### |
206 | @@ -3032,7 +3030,7 @@ | |||
207 | 3032 | :param verbose: Requests more detailed display of what was checked, | 3030 | :param verbose: Requests more detailed display of what was checked, |
208 | 3033 | if any. | 3031 | if any. |
209 | 3034 | """ | 3032 | """ |
211 | 3035 | note('checked branch %s format %s', self.branch.base, | 3033 | note('checked branch %s format %s', self.branch.user_url, |
212 | 3036 | self.branch._format) | 3034 | self.branch._format) |
213 | 3037 | for error in self.errors: | 3035 | for error in self.errors: |
214 | 3038 | note('found error:%s', error) | 3036 | note('found error:%s', error) |
215 | @@ -3367,7 +3365,7 @@ | |||
216 | 3367 | if local and not bound_location: | 3365 | if local and not bound_location: |
217 | 3368 | raise errors.LocalRequiresBoundBranch() | 3366 | raise errors.LocalRequiresBoundBranch() |
218 | 3369 | master_branch = None | 3367 | master_branch = None |
220 | 3370 | if not local and bound_location and self.source.base != bound_location: | 3368 | if not local and bound_location and self.source.user_url != bound_location: |
221 | 3371 | # not pulling from master, so we need to update master. | 3369 | # not pulling from master, so we need to update master. |
222 | 3372 | master_branch = self.target.get_master_branch(possible_transports) | 3370 | master_branch = self.target.get_master_branch(possible_transports) |
223 | 3373 | master_branch.lock_write() | 3371 | master_branch.lock_write() |
224 | 3374 | 3372 | ||
225 | === modified file 'bzrlib/builtins.py' | |||
226 | --- bzrlib/builtins.py 2010-04-23 11:11:22 +0000 | |||
227 | +++ bzrlib/builtins.py 2010-04-28 07:06:33 +0000 | |||
228 | @@ -504,9 +504,7 @@ | |||
229 | 504 | if (working.has_changes()): | 504 | if (working.has_changes()): |
230 | 505 | raise errors.UncommittedChanges(working) | 505 | raise errors.UncommittedChanges(working) |
231 | 506 | 506 | ||
235 | 507 | working_path = working.bzrdir.root_transport.base | 507 | if working.user_url != working.branch.user_url: |
233 | 508 | branch_path = working.branch.bzrdir.root_transport.base | ||
234 | 509 | if working_path != branch_path: | ||
236 | 510 | raise errors.BzrCommandError("You cannot remove the working tree" | 508 | raise errors.BzrCommandError("You cannot remove the working tree" |
237 | 511 | " from a lightweight checkout") | 509 | " from a lightweight checkout") |
238 | 512 | 510 | ||
239 | 513 | 511 | ||
240 | === modified file 'bzrlib/bzrdir.py' | |||
241 | --- bzrlib/bzrdir.py 2010-04-22 17:08:27 +0000 | |||
242 | +++ bzrlib/bzrdir.py 2010-04-28 07:06:33 +0000 | |||
243 | @@ -86,9 +86,42 @@ | |||
244 | 86 | registry, | 86 | registry, |
245 | 87 | symbol_versioning, | 87 | symbol_versioning, |
246 | 88 | ) | 88 | ) |
250 | 89 | 89 | ||
251 | 90 | 90 | ||
252 | 91 | class BzrDir(object): | 91 | class ControlComponent(object): |
253 | 92 | """Abstract base class for control directory components. | ||
254 | 93 | |||
255 | 94 | This provides interfaces that are common across bzrdirs, | ||
256 | 95 | repositories, branches, and workingtree control directories. | ||
257 | 96 | |||
258 | 97 | They all expose two urls and transports: the *user* URL is the | ||
259 | 98 | one that stops above the control directory (eg .bzr) and that | ||
260 | 99 | should normally be used in messages, and the *control* URL is | ||
261 | 100 | under that in eg .bzr/checkout and is used to read the control | ||
262 | 101 | files. | ||
263 | 102 | |||
264 | 103 | This can be used as a mixin and is intended to fit with | ||
265 | 104 | foreign formats. | ||
266 | 105 | """ | ||
267 | 106 | |||
268 | 107 | @property | ||
269 | 108 | def control_transport(self): | ||
270 | 109 | raise NotImplementedError | ||
271 | 110 | |||
272 | 111 | @property | ||
273 | 112 | def control_url(self): | ||
274 | 113 | return self.control_transport.base | ||
275 | 114 | |||
276 | 115 | @property | ||
277 | 116 | def user_transport(self): | ||
278 | 117 | raise NotImplementedError | ||
279 | 118 | |||
280 | 119 | @property | ||
281 | 120 | def user_url(self): | ||
282 | 121 | return self.user_transport.base | ||
283 | 122 | |||
284 | 123 | |||
285 | 124 | class BzrDir(ControlComponent): | ||
286 | 92 | """A .bzr control diretory. | 125 | """A .bzr control diretory. |
287 | 93 | 126 | ||
288 | 94 | BzrDir instances let you create or open any of the things that can be | 127 | BzrDir instances let you create or open any of the things that can be |
289 | @@ -261,8 +294,8 @@ | |||
290 | 261 | # copied, and finally if we are copying up to a specific | 294 | # copied, and finally if we are copying up to a specific |
291 | 262 | # revision_id then we can use the pending-ancestry-result which | 295 | # revision_id then we can use the pending-ancestry-result which |
292 | 263 | # does not require traversing all of history to describe it. | 296 | # does not require traversing all of history to describe it. |
295 | 264 | if (result_repo.bzrdir.root_transport.base == | 297 | if (result_repo.user_url == result.user_url |
296 | 265 | result.root_transport.base and not require_stacking and | 298 | and not require_stacking and |
297 | 266 | revision_id is not None): | 299 | revision_id is not None): |
298 | 267 | fetch_spec = graph.PendingAncestryResult( | 300 | fetch_spec = graph.PendingAncestryResult( |
299 | 268 | [revision_id], local_repo) | 301 | [revision_id], local_repo) |
300 | @@ -458,7 +491,7 @@ | |||
301 | 458 | stop = False | 491 | stop = False |
302 | 459 | stack_on = config.get_default_stack_on() | 492 | stack_on = config.get_default_stack_on() |
303 | 460 | if stack_on is not None: | 493 | if stack_on is not None: |
305 | 461 | stack_on_pwd = found_bzrdir.root_transport.base | 494 | stack_on_pwd = found_bzrdir.user_url |
306 | 462 | stop = True | 495 | stop = True |
307 | 463 | # does it have a repository ? | 496 | # does it have a repository ? |
308 | 464 | try: | 497 | try: |
309 | @@ -466,8 +499,8 @@ | |||
310 | 466 | except errors.NoRepositoryPresent: | 499 | except errors.NoRepositoryPresent: |
311 | 467 | repository = None | 500 | repository = None |
312 | 468 | else: | 501 | else: |
315 | 469 | if ((found_bzrdir.root_transport.base != | 502 | if (found_bzrdir.user_url != self.user_url |
316 | 470 | self.root_transport.base) and not repository.is_shared()): | 503 | and not repository.is_shared()): |
317 | 471 | # Don't look higher, can't use a higher shared repo. | 504 | # Don't look higher, can't use a higher shared repo. |
318 | 472 | repository = None | 505 | repository = None |
319 | 473 | stop = True | 506 | stop = True |
320 | @@ -669,7 +702,7 @@ | |||
321 | 669 | if stop: | 702 | if stop: |
322 | 670 | return result | 703 | return result |
323 | 671 | next_transport = found_bzrdir.root_transport.clone('..') | 704 | next_transport = found_bzrdir.root_transport.clone('..') |
325 | 672 | if (found_bzrdir.root_transport.base == next_transport.base): | 705 | if (found_bzrdir.user_url == next_transport.base): |
326 | 673 | # top of the file system | 706 | # top of the file system |
327 | 674 | return None | 707 | return None |
328 | 675 | # find the next containing bzrdir | 708 | # find the next containing bzrdir |
329 | @@ -692,7 +725,7 @@ | |||
330 | 692 | repository = found_bzrdir.open_repository() | 725 | repository = found_bzrdir.open_repository() |
331 | 693 | except errors.NoRepositoryPresent: | 726 | except errors.NoRepositoryPresent: |
332 | 694 | return None, False | 727 | return None, False |
334 | 695 | if found_bzrdir.root_transport.base == self.root_transport.base: | 728 | if found_bzrdir.user_url == self.user_url: |
335 | 696 | return repository, True | 729 | return repository, True |
336 | 697 | elif repository.is_shared(): | 730 | elif repository.is_shared(): |
337 | 698 | return repository, True | 731 | return repository, True |
338 | @@ -814,9 +847,19 @@ | |||
339 | 814 | :param _transport: the transport this dir is based at. | 847 | :param _transport: the transport this dir is based at. |
340 | 815 | """ | 848 | """ |
341 | 816 | self._format = _format | 849 | self._format = _format |
342 | 850 | # these are also under the more standard names of | ||
343 | 851 | # control_transport and user_transport | ||
344 | 817 | self.transport = _transport.clone('.bzr') | 852 | self.transport = _transport.clone('.bzr') |
345 | 818 | self.root_transport = _transport | 853 | self.root_transport = _transport |
346 | 819 | self._mode_check_done = False | 854 | self._mode_check_done = False |
347 | 855 | |||
348 | 856 | @property | ||
349 | 857 | def user_transport(self): | ||
350 | 858 | return self.root_transport | ||
351 | 859 | |||
352 | 860 | @property | ||
353 | 861 | def control_transport(self): | ||
354 | 862 | return self.transport | ||
355 | 820 | 863 | ||
356 | 821 | def is_control_filename(self, filename): | 864 | def is_control_filename(self, filename): |
357 | 822 | """True if filename is the name of a path which is reserved for bzrdir's. | 865 | """True if filename is the name of a path which is reserved for bzrdir's. |
358 | @@ -2692,7 +2735,7 @@ | |||
359 | 2692 | if isinstance(self.bzrdir.transport, local.LocalTransport): | 2735 | if isinstance(self.bzrdir.transport, local.LocalTransport): |
360 | 2693 | self.bzrdir.get_workingtree_transport(None).delete('stat-cache') | 2736 | self.bzrdir.get_workingtree_transport(None).delete('stat-cache') |
361 | 2694 | self._convert_to_weaves() | 2737 | self._convert_to_weaves() |
363 | 2695 | return BzrDir.open(self.bzrdir.root_transport.base) | 2738 | return BzrDir.open(self.bzrdir.user_url) |
364 | 2696 | finally: | 2739 | finally: |
365 | 2697 | self.pb.finished() | 2740 | self.pb.finished() |
366 | 2698 | 2741 | ||
367 | @@ -2945,7 +2988,7 @@ | |||
368 | 2945 | try: | 2988 | try: |
369 | 2946 | ui.ui_factory.note('starting upgrade from format 5 to 6') | 2989 | ui.ui_factory.note('starting upgrade from format 5 to 6') |
370 | 2947 | self._convert_to_prefixed() | 2990 | self._convert_to_prefixed() |
372 | 2948 | return BzrDir.open(self.bzrdir.root_transport.base) | 2991 | return BzrDir.open(self.bzrdir.user_url) |
373 | 2949 | finally: | 2992 | finally: |
374 | 2950 | pb.finished() | 2993 | pb.finished() |
375 | 2951 | 2994 | ||
376 | @@ -3073,7 +3116,7 @@ | |||
377 | 3073 | BzrDirMetaFormat1().get_format_string(), | 3116 | BzrDirMetaFormat1().get_format_string(), |
378 | 3074 | mode=self.file_mode) | 3117 | mode=self.file_mode) |
379 | 3075 | self.pb.finished() | 3118 | self.pb.finished() |
381 | 3076 | return BzrDir.open(self.bzrdir.root_transport.base) | 3119 | return BzrDir.open(self.bzrdir.user_url) |
382 | 3077 | 3120 | ||
383 | 3078 | def make_lock(self, name): | 3121 | def make_lock(self, name): |
384 | 3079 | """Make a lock for the new control dir name.""" | 3122 | """Make a lock for the new control dir name.""" |
385 | @@ -3660,7 +3703,7 @@ | |||
386 | 3660 | try: | 3703 | try: |
387 | 3661 | stack_on = urlutils.rebase_url(self._stack_on, | 3704 | stack_on = urlutils.rebase_url(self._stack_on, |
388 | 3662 | self._stack_on_pwd, | 3705 | self._stack_on_pwd, |
390 | 3663 | branch.bzrdir.root_transport.base) | 3706 | branch.user_url) |
391 | 3664 | except errors.InvalidRebaseURLs: | 3707 | except errors.InvalidRebaseURLs: |
392 | 3665 | stack_on = self._get_full_stack_on() | 3708 | stack_on = self._get_full_stack_on() |
393 | 3666 | try: | 3709 | try: |
394 | 3667 | 3710 | ||
395 | === modified file 'bzrlib/check.py' | |||
396 | --- bzrlib/check.py 2009-09-18 01:06:10 +0000 | |||
397 | +++ bzrlib/check.py 2010-04-28 07:06:33 +0000 | |||
398 | @@ -192,8 +192,8 @@ | |||
399 | 192 | 192 | ||
400 | 193 | def _report_repo_results(self, verbose): | 193 | def _report_repo_results(self, verbose): |
401 | 194 | note('checked repository %s format %s', | 194 | note('checked repository %s format %s', |
404 | 195 | self.repository.bzrdir.root_transport, | 195 | self.repository.user_url, |
405 | 196 | self.repository._format) | 196 | self.repository._format) |
406 | 197 | note('%6d revisions', self.checked_rev_cnt) | 197 | note('%6d revisions', self.checked_rev_cnt) |
407 | 198 | note('%6d file-ids', len(self.checked_weaves)) | 198 | note('%6d file-ids', len(self.checked_weaves)) |
408 | 199 | if verbose: | 199 | if verbose: |
409 | @@ -451,7 +451,7 @@ | |||
410 | 451 | if do_repo or do_branch or do_tree: | 451 | if do_repo or do_branch or do_tree: |
411 | 452 | if do_repo: | 452 | if do_repo: |
412 | 453 | note("Checking repository at '%s'." | 453 | note("Checking repository at '%s'." |
414 | 454 | % (repo.bzrdir.root_transport.base,)) | 454 | % (repo.user_url,)) |
415 | 455 | result = repo.check(None, callback_refs=needed_refs, | 455 | result = repo.check(None, callback_refs=needed_refs, |
416 | 456 | check_repo=do_repo) | 456 | check_repo=do_repo) |
417 | 457 | result.report_results(verbose) | 457 | result.report_results(verbose) |
418 | 458 | 458 | ||
419 | === modified file 'bzrlib/errors.py' | |||
420 | --- bzrlib/errors.py 2010-03-24 14:15:01 +0000 | |||
421 | +++ bzrlib/errors.py 2010-04-28 07:06:33 +0000 | |||
422 | @@ -2176,7 +2176,7 @@ | |||
423 | 2176 | 2176 | ||
424 | 2177 | def __init__(self, repo): | 2177 | def __init__(self, repo): |
425 | 2178 | BzrError.__init__(self) | 2178 | BzrError.__init__(self) |
427 | 2179 | self.repo_path = repo.bzrdir.root_transport.base | 2179 | self.repo_path = repo.user_url |
428 | 2180 | 2180 | ||
429 | 2181 | 2181 | ||
430 | 2182 | class InconsistentDelta(BzrError): | 2182 | class InconsistentDelta(BzrError): |
431 | @@ -2754,7 +2754,7 @@ | |||
432 | 2754 | 2754 | ||
433 | 2755 | def __init__(self, bzrdir): | 2755 | def __init__(self, bzrdir): |
434 | 2756 | import bzrlib.urlutils as urlutils | 2756 | import bzrlib.urlutils as urlutils |
436 | 2757 | display_url = urlutils.unescape_for_display(bzrdir.root_transport.base, | 2757 | display_url = urlutils.unescape_for_display(bzrdir.user_url, |
437 | 2758 | 'ascii') | 2758 | 'ascii') |
438 | 2759 | BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url) | 2759 | BzrError.__init__(self, bzrdir=bzrdir, display_url=display_url) |
439 | 2760 | 2760 | ||
440 | @@ -2835,7 +2835,7 @@ | |||
441 | 2835 | more = ' ' + more | 2835 | more = ' ' + more |
442 | 2836 | import bzrlib.urlutils as urlutils | 2836 | import bzrlib.urlutils as urlutils |
443 | 2837 | display_url = urlutils.unescape_for_display( | 2837 | display_url = urlutils.unescape_for_display( |
445 | 2838 | tree.bzrdir.root_transport.base, 'ascii') | 2838 | tree.user_url, 'ascii') |
446 | 2839 | BzrError.__init__(self, tree=tree, display_url=display_url, more=more) | 2839 | BzrError.__init__(self, tree=tree, display_url=display_url, more=more) |
447 | 2840 | 2840 | ||
448 | 2841 | 2841 | ||
449 | 2842 | 2842 | ||
450 | === modified file 'bzrlib/info.py' | |||
451 | --- bzrlib/info.py 2010-02-17 17:11:16 +0000 | |||
452 | +++ bzrlib/info.py 2010-04-28 07:06:33 +0000 | |||
453 | @@ -80,9 +80,9 @@ | |||
454 | 80 | 80 | ||
455 | 81 | def gather_location_info(repository, branch=None, working=None): | 81 | def gather_location_info(repository, branch=None, working=None): |
456 | 82 | locs = {} | 82 | locs = {} |
458 | 83 | repository_path = repository.bzrdir.root_transport.base | 83 | repository_path = repository.user_url |
459 | 84 | if branch is not None: | 84 | if branch is not None: |
461 | 85 | branch_path = branch.bzrdir.root_transport.base | 85 | branch_path = branch.user_url |
462 | 86 | master_path = branch.get_bound_location() | 86 | master_path = branch.get_bound_location() |
463 | 87 | if master_path is None: | 87 | if master_path is None: |
464 | 88 | master_path = branch_path | 88 | master_path = branch_path |
465 | @@ -90,7 +90,7 @@ | |||
466 | 90 | branch_path = None | 90 | branch_path = None |
467 | 91 | master_path = None | 91 | master_path = None |
468 | 92 | if working: | 92 | if working: |
470 | 93 | working_path = working.bzrdir.root_transport.base | 93 | working_path = working.user_url |
471 | 94 | if working_path != branch_path: | 94 | if working_path != branch_path: |
472 | 95 | locs['light checkout root'] = working_path | 95 | locs['light checkout root'] = working_path |
473 | 96 | if master_path != branch_path: | 96 | if master_path != branch_path: |
474 | @@ -420,8 +420,8 @@ | |||
475 | 420 | if branch is None and tree is not None: | 420 | if branch is None and tree is not None: |
476 | 421 | phrase = "branchless tree" | 421 | phrase = "branchless tree" |
477 | 422 | else: | 422 | else: |
480 | 423 | if (tree is not None and tree.bzrdir.root_transport.base != | 423 | if (tree is not None and tree.user_url != |
481 | 424 | branch.bzrdir.root_transport.base): | 424 | branch.user_url): |
482 | 425 | independence = '' | 425 | independence = '' |
483 | 426 | phrase = "Lightweight checkout" | 426 | phrase = "Lightweight checkout" |
484 | 427 | elif branch.get_bound_location() is not None: | 427 | elif branch.get_bound_location() is not None: |
485 | @@ -446,8 +446,7 @@ | |||
486 | 446 | """ | 446 | """ |
487 | 447 | candidates = [] | 447 | candidates = [] |
488 | 448 | if (branch is not None and tree is not None and | 448 | if (branch is not None and tree is not None and |
491 | 449 | branch.bzrdir.root_transport.base != | 449 | branch.user_url != tree.user_url): |
490 | 450 | tree.bzrdir.root_transport.base): | ||
492 | 451 | branch = None | 450 | branch = None |
493 | 452 | repository = None | 451 | repository = None |
494 | 453 | non_aliases = set(bzrdir.format_registry.keys()) | 452 | non_aliases = set(bzrdir.format_registry.keys()) |
495 | 454 | 453 | ||
496 | === modified file 'bzrlib/reconcile.py' | |||
497 | --- bzrlib/reconcile.py 2010-02-17 17:11:16 +0000 | |||
498 | +++ bzrlib/reconcile.py 2010-04-28 07:06:33 +0000 | |||
499 | @@ -97,7 +97,7 @@ | |||
500 | 97 | def _reconcile_repository(self): | 97 | def _reconcile_repository(self): |
501 | 98 | self.repo = self.bzrdir.find_repository() | 98 | self.repo = self.bzrdir.find_repository() |
502 | 99 | ui.ui_factory.note('Reconciling repository %s' % | 99 | ui.ui_factory.note('Reconciling repository %s' % |
504 | 100 | self.repo.bzrdir.root_transport.base) | 100 | self.repo.user_url) |
505 | 101 | self.pb.update("Reconciling repository", 0, 1) | 101 | self.pb.update("Reconciling repository", 0, 1) |
506 | 102 | repo_reconciler = self.repo.reconcile(thorough=True) | 102 | repo_reconciler = self.repo.reconcile(thorough=True) |
507 | 103 | self.inconsistent_parents = repo_reconciler.inconsistent_parents | 103 | self.inconsistent_parents = repo_reconciler.inconsistent_parents |
508 | 104 | 104 | ||
509 | === modified file 'bzrlib/reconfigure.py' | |||
510 | --- bzrlib/reconfigure.py 2010-03-25 09:39:03 +0000 | |||
511 | +++ bzrlib/reconfigure.py 2010-04-28 07:06:33 +0000 | |||
512 | @@ -82,14 +82,13 @@ | |||
513 | 82 | self.repository = None | 82 | self.repository = None |
514 | 83 | self.local_repository = None | 83 | self.local_repository = None |
515 | 84 | else: | 84 | else: |
518 | 85 | if (self.repository.bzrdir.root_transport.base == | 85 | if (self.repository.user_url == self.bzrdir.user_url): |
517 | 86 | self.bzrdir.root_transport.base): | ||
519 | 87 | self.local_repository = self.repository | 86 | self.local_repository = self.repository |
520 | 88 | else: | 87 | else: |
521 | 89 | self.local_repository = None | 88 | self.local_repository = None |
522 | 90 | try: | 89 | try: |
523 | 91 | branch = self.bzrdir.open_branch() | 90 | branch = self.bzrdir.open_branch() |
525 | 92 | if branch.bzrdir.root_transport.base == bzrdir.root_transport.base: | 91 | if branch.user_url == bzrdir.user_url: |
526 | 93 | self.local_branch = branch | 92 | self.local_branch = branch |
527 | 94 | self.referenced_branch = None | 93 | self.referenced_branch = None |
528 | 95 | else: | 94 | else: |
529 | @@ -217,8 +216,8 @@ | |||
530 | 217 | if not want_reference: | 216 | if not want_reference: |
531 | 218 | self._create_repository = True | 217 | self._create_repository = True |
532 | 219 | else: | 218 | else: |
535 | 220 | if want_reference and (self.repository.bzrdir.root_transport.base | 219 | if want_reference and ( |
536 | 221 | == self.bzrdir.root_transport.base): | 220 | self.repository.user_url == self.bzrdir.user_url): |
537 | 222 | if not self.repository.is_shared(): | 221 | if not self.repository.is_shared(): |
538 | 223 | self._destroy_repository = True | 222 | self._destroy_repository = True |
539 | 224 | if self.referenced_branch is None: | 223 | if self.referenced_branch is None: |
540 | @@ -344,7 +343,7 @@ | |||
541 | 344 | if self._create_reference: | 343 | if self._create_reference: |
542 | 345 | reference_branch.repository.fetch(self.repository) | 344 | reference_branch.repository.fetch(self.repository) |
543 | 346 | elif self.local_branch is not None and not self._destroy_branch: | 345 | elif self.local_branch is not None and not self._destroy_branch: |
545 | 347 | up = self.local_branch.bzrdir.root_transport.clone('..') | 346 | up = self.local_branch.user_transport.clone('..') |
546 | 348 | up_bzrdir = bzrdir.BzrDir.open_containing_from_transport(up)[0] | 347 | up_bzrdir = bzrdir.BzrDir.open_containing_from_transport(up)[0] |
547 | 349 | new_repo = up_bzrdir.find_repository() | 348 | new_repo = up_bzrdir.find_repository() |
548 | 350 | new_repo.fetch(self.repository) | 349 | new_repo.fetch(self.repository) |
549 | 351 | 350 | ||
550 | === modified file 'bzrlib/remote.py' | |||
551 | --- bzrlib/remote.py 2010-04-20 04:16:50 +0000 | |||
552 | +++ bzrlib/remote.py 2010-04-28 07:06:33 +0000 | |||
553 | @@ -643,7 +643,8 @@ | |||
554 | 643 | return self._custom_format._serializer | 643 | return self._custom_format._serializer |
555 | 644 | 644 | ||
556 | 645 | 645 | ||
558 | 646 | class RemoteRepository(_RpcHelper, lock._RelockDebugMixin): | 646 | class RemoteRepository(_RpcHelper, lock._RelockDebugMixin, |
559 | 647 | bzrdir.ControlComponent): | ||
560 | 647 | """Repository accessed over rpc. | 648 | """Repository accessed over rpc. |
561 | 648 | 649 | ||
562 | 649 | For the moment most operations are performed using local transport-backed | 650 | For the moment most operations are performed using local transport-backed |
563 | @@ -692,6 +693,17 @@ | |||
564 | 692 | # Additional places to query for data. | 693 | # Additional places to query for data. |
565 | 693 | self._fallback_repositories = [] | 694 | self._fallback_repositories = [] |
566 | 694 | 695 | ||
567 | 696 | @property | ||
568 | 697 | def user_transport(self): | ||
569 | 698 | return self.bzrdir.user_transport | ||
570 | 699 | |||
571 | 700 | @property | ||
572 | 701 | def control_transport(self): | ||
573 | 702 | # XXX: Normally you shouldn't directly get at the remote repository | ||
574 | 703 | # transport, but I'm not sure it's worth making this method | ||
575 | 704 | # optional -- mbp 2010-04-21 | ||
576 | 705 | return self.bzrdir.get_repository_transport(None) | ||
577 | 706 | |||
578 | 695 | def __str__(self): | 707 | def __str__(self): |
579 | 696 | return "%s(%s)" % (self.__class__.__name__, self.base) | 708 | return "%s(%s)" % (self.__class__.__name__, self.base) |
580 | 697 | 709 | ||
581 | @@ -1234,9 +1246,9 @@ | |||
582 | 1234 | # _real_branch had its get_stacked_on_url method called), then the | 1246 | # _real_branch had its get_stacked_on_url method called), then the |
583 | 1235 | # repository to be added may already be in the _real_repositories list. | 1247 | # repository to be added may already be in the _real_repositories list. |
584 | 1236 | if self._real_repository is not None: | 1248 | if self._real_repository is not None: |
586 | 1237 | fallback_locations = [repo.bzrdir.root_transport.base for repo in | 1249 | fallback_locations = [repo.user_url for repo in |
587 | 1238 | self._real_repository._fallback_repositories] | 1250 | self._real_repository._fallback_repositories] |
589 | 1239 | if repository.bzrdir.root_transport.base not in fallback_locations: | 1251 | if repository.user_url not in fallback_locations: |
590 | 1240 | self._real_repository.add_fallback_repository(repository) | 1252 | self._real_repository.add_fallback_repository(repository) |
591 | 1241 | 1253 | ||
592 | 1242 | def _check_fallback_repository(self, repository): | 1254 | def _check_fallback_repository(self, repository): |
593 | @@ -2181,7 +2193,8 @@ | |||
594 | 2181 | self._real_branch = None | 2193 | self._real_branch = None |
595 | 2182 | # Fill out expected attributes of branch for bzrlib API users. | 2194 | # Fill out expected attributes of branch for bzrlib API users. |
596 | 2183 | self._clear_cached_state() | 2195 | self._clear_cached_state() |
598 | 2184 | self.base = self.bzrdir.root_transport.base | 2196 | # TODO: deprecate self.base in favor of user_url |
599 | 2197 | self.base = self.bzrdir.user_url | ||
600 | 2185 | self._name = name | 2198 | self._name = name |
601 | 2186 | self._control_files = None | 2199 | self._control_files = None |
602 | 2187 | self._lock_mode = None | 2200 | self._lock_mode = None |
603 | 2188 | 2201 | ||
604 | === modified file 'bzrlib/repofmt/weaverepo.py' | |||
605 | --- bzrlib/repofmt/weaverepo.py 2010-04-26 13:51:08 +0000 | |||
606 | +++ bzrlib/repofmt/weaverepo.py 2010-04-28 07:06:33 +0000 | |||
607 | @@ -177,7 +177,7 @@ | |||
608 | 177 | :param new_value: True to restore the default, False to disable making | 177 | :param new_value: True to restore the default, False to disable making |
609 | 178 | working trees. | 178 | working trees. |
610 | 179 | """ | 179 | """ |
612 | 180 | raise errors.RepositoryUpgradeRequired(self.bzrdir.root_transport.base) | 180 | raise errors.RepositoryUpgradeRequired(self.user_url) |
613 | 181 | 181 | ||
614 | 182 | def make_working_trees(self): | 182 | def make_working_trees(self): |
615 | 183 | """Returns the policy for making working trees on new branches.""" | 183 | """Returns the policy for making working trees on new branches.""" |
616 | 184 | 184 | ||
617 | === modified file 'bzrlib/repository.py' | |||
618 | --- bzrlib/repository.py 2010-04-22 17:08:27 +0000 | |||
619 | +++ bzrlib/repository.py 2010-04-28 07:06:33 +0000 | |||
620 | @@ -864,7 +864,7 @@ | |||
621 | 864 | # Repositories | 864 | # Repositories |
622 | 865 | 865 | ||
623 | 866 | 866 | ||
625 | 867 | class Repository(_RelockDebugMixin): | 867 | class Repository(_RelockDebugMixin, bzrdir.ControlComponent): |
626 | 868 | """Repository holding history for one or more branches. | 868 | """Repository holding history for one or more branches. |
627 | 869 | 869 | ||
628 | 870 | The repository holds and retrieves historical information including | 870 | The repository holds and retrieves historical information including |
629 | @@ -1291,11 +1291,10 @@ | |||
630 | 1291 | 1291 | ||
631 | 1292 | :param _format: The format of the repository on disk. | 1292 | :param _format: The format of the repository on disk. |
632 | 1293 | :param a_bzrdir: The BzrDir of the repository. | 1293 | :param a_bzrdir: The BzrDir of the repository. |
633 | 1294 | |||
634 | 1295 | In the future we will have a single api for all stores for | ||
635 | 1296 | getting file texts, inventories and revisions, then | ||
636 | 1297 | this construct will accept instances of those things. | ||
637 | 1298 | """ | 1294 | """ |
638 | 1295 | # In the future we will have a single api for all stores for | ||
639 | 1296 | # getting file texts, inventories and revisions, then | ||
640 | 1297 | # this construct will accept instances of those things. | ||
641 | 1299 | super(Repository, self).__init__() | 1298 | super(Repository, self).__init__() |
642 | 1300 | self._format = _format | 1299 | self._format = _format |
643 | 1301 | # the following are part of the public API for Repository: | 1300 | # the following are part of the public API for Repository: |
644 | @@ -1316,6 +1315,14 @@ | |||
645 | 1316 | # rather copying them? | 1315 | # rather copying them? |
646 | 1317 | self._safe_to_return_from_cache = False | 1316 | self._safe_to_return_from_cache = False |
647 | 1318 | 1317 | ||
648 | 1318 | @property | ||
649 | 1319 | def user_transport(self): | ||
650 | 1320 | return self.bzrdir.user_transport | ||
651 | 1321 | |||
652 | 1322 | @property | ||
653 | 1323 | def control_transport(self): | ||
654 | 1324 | return self._transport | ||
655 | 1325 | |||
656 | 1319 | def __repr__(self): | 1326 | def __repr__(self): |
657 | 1320 | if self._fallback_repositories: | 1327 | if self._fallback_repositories: |
658 | 1321 | return '%s(%r, fallback_repositories=%r)' % ( | 1328 | return '%s(%r, fallback_repositories=%r)' % ( |
659 | @@ -1469,7 +1476,7 @@ | |||
660 | 1469 | 1476 | ||
661 | 1470 | # now gather global repository information | 1477 | # now gather global repository information |
662 | 1471 | # XXX: This is available for many repos regardless of listability. | 1478 | # XXX: This is available for many repos regardless of listability. |
664 | 1472 | if self.bzrdir.root_transport.listable(): | 1479 | if self.user_transport.listable(): |
665 | 1473 | # XXX: do we want to __define len__() ? | 1480 | # XXX: do we want to __define len__() ? |
666 | 1474 | # Maybe the versionedfiles object should provide a different | 1481 | # Maybe the versionedfiles object should provide a different |
667 | 1475 | # method to get the number of keys. | 1482 | # method to get the number of keys. |
668 | @@ -1507,7 +1514,7 @@ | |||
669 | 1507 | 1514 | ||
670 | 1508 | ret = [] | 1515 | ret = [] |
671 | 1509 | for branches, repository in bzrdir.BzrDir.find_bzrdirs( | 1516 | for branches, repository in bzrdir.BzrDir.find_bzrdirs( |
673 | 1510 | self.bzrdir.root_transport, evaluate=Evaluator()): | 1517 | self.user_transport, evaluate=Evaluator()): |
674 | 1511 | if branches is not None: | 1518 | if branches is not None: |
675 | 1512 | ret.extend(branches) | 1519 | ret.extend(branches) |
676 | 1513 | if not using and repository is not None: | 1520 | if not using and repository is not None: |
677 | 1514 | 1521 | ||
678 | === modified file 'bzrlib/smart/bzrdir.py' | |||
679 | --- bzrlib/smart/bzrdir.py 2010-02-17 17:11:16 +0000 | |||
680 | +++ bzrlib/smart/bzrdir.py 2010-04-28 07:06:33 +0000 | |||
681 | @@ -110,7 +110,7 @@ | |||
682 | 110 | """Get the relative path for repository from current_transport.""" | 110 | """Get the relative path for repository from current_transport.""" |
683 | 111 | # the relpath of the bzrdir in the found repository gives us the | 111 | # the relpath of the bzrdir in the found repository gives us the |
684 | 112 | # path segments to pop-out. | 112 | # path segments to pop-out. |
686 | 113 | relpath = repository.bzrdir.root_transport.relpath( | 113 | relpath = repository.user_transport.relpath( |
687 | 114 | current_transport.base) | 114 | current_transport.base) |
688 | 115 | if len(relpath): | 115 | if len(relpath): |
689 | 116 | segments = ['..'] * len(relpath.split('/')) | 116 | segments = ['..'] * len(relpath.split('/')) |
690 | 117 | 117 | ||
691 | === modified file 'bzrlib/tests/per_branch/test_branch.py' | |||
692 | --- bzrlib/tests/per_branch/test_branch.py 2010-03-02 22:25:58 +0000 | |||
693 | +++ bzrlib/tests/per_branch/test_branch.py 2010-04-28 07:06:33 +0000 | |||
694 | @@ -988,3 +988,16 @@ | |||
695 | 988 | merger.do_merge() | 988 | merger.do_merge() |
696 | 989 | self.assertEqual('../branch/reference', | 989 | self.assertEqual('../branch/reference', |
697 | 990 | tree.branch.get_reference_info('file-id')[1]) | 990 | tree.branch.get_reference_info('file-id')[1]) |
698 | 991 | |||
699 | 992 | |||
700 | 993 | class TestBranchControlComponent(per_branch.TestCaseWithBranch): | ||
701 | 994 | """Branch implementations adequately implement ControlComponent.""" | ||
702 | 995 | |||
703 | 996 | def test_urls(self): | ||
704 | 997 | br = self.make_branch('branch') | ||
705 | 998 | self.assertIsInstance(br.user_url, str) | ||
706 | 999 | self.assertEqual(br.user_url, br.user_transport.base) | ||
707 | 1000 | # for all current bzrdir implementations the user dir must be | ||
708 | 1001 | # above the control dir but we might need to relax that? | ||
709 | 1002 | self.assertEqual(br.control_url.find(br.user_url), 0) | ||
710 | 1003 | self.assertEqual(br.control_url, br.control_transport.base) | ||
711 | 991 | 1004 | ||
712 | === modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py' | |||
713 | --- bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-04-11 19:40:23 +0000 | |||
714 | +++ bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-04-28 07:06:33 +0000 | |||
715 | @@ -1971,3 +1971,15 @@ | |||
716 | 1971 | self.assertRaises(errors.NoRepositoryPresent, | 1971 | self.assertRaises(errors.NoRepositoryPresent, |
717 | 1972 | made_control.find_repository) | 1972 | made_control.find_repository) |
718 | 1973 | 1973 | ||
719 | 1974 | |||
720 | 1975 | class TestBzrDirControlComponent(TestCaseWithBzrDir): | ||
721 | 1976 | """BzrDir implementations adequately implement ControlComponent.""" | ||
722 | 1977 | |||
723 | 1978 | def test_urls(self): | ||
724 | 1979 | bd = self.make_bzrdir('bd') | ||
725 | 1980 | self.assertIsInstance(bd.user_url, str) | ||
726 | 1981 | self.assertEqual(bd.user_url, bd.user_transport.base) | ||
727 | 1982 | # for all current bzrdir implementations the user dir must be | ||
728 | 1983 | # above the control dir but we might need to relax that? | ||
729 | 1984 | self.assertEqual(bd.control_url.find(bd.user_url), 0) | ||
730 | 1985 | self.assertEqual(bd.control_url, bd.control_transport.base) | ||
731 | 1974 | 1986 | ||
732 | === modified file 'bzrlib/tests/per_repository/test_repository.py' | |||
733 | --- bzrlib/tests/per_repository/test_repository.py 2010-04-10 01:22:00 +0000 | |||
734 | +++ bzrlib/tests/per_repository/test_repository.py 2010-04-28 07:06:33 +0000 | |||
735 | @@ -1342,3 +1342,18 @@ | |||
736 | 1342 | fileobj = StringIO() | 1342 | fileobj = StringIO() |
737 | 1343 | wt.branch.repository.create_bundle( | 1343 | wt.branch.repository.create_bundle( |
738 | 1344 | 'rev1', _mod_revision.NULL_REVISION, fileobj) | 1344 | 'rev1', _mod_revision.NULL_REVISION, fileobj) |
739 | 1345 | |||
740 | 1346 | |||
741 | 1347 | |||
742 | 1348 | |||
743 | 1349 | class TestRepositoryControlComponent(per_repository.TestCaseWithRepository): | ||
744 | 1350 | """Repository implementations adequately implement ControlComponent.""" | ||
745 | 1351 | |||
746 | 1352 | def test_urls(self): | ||
747 | 1353 | repo = self.make_repository('repo') | ||
748 | 1354 | self.assertIsInstance(repo.user_url, str) | ||
749 | 1355 | self.assertEqual(repo.user_url, repo.user_transport.base) | ||
750 | 1356 | # for all current bzrdir implementations the user dir must be | ||
751 | 1357 | # above the control dir but we might need to relax that? | ||
752 | 1358 | self.assertEqual(repo.control_url.find(repo.user_url), 0) | ||
753 | 1359 | self.assertEqual(repo.control_url, repo.control_transport.base) | ||
754 | 1345 | 1360 | ||
755 | === modified file 'bzrlib/tests/per_workingtree/test_workingtree.py' | |||
756 | --- bzrlib/tests/per_workingtree/test_workingtree.py 2010-03-02 22:25:58 +0000 | |||
757 | +++ bzrlib/tests/per_workingtree/test_workingtree.py 2010-04-28 07:06:33 +0000 | |||
758 | @@ -1091,3 +1091,16 @@ | |||
759 | 1091 | # We should display the relative path | 1091 | # We should display the relative path |
760 | 1092 | self.assertEqual('subdir/m\xb5', e.filename) | 1092 | self.assertEqual('subdir/m\xb5', e.filename) |
761 | 1093 | self.assertEqual(osutils._fs_enc, e.fs_encoding) | 1093 | self.assertEqual(osutils._fs_enc, e.fs_encoding) |
762 | 1094 | |||
763 | 1095 | |||
764 | 1096 | class TestControlComponent(TestCaseWithWorkingTree): | ||
765 | 1097 | """WorkingTree implementations adequately implement ControlComponent.""" | ||
766 | 1098 | |||
767 | 1099 | def test_urls(self): | ||
768 | 1100 | wt = self.make_branch_and_tree('wt') | ||
769 | 1101 | self.assertIsInstance(wt.user_url, str) | ||
770 | 1102 | self.assertEqual(wt.user_url, wt.user_transport.base) | ||
771 | 1103 | # for all current bzrdir implementations the user dir must be | ||
772 | 1104 | # above the control dir but we might need to relax that? | ||
773 | 1105 | self.assertEqual(wt.control_url.find(wt.user_url), 0) | ||
774 | 1106 | self.assertEqual(wt.control_url, wt.control_transport.base) | ||
775 | 1094 | 1107 | ||
776 | === modified file 'bzrlib/tests/test_foreign.py' | |||
777 | --- bzrlib/tests/test_foreign.py 2010-03-02 22:25:58 +0000 | |||
778 | +++ bzrlib/tests/test_foreign.py 2010-04-28 07:06:33 +0000 | |||
779 | @@ -90,6 +90,7 @@ | |||
780 | 90 | self._format = _format | 90 | self._format = _format |
781 | 91 | self._base = a_bzrdir.transport.base | 91 | self._base = a_bzrdir.transport.base |
782 | 92 | self._ignore_fallbacks = False | 92 | self._ignore_fallbacks = False |
783 | 93 | self.bzrdir = a_bzrdir | ||
784 | 93 | foreign.ForeignBranch.__init__(self, | 94 | foreign.ForeignBranch.__init__(self, |
785 | 94 | DummyForeignVcsMapping(DummyForeignVcs())) | 95 | DummyForeignVcsMapping(DummyForeignVcs())) |
786 | 95 | branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir, | 96 | branch.BzrBranch6.__init__(self, _format, _control_files, a_bzrdir, |
787 | 96 | 97 | ||
788 | === modified file 'bzrlib/upgrade.py' | |||
789 | --- bzrlib/upgrade.py 2010-03-25 07:34:15 +0000 | |||
790 | +++ bzrlib/upgrade.py 2010-04-28 07:06:33 +0000 | |||
791 | @@ -47,11 +47,10 @@ | |||
792 | 47 | def convert(self): | 47 | def convert(self): |
793 | 48 | try: | 48 | try: |
794 | 49 | branch = self.bzrdir.open_branch() | 49 | branch = self.bzrdir.open_branch() |
797 | 50 | if branch.bzrdir.root_transport.base != \ | 50 | if branch.user_url != self.bzrdir.user_url: |
796 | 51 | self.bzrdir.root_transport.base: | ||
798 | 52 | ui.ui_factory.note("This is a checkout. The branch (%s) needs to be " | 51 | ui.ui_factory.note("This is a checkout. The branch (%s) needs to be " |
799 | 53 | "upgraded separately." % | 52 | "upgraded separately." % |
801 | 54 | branch.bzrdir.root_transport.base) | 53 | branch.user_url) |
802 | 55 | del branch | 54 | del branch |
803 | 56 | except (errors.NotBranchError, errors.IncompatibleRepositories): | 55 | except (errors.NotBranchError, errors.IncompatibleRepositories): |
804 | 57 | # might not be a format we can open without upgrading; see e.g. | 56 | # might not be a format we can open without upgrading; see e.g. |
805 | 58 | 57 | ||
806 | === modified file 'bzrlib/workingtree.py' | |||
807 | --- bzrlib/workingtree.py 2010-04-08 06:05:44 +0000 | |||
808 | +++ bzrlib/workingtree.py 2010-04-28 07:06:33 +0000 | |||
809 | @@ -29,12 +29,6 @@ | |||
810 | 29 | WorkingTree.open(dir). | 29 | WorkingTree.open(dir). |
811 | 30 | """ | 30 | """ |
812 | 31 | 31 | ||
813 | 32 | # TODO: Give the workingtree sole responsibility for the working inventory; | ||
814 | 33 | # remove the variable and references to it from the branch. This may require | ||
815 | 34 | # updating the commit code so as to update the inventory within the working | ||
816 | 35 | # copy, and making sure there's only one WorkingTree for any directory on disk. | ||
817 | 36 | # At the moment they may alias the inventory and have old copies of it in | ||
818 | 37 | # memory. (Now done? -- mbp 20060309) | ||
819 | 38 | 32 | ||
820 | 39 | from cStringIO import StringIO | 33 | from cStringIO import StringIO |
821 | 40 | import os | 34 | import os |
822 | @@ -174,7 +168,8 @@ | |||
823 | 174 | return '' | 168 | return '' |
824 | 175 | 169 | ||
825 | 176 | 170 | ||
827 | 177 | class WorkingTree(bzrlib.mutabletree.MutableTree): | 171 | class WorkingTree(bzrlib.mutabletree.MutableTree, |
828 | 172 | bzrdir.ControlComponent): | ||
829 | 178 | """Working copy tree. | 173 | """Working copy tree. |
830 | 179 | 174 | ||
831 | 180 | The inventory is held in the `Branch` working-inventory, and the | 175 | The inventory is held in the `Branch` working-inventory, and the |
832 | @@ -253,6 +248,14 @@ | |||
833 | 253 | self._rules_searcher = None | 248 | self._rules_searcher = None |
834 | 254 | self.views = self._make_views() | 249 | self.views = self._make_views() |
835 | 255 | 250 | ||
836 | 251 | @property | ||
837 | 252 | def user_transport(self): | ||
838 | 253 | return self.bzrdir.user_transport | ||
839 | 254 | |||
840 | 255 | @property | ||
841 | 256 | def control_transport(self): | ||
842 | 257 | return self._transport | ||
843 | 258 | |||
844 | 256 | def _detect_case_handling(self): | 259 | def _detect_case_handling(self): |
845 | 257 | wt_trans = self.bzrdir.get_workingtree_transport(None) | 260 | wt_trans = self.bzrdir.get_workingtree_transport(None) |
846 | 258 | try: | 261 | try: |
I like this! The new names are much much clearer. It seems a bit of a shame to create another mixin, but the new code is certainly much nicer.