Merge lp:~lifeless/bzr/loomsupport into lp:bzr
- loomsupport
- Merge into bzr.dev
Proposed by
Robert Collins
Status: | Merged |
---|---|
Approved by: | Robert Collins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 5293 |
Proposed branch: | lp:~lifeless/bzr/loomsupport |
Merge into: | lp:bzr |
Diff against target: |
567 lines (+267/-154) 7 files modified
NEWS (+16/-10) bzrlib/branch.py (+138/-131) bzrlib/tests/per_branch/test_pull.py (+0/-11) bzrlib/tests/per_interbranch/__init__.py (+30/-0) bzrlib/tests/per_interbranch/test_copy_content_into.py (+47/-0) bzrlib/tests/per_interbranch/test_get.py (+34/-0) bzrlib/tests/per_interbranch/test_pull.py (+2/-2) |
To merge this branch: | bzr merge lp:~lifeless/bzr/loomsupport |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Vincent Ladeuil | Approve | ||
Review via email: mp+27473@code.launchpad.net |
Commit message
InterBranch improvements needed for bzr-loom support.
Description of the change
Essentially, move Branch.
Opportunistically:
- cleanup a crazy InterBranch structural issue that had me confused while
doing this.
- add tests to ensure that that issue can't resurrect itself
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote : | # |
They work for me. Perhaps you have a non-core plugin interfering?
Revision history for this message
Vincent Ladeuil (vila) wrote : | # |
Sounds fine, please land.
review:
Approve
Revision history for this message
Robert Collins (lifeless) wrote : | # |
sent to pqm by email
Revision history for this message
Robert Collins (lifeless) wrote : | # |
sent to pqm by email
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2010-06-14 17:58:24 +0000 | |||
3 | +++ NEWS 2010-06-14 21:46:28 +0000 | |||
4 | @@ -34,29 +34,35 @@ | |||
5 | 34 | (Martin [gz], Parth Malwankar, #501307) | 34 | (Martin [gz], Parth Malwankar, #501307) |
6 | 35 | 35 | ||
7 | 36 | * ``bzr log --exclude-common-ancestry`` is now taken into account for | 36 | * ``bzr log --exclude-common-ancestry`` is now taken into account for |
10 | 37 | linear ancetries. | 37 | linear ancetries. (Vincent Ladeuil, #575631) |
9 | 38 | (Vincent Ladeuil, #575631) | ||
11 | 39 | 38 | ||
12 | 40 | * Ensure that wrong path specifications in ``BZR_PLUGINS_AT`` display | 39 | * Ensure that wrong path specifications in ``BZR_PLUGINS_AT`` display |
15 | 41 | proper error messages. | 40 | proper error messages. (Vincent Ladeuil, #591215) |
16 | 42 | (Vincent Ladeuil, #591215) | 41 | |
17 | 42 | * Explicitly removing ``--profile-imports`` option from parsed command-line | ||
18 | 43 | arguments on Windows, because bzr script does the same. | ||
19 | 44 | (Alexander Belchenko, #588277) | ||
20 | 45 | |||
21 | 46 | * Fetching was slightly confused about the best code to use and was | ||
22 | 47 | using a new code path for all branches, resulting in more lookups than | ||
23 | 48 | necessary on old branches. (Robert Collins, #593515) | ||
24 | 43 | 49 | ||
25 | 44 | * Final fix for 'no help for command' issue. We now show a clean message | 50 | * Final fix for 'no help for command' issue. We now show a clean message |
26 | 45 | when a command has no help, document how to set help more clearly, and | 51 | when a command has no help, document how to set help more clearly, and |
27 | 46 | test that all commands available to the test suite have help. | 52 | test that all commands available to the test suite have help. |
28 | 47 | (Robert Collins, #177500) | 53 | (Robert Collins, #177500) |
29 | 48 | 54 | ||
30 | 49 | * Explicitly removing ``--profile-imports`` option from parsed command-line | ||
31 | 50 | arguments on Windows, because bzr script does the same. | ||
32 | 51 | (Alexander Belchenko, #588277) | ||
33 | 52 | |||
34 | 53 | * Relative imports in plugins are now handled correctly when using | 55 | * Relative imports in plugins are now handled correctly when using |
37 | 54 | BZR_PLUGINS_AT. | 56 | BZR_PLUGINS_AT. (Vincent Ladeuil, #588959) |
36 | 55 | (Vincent Ladeuil, #588959) | ||
38 | 56 | 57 | ||
39 | 57 | Improvements | 58 | Improvements |
40 | 58 | ************ | 59 | ************ |
41 | 59 | 60 | ||
42 | 61 | * ``Branch.copy_content_into`` is now a convenience method dispatching to | ||
43 | 62 | a ``InterBranch`` multi-method. This permits ``bzr-loom`` and other | ||
44 | 63 | plugins to intercept this even when a ``RemoteBranch`` proxy is in use. | ||
45 | 64 | (Robert Collins, #201613) | ||
46 | 65 | |||
47 | 60 | * Use lazy imports in ``bzrlib/merge.py`` so that plugins like ``news_merge`` | 66 | * Use lazy imports in ``bzrlib/merge.py`` so that plugins like ``news_merge`` |
48 | 61 | do not cause modules to be loaded unnecessarily just because the plugin | 67 | do not cause modules to be loaded unnecessarily just because the plugin |
49 | 62 | registers a merge hook. This improves ``bzr rocks`` time by about 25% | 68 | registers a merge hook. This improves ``bzr rocks`` time by about 25% |
50 | 63 | 69 | ||
51 | === modified file 'bzrlib/branch.py' | |||
52 | --- bzrlib/branch.py 2010-06-07 20:25:05 +0000 | |||
53 | +++ bzrlib/branch.py 2010-06-14 21:46:28 +0000 | |||
54 | @@ -29,6 +29,7 @@ | |||
55 | 29 | errors, | 29 | errors, |
56 | 30 | lockdir, | 30 | lockdir, |
57 | 31 | lockable_files, | 31 | lockable_files, |
58 | 32 | remote, | ||
59 | 32 | repository, | 33 | repository, |
60 | 33 | revision as _mod_revision, | 34 | revision as _mod_revision, |
61 | 34 | rio, | 35 | rio, |
62 | @@ -968,7 +969,6 @@ | |||
63 | 968 | raise errors.NoSuchRevision(self, stop_revision) | 969 | raise errors.NoSuchRevision(self, stop_revision) |
64 | 969 | return other_history[self_len:stop_revision] | 970 | return other_history[self_len:stop_revision] |
65 | 970 | 971 | ||
66 | 971 | @needs_write_lock | ||
67 | 972 | def update_revisions(self, other, stop_revision=None, overwrite=False, | 972 | def update_revisions(self, other, stop_revision=None, overwrite=False, |
68 | 973 | graph=None): | 973 | graph=None): |
69 | 974 | """Pull in new perfect-fit revisions. | 974 | """Pull in new perfect-fit revisions. |
70 | @@ -1272,24 +1272,14 @@ | |||
71 | 1272 | revno = 1 | 1272 | revno = 1 |
72 | 1273 | destination.set_last_revision_info(revno, revision_id) | 1273 | destination.set_last_revision_info(revno, revision_id) |
73 | 1274 | 1274 | ||
74 | 1275 | @needs_read_lock | ||
75 | 1276 | def copy_content_into(self, destination, revision_id=None): | 1275 | def copy_content_into(self, destination, revision_id=None): |
76 | 1277 | """Copy the content of self into destination. | 1276 | """Copy the content of self into destination. |
77 | 1278 | 1277 | ||
78 | 1279 | revision_id: if not None, the revision history in the new branch will | 1278 | revision_id: if not None, the revision history in the new branch will |
79 | 1280 | be truncated to end with revision_id. | 1279 | be truncated to end with revision_id. |
80 | 1281 | """ | 1280 | """ |
92 | 1282 | self.update_references(destination) | 1281 | return InterBranch.get(self, destination).copy_content_into( |
93 | 1283 | self._synchronize_history(destination, revision_id) | 1282 | revision_id=revision_id) |
83 | 1284 | try: | ||
84 | 1285 | parent = self.get_parent() | ||
85 | 1286 | except errors.InaccessibleParent, e: | ||
86 | 1287 | mutter('parent was not accessible to copy: %s', e) | ||
87 | 1288 | else: | ||
88 | 1289 | if parent: | ||
89 | 1290 | destination.set_parent(parent) | ||
90 | 1291 | if self._push_should_merge_tags(): | ||
91 | 1292 | self.tags.merge_to(destination.tags) | ||
94 | 1293 | 1283 | ||
95 | 1294 | def update_references(self, target): | 1284 | def update_references(self, target): |
96 | 1295 | if not getattr(self._format, 'supports_reference_locations', False): | 1285 | if not getattr(self._format, 'supports_reference_locations', False): |
97 | @@ -3233,110 +3223,112 @@ | |||
98 | 3233 | 3223 | ||
99 | 3234 | 3224 | ||
100 | 3235 | class GenericInterBranch(InterBranch): | 3225 | class GenericInterBranch(InterBranch): |
103 | 3236 | """InterBranch implementation that uses public Branch functions. | 3226 | """InterBranch implementation that uses public Branch functions.""" |
104 | 3237 | """ | 3227 | |
105 | 3228 | @classmethod | ||
106 | 3229 | def is_compatible(klass, source, target): | ||
107 | 3230 | # GenericBranch uses the public API, so always compatible | ||
108 | 3231 | return True | ||
109 | 3238 | 3232 | ||
110 | 3239 | @staticmethod | 3233 | @staticmethod |
111 | 3240 | def _get_branch_formats_to_test(): | 3234 | def _get_branch_formats_to_test(): |
112 | 3241 | return BranchFormat._default_format, BranchFormat._default_format | 3235 | return BranchFormat._default_format, BranchFormat._default_format |
113 | 3242 | 3236 | ||
114 | 3237 | @classmethod | ||
115 | 3238 | def unwrap_format(klass, format): | ||
116 | 3239 | if isinstance(format, remote.RemoteBranchFormat): | ||
117 | 3240 | format._ensure_real() | ||
118 | 3241 | return format._custom_format | ||
119 | 3242 | return format | ||
120 | 3243 | |||
121 | 3244 | @needs_write_lock | ||
122 | 3245 | def copy_content_into(self, revision_id=None): | ||
123 | 3246 | """Copy the content of source into target | ||
124 | 3247 | |||
125 | 3248 | revision_id: if not None, the revision history in the new branch will | ||
126 | 3249 | be truncated to end with revision_id. | ||
127 | 3250 | """ | ||
128 | 3251 | self.source.update_references(self.target) | ||
129 | 3252 | self.source._synchronize_history(self.target, revision_id) | ||
130 | 3253 | try: | ||
131 | 3254 | parent = self.source.get_parent() | ||
132 | 3255 | except errors.InaccessibleParent, e: | ||
133 | 3256 | mutter('parent was not accessible to copy: %s', e) | ||
134 | 3257 | else: | ||
135 | 3258 | if parent: | ||
136 | 3259 | self.target.set_parent(parent) | ||
137 | 3260 | if self.source._push_should_merge_tags(): | ||
138 | 3261 | self.source.tags.merge_to(self.target.tags) | ||
139 | 3262 | |||
140 | 3263 | @needs_write_lock | ||
141 | 3243 | def update_revisions(self, stop_revision=None, overwrite=False, | 3264 | def update_revisions(self, stop_revision=None, overwrite=False, |
142 | 3244 | graph=None): | 3265 | graph=None): |
143 | 3245 | """See InterBranch.update_revisions().""" | 3266 | """See InterBranch.update_revisions().""" |
154 | 3246 | self.source.lock_read() | 3267 | other_revno, other_last_revision = self.source.last_revision_info() |
155 | 3247 | try: | 3268 | stop_revno = None # unknown |
156 | 3248 | other_revno, other_last_revision = self.source.last_revision_info() | 3269 | if stop_revision is None: |
157 | 3249 | stop_revno = None # unknown | 3270 | stop_revision = other_last_revision |
158 | 3250 | if stop_revision is None: | 3271 | if _mod_revision.is_null(stop_revision): |
159 | 3251 | stop_revision = other_last_revision | 3272 | # if there are no commits, we're done. |
160 | 3252 | if _mod_revision.is_null(stop_revision): | 3273 | return |
161 | 3253 | # if there are no commits, we're done. | 3274 | stop_revno = other_revno |
152 | 3254 | return | ||
153 | 3255 | stop_revno = other_revno | ||
162 | 3256 | 3275 | ||
191 | 3257 | # what's the current last revision, before we fetch [and change it | 3276 | # what's the current last revision, before we fetch [and change it |
192 | 3258 | # possibly] | 3277 | # possibly] |
193 | 3259 | last_rev = _mod_revision.ensure_null(self.target.last_revision()) | 3278 | last_rev = _mod_revision.ensure_null(self.target.last_revision()) |
194 | 3260 | # we fetch here so that we don't process data twice in the common | 3279 | # we fetch here so that we don't process data twice in the common |
195 | 3261 | # case of having something to pull, and so that the check for | 3280 | # case of having something to pull, and so that the check for |
196 | 3262 | # already merged can operate on the just fetched graph, which will | 3281 | # already merged can operate on the just fetched graph, which will |
197 | 3263 | # be cached in memory. | 3282 | # be cached in memory. |
198 | 3264 | self.target.fetch(self.source, stop_revision) | 3283 | self.target.fetch(self.source, stop_revision) |
199 | 3265 | # Check to see if one is an ancestor of the other | 3284 | # Check to see if one is an ancestor of the other |
200 | 3266 | if not overwrite: | 3285 | if not overwrite: |
201 | 3267 | if graph is None: | 3286 | if graph is None: |
202 | 3268 | graph = self.target.repository.get_graph() | 3287 | graph = self.target.repository.get_graph() |
203 | 3269 | if self.target._check_if_descendant_or_diverged( | 3288 | if self.target._check_if_descendant_or_diverged( |
204 | 3270 | stop_revision, last_rev, graph, self.source): | 3289 | stop_revision, last_rev, graph, self.source): |
205 | 3271 | # stop_revision is a descendant of last_rev, but we aren't | 3290 | # stop_revision is a descendant of last_rev, but we aren't |
206 | 3272 | # overwriting, so we're done. | 3291 | # overwriting, so we're done. |
207 | 3273 | return | 3292 | return |
208 | 3274 | if stop_revno is None: | 3293 | if stop_revno is None: |
209 | 3275 | if graph is None: | 3294 | if graph is None: |
210 | 3276 | graph = self.target.repository.get_graph() | 3295 | graph = self.target.repository.get_graph() |
211 | 3277 | this_revno, this_last_revision = \ | 3296 | this_revno, this_last_revision = \ |
212 | 3278 | self.target.last_revision_info() | 3297 | self.target.last_revision_info() |
213 | 3279 | stop_revno = graph.find_distance_to_null(stop_revision, | 3298 | stop_revno = graph.find_distance_to_null(stop_revision, |
214 | 3280 | [(other_last_revision, other_revno), | 3299 | [(other_last_revision, other_revno), |
215 | 3281 | (this_last_revision, this_revno)]) | 3300 | (this_last_revision, this_revno)]) |
216 | 3282 | self.target.set_last_revision_info(stop_revno, stop_revision) | 3301 | self.target.set_last_revision_info(stop_revno, stop_revision) |
189 | 3283 | finally: | ||
190 | 3284 | self.source.unlock() | ||
217 | 3285 | 3302 | ||
218 | 3286 | def pull(self, overwrite=False, stop_revision=None, | 3303 | def pull(self, overwrite=False, stop_revision=None, |
220 | 3287 | possible_transports=None, _hook_master=None, run_hooks=True, | 3304 | possible_transports=None, run_hooks=True, |
221 | 3288 | _override_hook_target=None, local=False): | 3305 | _override_hook_target=None, local=False): |
223 | 3289 | """See Branch.pull. | 3306 | """Pull from source into self, updating my master if any. |
224 | 3290 | 3307 | ||
225 | 3291 | :param _hook_master: Private parameter - set the branch to | ||
226 | 3292 | be supplied as the master to pull hooks. | ||
227 | 3293 | :param run_hooks: Private parameter - if false, this branch | 3308 | :param run_hooks: Private parameter - if false, this branch |
228 | 3294 | is being called because it's the master of the primary branch, | 3309 | is being called because it's the master of the primary branch, |
229 | 3295 | so it should not run its hooks. | 3310 | so it should not run its hooks. |
230 | 3296 | :param _override_hook_target: Private parameter - set the branch to be | ||
231 | 3297 | supplied as the target_branch to pull hooks. | ||
232 | 3298 | :param local: Only update the local branch, and not the bound branch. | ||
233 | 3299 | """ | 3311 | """ |
236 | 3300 | # This type of branch can't be bound. | 3312 | bound_location = self.target.get_bound_location() |
237 | 3301 | if local: | 3313 | if local and not bound_location: |
238 | 3302 | raise errors.LocalRequiresBoundBranch() | 3314 | raise errors.LocalRequiresBoundBranch() |
246 | 3303 | result = PullResult() | 3315 | master_branch = None |
247 | 3304 | result.source_branch = self.source | 3316 | if not local and bound_location and self.source.user_url != bound_location: |
248 | 3305 | if _override_hook_target is None: | 3317 | # not pulling from master, so we need to update master. |
249 | 3306 | result.target_branch = self.target | 3318 | master_branch = self.target.get_master_branch(possible_transports) |
250 | 3307 | else: | 3319 | master_branch.lock_write() |
244 | 3308 | result.target_branch = _override_hook_target | ||
245 | 3309 | self.source.lock_read() | ||
251 | 3310 | try: | 3320 | try: |
278 | 3311 | # We assume that during 'pull' the target repository is closer than | 3321 | if master_branch: |
279 | 3312 | # the source one. | 3322 | # pull from source into master. |
280 | 3313 | self.source.update_references(self.target) | 3323 | master_branch.pull(self.source, overwrite, stop_revision, |
281 | 3314 | graph = self.target.repository.get_graph(self.source.repository) | 3324 | run_hooks=False) |
282 | 3315 | # TODO: Branch formats should have a flag that indicates | 3325 | return self._pull(overwrite, |
283 | 3316 | # that revno's are expensive, and pull() should honor that flag. | 3326 | stop_revision, _hook_master=master_branch, |
284 | 3317 | # -- JRV20090506 | 3327 | run_hooks=run_hooks, |
285 | 3318 | result.old_revno, result.old_revid = \ | 3328 | _override_hook_target=_override_hook_target) |
260 | 3319 | self.target.last_revision_info() | ||
261 | 3320 | self.target.update_revisions(self.source, stop_revision, | ||
262 | 3321 | overwrite=overwrite, graph=graph) | ||
263 | 3322 | # TODO: The old revid should be specified when merging tags, | ||
264 | 3323 | # so a tags implementation that versions tags can only | ||
265 | 3324 | # pull in the most recent changes. -- JRV20090506 | ||
266 | 3325 | result.tag_conflicts = self.source.tags.merge_to(self.target.tags, | ||
267 | 3326 | overwrite) | ||
268 | 3327 | result.new_revno, result.new_revid = self.target.last_revision_info() | ||
269 | 3328 | if _hook_master: | ||
270 | 3329 | result.master_branch = _hook_master | ||
271 | 3330 | result.local_branch = result.target_branch | ||
272 | 3331 | else: | ||
273 | 3332 | result.master_branch = result.target_branch | ||
274 | 3333 | result.local_branch = None | ||
275 | 3334 | if run_hooks: | ||
276 | 3335 | for hook in Branch.hooks['post_pull']: | ||
277 | 3336 | hook(result) | ||
286 | 3337 | finally: | 3329 | finally: |
289 | 3338 | self.source.unlock() | 3330 | if master_branch: |
290 | 3339 | return result | 3331 | master_branch.unlock() |
291 | 3340 | 3332 | ||
292 | 3341 | def push(self, overwrite=False, stop_revision=None, | 3333 | def push(self, overwrite=False, stop_revision=None, |
293 | 3342 | _override_hook_source_branch=None): | 3334 | _override_hook_source_branch=None): |
294 | @@ -3404,48 +3396,63 @@ | |||
295 | 3404 | _run_hooks() | 3396 | _run_hooks() |
296 | 3405 | return result | 3397 | return result |
297 | 3406 | 3398 | ||
312 | 3407 | @classmethod | 3399 | def _pull(self, overwrite=False, stop_revision=None, |
313 | 3408 | def is_compatible(self, source, target): | 3400 | possible_transports=None, _hook_master=None, run_hooks=True, |
300 | 3409 | # GenericBranch uses the public API, so always compatible | ||
301 | 3410 | return True | ||
302 | 3411 | |||
303 | 3412 | |||
304 | 3413 | class InterToBranch5(GenericInterBranch): | ||
305 | 3414 | |||
306 | 3415 | @staticmethod | ||
307 | 3416 | def _get_branch_formats_to_test(): | ||
308 | 3417 | return BranchFormat._default_format, BzrBranchFormat5() | ||
309 | 3418 | |||
310 | 3419 | def pull(self, overwrite=False, stop_revision=None, | ||
311 | 3420 | possible_transports=None, run_hooks=True, | ||
314 | 3421 | _override_hook_target=None, local=False): | 3401 | _override_hook_target=None, local=False): |
317 | 3422 | """Pull from source into self, updating my master if any. | 3402 | """See Branch.pull. |
318 | 3423 | 3403 | ||
319 | 3404 | This function is the core worker, used by GenericInterBranch.pull to | ||
320 | 3405 | avoid duplication when pulling source->master and source->local. | ||
321 | 3406 | |||
322 | 3407 | :param _hook_master: Private parameter - set the branch to | ||
323 | 3408 | be supplied as the master to pull hooks. | ||
324 | 3424 | :param run_hooks: Private parameter - if false, this branch | 3409 | :param run_hooks: Private parameter - if false, this branch |
325 | 3425 | is being called because it's the master of the primary branch, | 3410 | is being called because it's the master of the primary branch, |
326 | 3426 | so it should not run its hooks. | 3411 | so it should not run its hooks. |
327 | 3412 | :param _override_hook_target: Private parameter - set the branch to be | ||
328 | 3413 | supplied as the target_branch to pull hooks. | ||
329 | 3414 | :param local: Only update the local branch, and not the bound branch. | ||
330 | 3427 | """ | 3415 | """ |
333 | 3428 | bound_location = self.target.get_bound_location() | 3416 | # This type of branch can't be bound. |
334 | 3429 | if local and not bound_location: | 3417 | if local: |
335 | 3430 | raise errors.LocalRequiresBoundBranch() | 3418 | raise errors.LocalRequiresBoundBranch() |
341 | 3431 | master_branch = None | 3419 | result = PullResult() |
342 | 3432 | if not local and bound_location and self.source.user_url != bound_location: | 3420 | result.source_branch = self.source |
343 | 3433 | # not pulling from master, so we need to update master. | 3421 | if _override_hook_target is None: |
344 | 3434 | master_branch = self.target.get_master_branch(possible_transports) | 3422 | result.target_branch = self.target |
345 | 3435 | master_branch.lock_write() | 3423 | else: |
346 | 3424 | result.target_branch = _override_hook_target | ||
347 | 3425 | self.source.lock_read() | ||
348 | 3436 | try: | 3426 | try: |
357 | 3437 | if master_branch: | 3427 | # We assume that during 'pull' the target repository is closer than |
358 | 3438 | # pull from source into master. | 3428 | # the source one. |
359 | 3439 | master_branch.pull(self.source, overwrite, stop_revision, | 3429 | self.source.update_references(self.target) |
360 | 3440 | run_hooks=False) | 3430 | graph = self.target.repository.get_graph(self.source.repository) |
361 | 3441 | return super(InterToBranch5, self).pull(overwrite, | 3431 | # TODO: Branch formats should have a flag that indicates |
362 | 3442 | stop_revision, _hook_master=master_branch, | 3432 | # that revno's are expensive, and pull() should honor that flag. |
363 | 3443 | run_hooks=run_hooks, | 3433 | # -- JRV20090506 |
364 | 3444 | _override_hook_target=_override_hook_target) | 3434 | result.old_revno, result.old_revid = \ |
365 | 3435 | self.target.last_revision_info() | ||
366 | 3436 | self.target.update_revisions(self.source, stop_revision, | ||
367 | 3437 | overwrite=overwrite, graph=graph) | ||
368 | 3438 | # TODO: The old revid should be specified when merging tags, | ||
369 | 3439 | # so a tags implementation that versions tags can only | ||
370 | 3440 | # pull in the most recent changes. -- JRV20090506 | ||
371 | 3441 | result.tag_conflicts = self.source.tags.merge_to(self.target.tags, | ||
372 | 3442 | overwrite) | ||
373 | 3443 | result.new_revno, result.new_revid = self.target.last_revision_info() | ||
374 | 3444 | if _hook_master: | ||
375 | 3445 | result.master_branch = _hook_master | ||
376 | 3446 | result.local_branch = result.target_branch | ||
377 | 3447 | else: | ||
378 | 3448 | result.master_branch = result.target_branch | ||
379 | 3449 | result.local_branch = None | ||
380 | 3450 | if run_hooks: | ||
381 | 3451 | for hook in Branch.hooks['post_pull']: | ||
382 | 3452 | hook(result) | ||
383 | 3445 | finally: | 3453 | finally: |
386 | 3446 | if master_branch: | 3454 | self.source.unlock() |
387 | 3447 | master_branch.unlock() | 3455 | return result |
388 | 3448 | 3456 | ||
389 | 3449 | 3457 | ||
390 | 3450 | InterBranch.register_optimiser(GenericInterBranch) | 3458 | InterBranch.register_optimiser(GenericInterBranch) |
391 | 3451 | InterBranch.register_optimiser(InterToBranch5) | ||
392 | 3452 | 3459 | ||
393 | === modified file 'bzrlib/tests/per_branch/test_pull.py' | |||
394 | --- bzrlib/tests/per_branch/test_pull.py 2010-02-10 17:52:08 +0000 | |||
395 | +++ bzrlib/tests/per_branch/test_pull.py 2010-06-14 21:46:28 +0000 | |||
396 | @@ -98,17 +98,6 @@ | |||
397 | 98 | master_tree.branch.pull, other.branch, local = True) | 98 | master_tree.branch.pull, other.branch, local = True) |
398 | 99 | self.assertEqual([rev1], master_tree.branch.revision_history()) | 99 | self.assertEqual([rev1], master_tree.branch.revision_history()) |
399 | 100 | 100 | ||
400 | 101 | def test_pull_raises_specific_error_on_master_connection_error(self): | ||
401 | 102 | master_tree = self.make_branch_and_tree('master') | ||
402 | 103 | checkout = master_tree.branch.create_checkout('checkout') | ||
403 | 104 | other = master_tree.branch.bzrdir.sprout('other').open_workingtree() | ||
404 | 105 | # move the branch out of the way on disk to cause a connection | ||
405 | 106 | # error. | ||
406 | 107 | os.rename('master', 'master_gone') | ||
407 | 108 | # try to pull, which should raise a BoundBranchConnectionFailure. | ||
408 | 109 | self.assertRaises(errors.BoundBranchConnectionFailure, | ||
409 | 110 | checkout.branch.pull, other.branch) | ||
410 | 111 | |||
411 | 112 | def test_pull_returns_result(self): | 101 | def test_pull_returns_result(self): |
412 | 113 | parent = self.make_branch_and_tree('parent') | 102 | parent = self.make_branch_and_tree('parent') |
413 | 114 | parent.commit('1st post', rev_id='P1') | 103 | parent.commit('1st post', rev_id='P1') |
414 | 115 | 104 | ||
415 | === modified file 'bzrlib/tests/per_interbranch/__init__.py' | |||
416 | --- bzrlib/tests/per_interbranch/__init__.py 2009-05-07 05:08:46 +0000 | |||
417 | +++ bzrlib/tests/per_interbranch/__init__.py 2010-06-14 21:46:28 +0000 | |||
418 | @@ -144,8 +144,38 @@ | |||
419 | 144 | return newbranch.bzrdir | 144 | return newbranch.bzrdir |
420 | 145 | 145 | ||
421 | 146 | 146 | ||
422 | 147 | class StubWithFormat(object): | ||
423 | 148 | """A stub object used to check that convenience methods call Inter's.""" | ||
424 | 149 | |||
425 | 150 | _format = object() | ||
426 | 151 | |||
427 | 152 | |||
428 | 153 | class StubMatchingInter(object): | ||
429 | 154 | """An inter for tests. | ||
430 | 155 | |||
431 | 156 | This is not a subclass of InterBranch so that missing methods are caught | ||
432 | 157 | and added rather than actually trying to do something. | ||
433 | 158 | """ | ||
434 | 159 | |||
435 | 160 | _uses = [] | ||
436 | 161 | |||
437 | 162 | def __init__(self, source, target): | ||
438 | 163 | self.source = source | ||
439 | 164 | self.target = target | ||
440 | 165 | |||
441 | 166 | @classmethod | ||
442 | 167 | def is_compatible(klass, source, target): | ||
443 | 168 | return StubWithFormat._format in (source._format, target._format) | ||
444 | 169 | |||
445 | 170 | def copy_content_into(self, *args, **kwargs): | ||
446 | 171 | self.__class__._uses.append( | ||
447 | 172 | (self, 'copy_content_into', args, kwargs)) | ||
448 | 173 | |||
449 | 174 | |||
450 | 147 | def load_tests(standard_tests, module, loader): | 175 | def load_tests(standard_tests, module, loader): |
451 | 148 | submod_tests = loader.loadTestsFromModuleNames([ | 176 | submod_tests = loader.loadTestsFromModuleNames([ |
452 | 177 | 'bzrlib.tests.per_interbranch.test_get', | ||
453 | 178 | 'bzrlib.tests.per_interbranch.test_copy_content_into', | ||
454 | 149 | 'bzrlib.tests.per_interbranch.test_pull', | 179 | 'bzrlib.tests.per_interbranch.test_pull', |
455 | 150 | 'bzrlib.tests.per_interbranch.test_push', | 180 | 'bzrlib.tests.per_interbranch.test_push', |
456 | 151 | 'bzrlib.tests.per_interbranch.test_update_revisions', | 181 | 'bzrlib.tests.per_interbranch.test_update_revisions', |
457 | 152 | 182 | ||
458 | === added file 'bzrlib/tests/per_interbranch/test_copy_content_into.py' | |||
459 | --- bzrlib/tests/per_interbranch/test_copy_content_into.py 1970-01-01 00:00:00 +0000 | |||
460 | +++ bzrlib/tests/per_interbranch/test_copy_content_into.py 2010-06-14 21:46:28 +0000 | |||
461 | @@ -0,0 +1,47 @@ | |||
462 | 1 | # Copyright (C) 2010 Canonical Ltd | ||
463 | 2 | # | ||
464 | 3 | # This program is free software; you can redistribute it and/or modify | ||
465 | 4 | # it under the terms of the GNU General Public License as published by | ||
466 | 5 | # the Free Software Foundation; either version 2 of the License, or | ||
467 | 6 | # (at your option) any later version. | ||
468 | 7 | # | ||
469 | 8 | # This program is distributed in the hope that it will be useful, | ||
470 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
471 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
472 | 11 | # GNU General Public License for more details. | ||
473 | 12 | # | ||
474 | 13 | # You should have received a copy of the GNU General Public License | ||
475 | 14 | # along with this program; if not, write to the Free Software | ||
476 | 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
477 | 16 | |||
478 | 17 | """Tests for bzrlib.branch.InterBranch.copy_content_into.""" | ||
479 | 18 | |||
480 | 19 | from bzrlib import branch | ||
481 | 20 | from bzrlib.tests.per_interbranch import ( | ||
482 | 21 | StubMatchingInter, | ||
483 | 22 | StubWithFormat, | ||
484 | 23 | TestCaseWithInterBranch, | ||
485 | 24 | ) | ||
486 | 25 | |||
487 | 26 | |||
488 | 27 | class TestCopyContentInto(TestCaseWithInterBranch): | ||
489 | 28 | |||
490 | 29 | def test_contract_convenience_method(self): | ||
491 | 30 | self.tree1 = self.make_branch_and_tree('tree1') | ||
492 | 31 | rev1 = self.tree1.commit('one') | ||
493 | 32 | branch2 = self.make_to_branch('tree2') | ||
494 | 33 | branch2.repository.fetch(self.tree1.branch.repository) | ||
495 | 34 | self.tree1.branch.copy_content_into(branch2, revision_id=rev1) | ||
496 | 35 | |||
497 | 36 | def test_inter_is_used(self): | ||
498 | 37 | self.tree1 = self.make_branch_and_tree('tree1') | ||
499 | 38 | self.addCleanup(branch.InterBranch.unregister_optimiser, | ||
500 | 39 | StubMatchingInter) | ||
501 | 40 | branch.InterBranch.register_optimiser(StubMatchingInter) | ||
502 | 41 | del StubMatchingInter._uses[:] | ||
503 | 42 | self.tree1.branch.copy_content_into(StubWithFormat(), revision_id='54') | ||
504 | 43 | self.assertLength(1, StubMatchingInter._uses) | ||
505 | 44 | use = StubMatchingInter._uses[0] | ||
506 | 45 | self.assertEqual('copy_content_into', use[1]) | ||
507 | 46 | self.assertEqual('54', use[3]['revision_id']) | ||
508 | 47 | del StubMatchingInter._uses[:] | ||
509 | 0 | 48 | ||
510 | === added file 'bzrlib/tests/per_interbranch/test_get.py' | |||
511 | --- bzrlib/tests/per_interbranch/test_get.py 1970-01-01 00:00:00 +0000 | |||
512 | +++ bzrlib/tests/per_interbranch/test_get.py 2010-06-14 21:46:28 +0000 | |||
513 | @@ -0,0 +1,34 @@ | |||
514 | 1 | # Copyright (C) 2010 Canonical Ltd | ||
515 | 2 | # | ||
516 | 3 | # This program is free software; you can redistribute it and/or modify | ||
517 | 4 | # it under the terms of the GNU General Public License as published by | ||
518 | 5 | # the Free Software Foundation; either version 2 of the License, or | ||
519 | 6 | # (at your option) any later version. | ||
520 | 7 | # | ||
521 | 8 | # This program is distributed in the hope that it will be useful, | ||
522 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
523 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
524 | 11 | # GNU General Public License for more details. | ||
525 | 12 | # | ||
526 | 13 | # You should have received a copy of the GNU General Public License | ||
527 | 14 | # along with this program; if not, write to the Free Software | ||
528 | 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
529 | 16 | |||
530 | 17 | """Tests for bzrlib.branch.InterBranch.get.""" | ||
531 | 18 | |||
532 | 19 | from bzrlib import ( | ||
533 | 20 | branch, | ||
534 | 21 | ) | ||
535 | 22 | from bzrlib.tests.per_interbranch import ( | ||
536 | 23 | TestCaseWithInterBranch, | ||
537 | 24 | ) | ||
538 | 25 | |||
539 | 26 | |||
540 | 27 | class TestCopyContentInto(TestCaseWithInterBranch): | ||
541 | 28 | |||
542 | 29 | def test_gets_right_inter(self): | ||
543 | 30 | self.tree1 = self.make_branch_and_tree('tree1') | ||
544 | 31 | branch2 = self.make_to_branch('tree2') | ||
545 | 32 | self.assertIs(branch.InterBranch.get( | ||
546 | 33 | self.tree1.branch, branch2).__class__, | ||
547 | 34 | self.interbranch_class) | ||
548 | 0 | 35 | ||
549 | === modified file 'bzrlib/tests/per_interbranch/test_pull.py' | |||
550 | --- bzrlib/tests/per_interbranch/test_pull.py 2009-07-10 05:49:34 +0000 | |||
551 | +++ bzrlib/tests/per_interbranch/test_pull.py 2010-06-14 21:46:28 +0000 | |||
552 | @@ -76,13 +76,13 @@ | |||
553 | 76 | def test_pull_raises_specific_error_on_master_connection_error(self): | 76 | def test_pull_raises_specific_error_on_master_connection_error(self): |
554 | 77 | master_tree = self.make_from_branch_and_tree('master') | 77 | master_tree = self.make_from_branch_and_tree('master') |
555 | 78 | checkout = master_tree.branch.create_checkout('checkout') | 78 | checkout = master_tree.branch.create_checkout('checkout') |
557 | 79 | other = self.sprout_to(master_tree.branch.bzrdir, 'other').open_workingtree() | 79 | other = self.sprout_to(master_tree.branch.bzrdir, 'other').open_branch() |
558 | 80 | # move the branch out of the way on disk to cause a connection | 80 | # move the branch out of the way on disk to cause a connection |
559 | 81 | # error. | 81 | # error. |
560 | 82 | os.rename('master', 'master_gone') | 82 | os.rename('master', 'master_gone') |
561 | 83 | # try to pull, which should raise a BoundBranchConnectionFailure. | 83 | # try to pull, which should raise a BoundBranchConnectionFailure. |
562 | 84 | self.assertRaises(errors.BoundBranchConnectionFailure, | 84 | self.assertRaises(errors.BoundBranchConnectionFailure, |
564 | 85 | checkout.branch.pull, other.branch) | 85 | checkout.branch.pull, other) |
565 | 86 | 86 | ||
566 | 87 | def test_pull_returns_result(self): | 87 | def test_pull_returns_result(self): |
567 | 88 | parent = self.make_from_branch_and_tree('parent') | 88 | parent = self.make_from_branch_and_tree('parent') |
Tests failing: tests.blackbox. test_push. TestPush. test_push_ smart_tags_ streaming_ acceptance tests.blackbox. test_switch. TestSwitch. test_switch_ lightweight_ directory tests.blackbox. test_tags. TestTagging. test_branch_ push_pull_ merge_copies_ tags tests.blackbox. test_tags. TestTagging. test_list_ tags
ERROR: bzrlib.
ERROR: bzrlib.
ERROR: bzrlib.
ERROR: bzrlib.
I haven't reviewed yet.