Merge lp:~lifeless/bzr/loomsupport into lp:bzr

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
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.copy_content_into to a InterBranch method.

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
Vincent Ladeuil (vila) wrote :

Tests failing:
ERROR: bzrlib.tests.blackbox.test_push.TestPush.test_push_smart_tags_streaming_acceptance
ERROR: bzrlib.tests.blackbox.test_switch.TestSwitch.test_switch_lightweight_directory
ERROR: bzrlib.tests.blackbox.test_tags.TestTagging.test_branch_push_pull_merge_copies_tags
ERROR: bzrlib.tests.blackbox.test_tags.TestTagging.test_list_tags

I haven't reviewed yet.

review: Needs Fixing
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
=== modified file 'NEWS'
--- NEWS 2010-06-14 17:58:24 +0000
+++ NEWS 2010-06-14 21:46:28 +0000
@@ -34,29 +34,35 @@
34 (Martin [gz], Parth Malwankar, #501307)34 (Martin [gz], Parth Malwankar, #501307)
3535
36* ``bzr log --exclude-common-ancestry`` is now taken into account for36* ``bzr log --exclude-common-ancestry`` is now taken into account for
37 linear ancetries.37 linear ancetries. (Vincent Ladeuil, #575631)
38 (Vincent Ladeuil, #575631)
3938
40* Ensure that wrong path specifications in ``BZR_PLUGINS_AT`` display39* Ensure that wrong path specifications in ``BZR_PLUGINS_AT`` display
41 proper error messages. 40 proper error messages. (Vincent Ladeuil, #591215)
42 (Vincent Ladeuil, #591215)41
42* Explicitly removing ``--profile-imports`` option from parsed command-line
43 arguments on Windows, because bzr script does the same.
44 (Alexander Belchenko, #588277)
45
46* Fetching was slightly confused about the best code to use and was
47 using a new code path for all branches, resulting in more lookups than
48 necessary on old branches. (Robert Collins, #593515)
4349
44* Final fix for 'no help for command' issue. We now show a clean message50* Final fix for 'no help for command' issue. We now show a clean message
45 when a command has no help, document how to set help more clearly, and51 when a command has no help, document how to set help more clearly, and
46 test that all commands available to the test suite have help.52 test that all commands available to the test suite have help.
47 (Robert Collins, #177500)53 (Robert Collins, #177500)
4854
49* Explicitly removing ``--profile-imports`` option from parsed command-line
50 arguments on Windows, because bzr script does the same.
51 (Alexander Belchenko, #588277)
52
53* Relative imports in plugins are now handled correctly when using55* Relative imports in plugins are now handled correctly when using
54 BZR_PLUGINS_AT.56 BZR_PLUGINS_AT. (Vincent Ladeuil, #588959)
55 (Vincent Ladeuil, #588959)
5657
57Improvements58Improvements
58************59************
5960
61* ``Branch.copy_content_into`` is now a convenience method dispatching to
62 a ``InterBranch`` multi-method. This permits ``bzr-loom`` and other
63 plugins to intercept this even when a ``RemoteBranch`` proxy is in use.
64 (Robert Collins, #201613)
65
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``
61 do not cause modules to be loaded unnecessarily just because the plugin67 do not cause modules to be loaded unnecessarily just because the plugin
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%
6369
=== modified file 'bzrlib/branch.py'
--- bzrlib/branch.py 2010-06-07 20:25:05 +0000
+++ bzrlib/branch.py 2010-06-14 21:46:28 +0000
@@ -29,6 +29,7 @@
29 errors,29 errors,
30 lockdir,30 lockdir,
31 lockable_files,31 lockable_files,
32 remote,
32 repository,33 repository,
33 revision as _mod_revision,34 revision as _mod_revision,
34 rio,35 rio,
@@ -968,7 +969,6 @@
968 raise errors.NoSuchRevision(self, stop_revision)969 raise errors.NoSuchRevision(self, stop_revision)
969 return other_history[self_len:stop_revision]970 return other_history[self_len:stop_revision]
970971
971 @needs_write_lock
972 def update_revisions(self, other, stop_revision=None, overwrite=False,972 def update_revisions(self, other, stop_revision=None, overwrite=False,
973 graph=None):973 graph=None):
974 """Pull in new perfect-fit revisions.974 """Pull in new perfect-fit revisions.
@@ -1272,24 +1272,14 @@
1272 revno = 11272 revno = 1
1273 destination.set_last_revision_info(revno, revision_id)1273 destination.set_last_revision_info(revno, revision_id)
12741274
1275 @needs_read_lock
1276 def copy_content_into(self, destination, revision_id=None):1275 def copy_content_into(self, destination, revision_id=None):
1277 """Copy the content of self into destination.1276 """Copy the content of self into destination.
12781277
1279 revision_id: if not None, the revision history in the new branch will1278 revision_id: if not None, the revision history in the new branch will
1280 be truncated to end with revision_id.1279 be truncated to end with revision_id.
1281 """1280 """
1282 self.update_references(destination)1281 return InterBranch.get(self, destination).copy_content_into(
1283 self._synchronize_history(destination, revision_id)1282 revision_id=revision_id)
1284 try:
1285 parent = self.get_parent()
1286 except errors.InaccessibleParent, e:
1287 mutter('parent was not accessible to copy: %s', e)
1288 else:
1289 if parent:
1290 destination.set_parent(parent)
1291 if self._push_should_merge_tags():
1292 self.tags.merge_to(destination.tags)
12931283
1294 def update_references(self, target):1284 def update_references(self, target):
1295 if not getattr(self._format, 'supports_reference_locations', False):1285 if not getattr(self._format, 'supports_reference_locations', False):
@@ -3233,110 +3223,112 @@
32333223
32343224
3235class GenericInterBranch(InterBranch):3225class GenericInterBranch(InterBranch):
3236 """InterBranch implementation that uses public Branch functions.3226 """InterBranch implementation that uses public Branch functions."""
3237 """3227
3228 @classmethod
3229 def is_compatible(klass, source, target):
3230 # GenericBranch uses the public API, so always compatible
3231 return True
32383232
3239 @staticmethod3233 @staticmethod
3240 def _get_branch_formats_to_test():3234 def _get_branch_formats_to_test():
3241 return BranchFormat._default_format, BranchFormat._default_format3235 return BranchFormat._default_format, BranchFormat._default_format
32423236
3237 @classmethod
3238 def unwrap_format(klass, format):
3239 if isinstance(format, remote.RemoteBranchFormat):
3240 format._ensure_real()
3241 return format._custom_format
3242 return format
3243
3244 @needs_write_lock
3245 def copy_content_into(self, revision_id=None):
3246 """Copy the content of source into target
3247
3248 revision_id: if not None, the revision history in the new branch will
3249 be truncated to end with revision_id.
3250 """
3251 self.source.update_references(self.target)
3252 self.source._synchronize_history(self.target, revision_id)
3253 try:
3254 parent = self.source.get_parent()
3255 except errors.InaccessibleParent, e:
3256 mutter('parent was not accessible to copy: %s', e)
3257 else:
3258 if parent:
3259 self.target.set_parent(parent)
3260 if self.source._push_should_merge_tags():
3261 self.source.tags.merge_to(self.target.tags)
3262
3263 @needs_write_lock
3243 def update_revisions(self, stop_revision=None, overwrite=False,3264 def update_revisions(self, stop_revision=None, overwrite=False,
3244 graph=None):3265 graph=None):
3245 """See InterBranch.update_revisions()."""3266 """See InterBranch.update_revisions()."""
3246 self.source.lock_read()3267 other_revno, other_last_revision = self.source.last_revision_info()
3247 try:3268 stop_revno = None # unknown
3248 other_revno, other_last_revision = self.source.last_revision_info()3269 if stop_revision is None:
3249 stop_revno = None # unknown3270 stop_revision = other_last_revision
3250 if stop_revision is None:3271 if _mod_revision.is_null(stop_revision):
3251 stop_revision = other_last_revision3272 # if there are no commits, we're done.
3252 if _mod_revision.is_null(stop_revision):3273 return
3253 # if there are no commits, we're done.3274 stop_revno = other_revno
3254 return
3255 stop_revno = other_revno
32563275
3257 # what's the current last revision, before we fetch [and change it3276 # what's the current last revision, before we fetch [and change it
3258 # possibly]3277 # possibly]
3259 last_rev = _mod_revision.ensure_null(self.target.last_revision())3278 last_rev = _mod_revision.ensure_null(self.target.last_revision())
3260 # we fetch here so that we don't process data twice in the common3279 # we fetch here so that we don't process data twice in the common
3261 # case of having something to pull, and so that the check for3280 # case of having something to pull, and so that the check for
3262 # already merged can operate on the just fetched graph, which will3281 # already merged can operate on the just fetched graph, which will
3263 # be cached in memory.3282 # be cached in memory.
3264 self.target.fetch(self.source, stop_revision)3283 self.target.fetch(self.source, stop_revision)
3265 # Check to see if one is an ancestor of the other3284 # Check to see if one is an ancestor of the other
3266 if not overwrite:3285 if not overwrite:
3267 if graph is None:3286 if graph is None:
3268 graph = self.target.repository.get_graph()3287 graph = self.target.repository.get_graph()
3269 if self.target._check_if_descendant_or_diverged(3288 if self.target._check_if_descendant_or_diverged(
3270 stop_revision, last_rev, graph, self.source):3289 stop_revision, last_rev, graph, self.source):
3271 # stop_revision is a descendant of last_rev, but we aren't3290 # stop_revision is a descendant of last_rev, but we aren't
3272 # overwriting, so we're done.3291 # overwriting, so we're done.
3273 return3292 return
3274 if stop_revno is None:3293 if stop_revno is None:
3275 if graph is None:3294 if graph is None:
3276 graph = self.target.repository.get_graph()3295 graph = self.target.repository.get_graph()
3277 this_revno, this_last_revision = \3296 this_revno, this_last_revision = \
3278 self.target.last_revision_info()3297 self.target.last_revision_info()
3279 stop_revno = graph.find_distance_to_null(stop_revision,3298 stop_revno = graph.find_distance_to_null(stop_revision,
3280 [(other_last_revision, other_revno),3299 [(other_last_revision, other_revno),
3281 (this_last_revision, this_revno)])3300 (this_last_revision, this_revno)])
3282 self.target.set_last_revision_info(stop_revno, stop_revision)3301 self.target.set_last_revision_info(stop_revno, stop_revision)
3283 finally:
3284 self.source.unlock()
32853302
3286 def pull(self, overwrite=False, stop_revision=None,3303 def pull(self, overwrite=False, stop_revision=None,
3287 possible_transports=None, _hook_master=None, run_hooks=True,3304 possible_transports=None, run_hooks=True,
3288 _override_hook_target=None, local=False):3305 _override_hook_target=None, local=False):
3289 """See Branch.pull.3306 """Pull from source into self, updating my master if any.
32903307
3291 :param _hook_master: Private parameter - set the branch to
3292 be supplied as the master to pull hooks.
3293 :param run_hooks: Private parameter - if false, this branch3308 :param run_hooks: Private parameter - if false, this branch
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,
3295 so it should not run its hooks.3310 so it should not run its hooks.
3296 :param _override_hook_target: Private parameter - set the branch to be
3297 supplied as the target_branch to pull hooks.
3298 :param local: Only update the local branch, and not the bound branch.
3299 """3311 """
3300 # This type of branch can't be bound.3312 bound_location = self.target.get_bound_location()
3301 if local:3313 if local and not bound_location:
3302 raise errors.LocalRequiresBoundBranch()3314 raise errors.LocalRequiresBoundBranch()
3303 result = PullResult()3315 master_branch = None
3304 result.source_branch = self.source3316 if not local and bound_location and self.source.user_url != bound_location:
3305 if _override_hook_target is None:3317 # not pulling from master, so we need to update master.
3306 result.target_branch = self.target3318 master_branch = self.target.get_master_branch(possible_transports)
3307 else:3319 master_branch.lock_write()
3308 result.target_branch = _override_hook_target
3309 self.source.lock_read()
3310 try:3320 try:
3311 # We assume that during 'pull' the target repository is closer than3321 if master_branch:
3312 # the source one.3322 # pull from source into master.
3313 self.source.update_references(self.target)3323 master_branch.pull(self.source, overwrite, stop_revision,
3314 graph = self.target.repository.get_graph(self.source.repository)3324 run_hooks=False)
3315 # TODO: Branch formats should have a flag that indicates 3325 return self._pull(overwrite,
3316 # that revno's are expensive, and pull() should honor that flag.3326 stop_revision, _hook_master=master_branch,
3317 # -- JRV200905063327 run_hooks=run_hooks,
3318 result.old_revno, result.old_revid = \3328 _override_hook_target=_override_hook_target)
3319 self.target.last_revision_info()
3320 self.target.update_revisions(self.source, stop_revision,
3321 overwrite=overwrite, graph=graph)
3322 # TODO: The old revid should be specified when merging tags,
3323 # so a tags implementation that versions tags can only
3324 # pull in the most recent changes. -- JRV20090506
3325 result.tag_conflicts = self.source.tags.merge_to(self.target.tags,
3326 overwrite)
3327 result.new_revno, result.new_revid = self.target.last_revision_info()
3328 if _hook_master:
3329 result.master_branch = _hook_master
3330 result.local_branch = result.target_branch
3331 else:
3332 result.master_branch = result.target_branch
3333 result.local_branch = None
3334 if run_hooks:
3335 for hook in Branch.hooks['post_pull']:
3336 hook(result)
3337 finally:3329 finally:
3338 self.source.unlock()3330 if master_branch:
3339 return result3331 master_branch.unlock()
33403332
3341 def push(self, overwrite=False, stop_revision=None,3333 def push(self, overwrite=False, stop_revision=None,
3342 _override_hook_source_branch=None):3334 _override_hook_source_branch=None):
@@ -3404,48 +3396,63 @@
3404 _run_hooks()3396 _run_hooks()
3405 return result3397 return result
34063398
3407 @classmethod3399 def _pull(self, overwrite=False, stop_revision=None,
3408 def is_compatible(self, source, target):3400 possible_transports=None, _hook_master=None, run_hooks=True,
3409 # GenericBranch uses the public API, so always compatible
3410 return True
3411
3412
3413class InterToBranch5(GenericInterBranch):
3414
3415 @staticmethod
3416 def _get_branch_formats_to_test():
3417 return BranchFormat._default_format, BzrBranchFormat5()
3418
3419 def pull(self, overwrite=False, stop_revision=None,
3420 possible_transports=None, run_hooks=True,
3421 _override_hook_target=None, local=False):3401 _override_hook_target=None, local=False):
3422 """Pull from source into self, updating my master if any.3402 """See Branch.pull.
34233403
3404 This function is the core worker, used by GenericInterBranch.pull to
3405 avoid duplication when pulling source->master and source->local.
3406
3407 :param _hook_master: Private parameter - set the branch to
3408 be supplied as the master to pull hooks.
3424 :param run_hooks: Private parameter - if false, this branch3409 :param run_hooks: Private parameter - if false, this branch
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,
3426 so it should not run its hooks.3411 so it should not run its hooks.
3412 :param _override_hook_target: Private parameter - set the branch to be
3413 supplied as the target_branch to pull hooks.
3414 :param local: Only update the local branch, and not the bound branch.
3427 """3415 """
3428 bound_location = self.target.get_bound_location()3416 # This type of branch can't be bound.
3429 if local and not bound_location:3417 if local:
3430 raise errors.LocalRequiresBoundBranch()3418 raise errors.LocalRequiresBoundBranch()
3431 master_branch = None3419 result = PullResult()
3432 if not local and bound_location and self.source.user_url != bound_location:3420 result.source_branch = self.source
3433 # not pulling from master, so we need to update master.3421 if _override_hook_target is None:
3434 master_branch = self.target.get_master_branch(possible_transports)3422 result.target_branch = self.target
3435 master_branch.lock_write()3423 else:
3424 result.target_branch = _override_hook_target
3425 self.source.lock_read()
3436 try:3426 try:
3437 if master_branch:3427 # We assume that during 'pull' the target repository is closer than
3438 # pull from source into master.3428 # the source one.
3439 master_branch.pull(self.source, overwrite, stop_revision,3429 self.source.update_references(self.target)
3440 run_hooks=False)3430 graph = self.target.repository.get_graph(self.source.repository)
3441 return super(InterToBranch5, self).pull(overwrite,3431 # TODO: Branch formats should have a flag that indicates
3442 stop_revision, _hook_master=master_branch,3432 # that revno's are expensive, and pull() should honor that flag.
3443 run_hooks=run_hooks,3433 # -- JRV20090506
3444 _override_hook_target=_override_hook_target)3434 result.old_revno, result.old_revid = \
3435 self.target.last_revision_info()
3436 self.target.update_revisions(self.source, stop_revision,
3437 overwrite=overwrite, graph=graph)
3438 # TODO: The old revid should be specified when merging tags,
3439 # so a tags implementation that versions tags can only
3440 # pull in the most recent changes. -- JRV20090506
3441 result.tag_conflicts = self.source.tags.merge_to(self.target.tags,
3442 overwrite)
3443 result.new_revno, result.new_revid = self.target.last_revision_info()
3444 if _hook_master:
3445 result.master_branch = _hook_master
3446 result.local_branch = result.target_branch
3447 else:
3448 result.master_branch = result.target_branch
3449 result.local_branch = None
3450 if run_hooks:
3451 for hook in Branch.hooks['post_pull']:
3452 hook(result)
3445 finally:3453 finally:
3446 if master_branch:3454 self.source.unlock()
3447 master_branch.unlock()3455 return result
34483456
34493457
3450InterBranch.register_optimiser(GenericInterBranch)3458InterBranch.register_optimiser(GenericInterBranch)
3451InterBranch.register_optimiser(InterToBranch5)
34523459
=== modified file 'bzrlib/tests/per_branch/test_pull.py'
--- bzrlib/tests/per_branch/test_pull.py 2010-02-10 17:52:08 +0000
+++ bzrlib/tests/per_branch/test_pull.py 2010-06-14 21:46:28 +0000
@@ -98,17 +98,6 @@
98 master_tree.branch.pull, other.branch, local = True)98 master_tree.branch.pull, other.branch, local = True)
99 self.assertEqual([rev1], master_tree.branch.revision_history())99 self.assertEqual([rev1], master_tree.branch.revision_history())
100100
101 def test_pull_raises_specific_error_on_master_connection_error(self):
102 master_tree = self.make_branch_and_tree('master')
103 checkout = master_tree.branch.create_checkout('checkout')
104 other = master_tree.branch.bzrdir.sprout('other').open_workingtree()
105 # move the branch out of the way on disk to cause a connection
106 # error.
107 os.rename('master', 'master_gone')
108 # try to pull, which should raise a BoundBranchConnectionFailure.
109 self.assertRaises(errors.BoundBranchConnectionFailure,
110 checkout.branch.pull, other.branch)
111
112 def test_pull_returns_result(self):101 def test_pull_returns_result(self):
113 parent = self.make_branch_and_tree('parent')102 parent = self.make_branch_and_tree('parent')
114 parent.commit('1st post', rev_id='P1')103 parent.commit('1st post', rev_id='P1')
115104
=== modified file 'bzrlib/tests/per_interbranch/__init__.py'
--- bzrlib/tests/per_interbranch/__init__.py 2009-05-07 05:08:46 +0000
+++ bzrlib/tests/per_interbranch/__init__.py 2010-06-14 21:46:28 +0000
@@ -144,8 +144,38 @@
144 return newbranch.bzrdir144 return newbranch.bzrdir
145145
146146
147class StubWithFormat(object):
148 """A stub object used to check that convenience methods call Inter's."""
149
150 _format = object()
151
152
153class StubMatchingInter(object):
154 """An inter for tests.
155
156 This is not a subclass of InterBranch so that missing methods are caught
157 and added rather than actually trying to do something.
158 """
159
160 _uses = []
161
162 def __init__(self, source, target):
163 self.source = source
164 self.target = target
165
166 @classmethod
167 def is_compatible(klass, source, target):
168 return StubWithFormat._format in (source._format, target._format)
169
170 def copy_content_into(self, *args, **kwargs):
171 self.__class__._uses.append(
172 (self, 'copy_content_into', args, kwargs))
173
174
147def load_tests(standard_tests, module, loader):175def load_tests(standard_tests, module, loader):
148 submod_tests = loader.loadTestsFromModuleNames([176 submod_tests = loader.loadTestsFromModuleNames([
177 'bzrlib.tests.per_interbranch.test_get',
178 'bzrlib.tests.per_interbranch.test_copy_content_into',
149 'bzrlib.tests.per_interbranch.test_pull',179 'bzrlib.tests.per_interbranch.test_pull',
150 'bzrlib.tests.per_interbranch.test_push',180 'bzrlib.tests.per_interbranch.test_push',
151 'bzrlib.tests.per_interbranch.test_update_revisions',181 'bzrlib.tests.per_interbranch.test_update_revisions',
152182
=== added file 'bzrlib/tests/per_interbranch/test_copy_content_into.py'
--- bzrlib/tests/per_interbranch/test_copy_content_into.py 1970-01-01 00:00:00 +0000
+++ bzrlib/tests/per_interbranch/test_copy_content_into.py 2010-06-14 21:46:28 +0000
@@ -0,0 +1,47 @@
1# Copyright (C) 2010 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17"""Tests for bzrlib.branch.InterBranch.copy_content_into."""
18
19from bzrlib import branch
20from bzrlib.tests.per_interbranch import (
21 StubMatchingInter,
22 StubWithFormat,
23 TestCaseWithInterBranch,
24 )
25
26
27class TestCopyContentInto(TestCaseWithInterBranch):
28
29 def test_contract_convenience_method(self):
30 self.tree1 = self.make_branch_and_tree('tree1')
31 rev1 = self.tree1.commit('one')
32 branch2 = self.make_to_branch('tree2')
33 branch2.repository.fetch(self.tree1.branch.repository)
34 self.tree1.branch.copy_content_into(branch2, revision_id=rev1)
35
36 def test_inter_is_used(self):
37 self.tree1 = self.make_branch_and_tree('tree1')
38 self.addCleanup(branch.InterBranch.unregister_optimiser,
39 StubMatchingInter)
40 branch.InterBranch.register_optimiser(StubMatchingInter)
41 del StubMatchingInter._uses[:]
42 self.tree1.branch.copy_content_into(StubWithFormat(), revision_id='54')
43 self.assertLength(1, StubMatchingInter._uses)
44 use = StubMatchingInter._uses[0]
45 self.assertEqual('copy_content_into', use[1])
46 self.assertEqual('54', use[3]['revision_id'])
47 del StubMatchingInter._uses[:]
048
=== added file 'bzrlib/tests/per_interbranch/test_get.py'
--- bzrlib/tests/per_interbranch/test_get.py 1970-01-01 00:00:00 +0000
+++ bzrlib/tests/per_interbranch/test_get.py 2010-06-14 21:46:28 +0000
@@ -0,0 +1,34 @@
1# Copyright (C) 2010 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17"""Tests for bzrlib.branch.InterBranch.get."""
18
19from bzrlib import (
20 branch,
21 )
22from bzrlib.tests.per_interbranch import (
23 TestCaseWithInterBranch,
24 )
25
26
27class TestCopyContentInto(TestCaseWithInterBranch):
28
29 def test_gets_right_inter(self):
30 self.tree1 = self.make_branch_and_tree('tree1')
31 branch2 = self.make_to_branch('tree2')
32 self.assertIs(branch.InterBranch.get(
33 self.tree1.branch, branch2).__class__,
34 self.interbranch_class)
035
=== modified file 'bzrlib/tests/per_interbranch/test_pull.py'
--- bzrlib/tests/per_interbranch/test_pull.py 2009-07-10 05:49:34 +0000
+++ bzrlib/tests/per_interbranch/test_pull.py 2010-06-14 21:46:28 +0000
@@ -76,13 +76,13 @@
76 def test_pull_raises_specific_error_on_master_connection_error(self):76 def test_pull_raises_specific_error_on_master_connection_error(self):
77 master_tree = self.make_from_branch_and_tree('master')77 master_tree = self.make_from_branch_and_tree('master')
78 checkout = master_tree.branch.create_checkout('checkout')78 checkout = master_tree.branch.create_checkout('checkout')
79 other = self.sprout_to(master_tree.branch.bzrdir, 'other').open_workingtree()79 other = self.sprout_to(master_tree.branch.bzrdir, 'other').open_branch()
80 # move the branch out of the way on disk to cause a connection80 # move the branch out of the way on disk to cause a connection
81 # error.81 # error.
82 os.rename('master', 'master_gone')82 os.rename('master', 'master_gone')
83 # try to pull, which should raise a BoundBranchConnectionFailure.83 # try to pull, which should raise a BoundBranchConnectionFailure.
84 self.assertRaises(errors.BoundBranchConnectionFailure,84 self.assertRaises(errors.BoundBranchConnectionFailure,
85 checkout.branch.pull, other.branch)85 checkout.branch.pull, other)
8686
87 def test_pull_returns_result(self):87 def test_pull_returns_result(self):
88 parent = self.make_from_branch_and_tree('parent')88 parent = self.make_from_branch_and_tree('parent')