90
90
self.assertRaises(errors.BoundBranchConnectionFailure,
91
91
other.branch.push, checkout.branch)
93
def test_push_uses_read_lock(self):
94
"""Push should only need a read lock on the source side."""
95
source = self.make_branch_and_tree('source')
96
target = self.make_branch('target')
98
self.build_tree(['source/a'])
102
source.branch.lock_read()
106
source.branch.push(target, stop_revision=source.last_revision())
110
source.branch.unlock()
112
def test_push_within_repository(self):
113
"""Push from one branch to another inside the same repository."""
115
repo = self.make_repository('repo', shared=True)
116
except (errors.IncompatibleFormat, errors.UninitializableFormat):
117
# This Branch format cannot create shared repositories
119
# This is a little bit trickier because make_branch_and_tree will not
120
# re-use a shared repository.
121
a_bzrdir = self.make_bzrdir('repo/tree')
123
a_branch = self.branch_format.initialize(a_bzrdir)
124
except (errors.UninitializableFormat):
125
# Cannot create these branches
127
tree = a_branch.bzrdir.create_workingtree()
128
self.build_tree(['repo/tree/a'])
132
to_bzrdir = self.make_bzrdir('repo/branch')
133
to_branch = self.branch_format.initialize(to_bzrdir)
134
tree.branch.push(to_branch)
136
self.assertEqual(tree.branch.last_revision(),
137
to_branch.last_revision())
94
140
class TestPushHook(TestCaseWithBranch):