4988.10.5
by John Arbash Meinel
Merge bzr.dev 5021 to resolve NEWS |
1 |
# Copyright (C) 2007-2010 Canonical Ltd
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
16 |
|
17 |
"""Tests for branch.push behaviour."""
|
|
18 |
||
3904.3.5
by Andrew Bennetts
Improve the test; now 4/7 passing. |
19 |
from cStringIO import StringIO |
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
20 |
import os |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
21 |
|
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
22 |
from bzrlib import ( |
23 |
branch, |
|
24 |
builtins, |
|
25 |
bzrdir, |
|
4332.3.35
by Robert Collins
Fix failing tests. |
26 |
check, |
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
27 |
debug, |
28 |
errors, |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
29 |
memorytree, |
3904.3.5
by Andrew Bennetts
Improve the test; now 4/7 passing. |
30 |
push, |
4035.2.1
by Andrew Bennetts
Fix unnecessary get_parent_map calls after insert_stream during push. |
31 |
repository, |
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
32 |
revision, |
5348.1.2
by Martin Pool
Deprecate casting PushResult and PullResult to int to get the relative revno change |
33 |
symbol_versioning, |
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
34 |
tests, |
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
35 |
transport, |
36 |
)
|
|
37 |
from bzrlib.smart import ( |
|
38 |
client, |
|
39 |
server, |
|
40 |
repository as _mod_smart_repo, |
|
41 |
)
|
|
5017.3.29
by Vincent Ladeuil
-s bt.per_branch.test_push passing |
42 |
from bzrlib.tests import ( |
43 |
per_branch, |
|
44 |
test_server, |
|
45 |
)
|
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
46 |
|
47 |
||
48 |
class TestPush(per_branch.TestCaseWithBranch): |
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
49 |
|
50 |
def test_push_convergence_simple(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
51 |
# when revisions are pushed, the left-most accessible parents must
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
52 |
# become the revision-history.
|
53 |
mine = self.make_branch_and_tree('mine') |
|
54 |
mine.commit('1st post', rev_id='P1', allow_pointless=True) |
|
55 |
other = mine.bzrdir.sprout('other').open_workingtree() |
|
56 |
other.commit('my change', rev_id='M1', allow_pointless=True) |
|
57 |
mine.merge_from_branch(other.branch) |
|
58 |
mine.commit('merge my change', rev_id='P2') |
|
2297.1.4
by Martin Pool
Push now returns a PushResult rather than just an integer. |
59 |
result = mine.branch.push(other.branch) |
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
60 |
self.assertEqual(['P1', 'P2'], other.branch.revision_history()) |
2297.1.4
by Martin Pool
Push now returns a PushResult rather than just an integer. |
61 |
# result object contains some structured data
|
62 |
self.assertEqual(result.old_revid, 'M1') |
|
63 |
self.assertEqual(result.new_revid, 'P2') |
|
64 |
# and it can be treated as an integer for compatibility
|
|
5348.1.2
by Martin Pool
Deprecate casting PushResult and PullResult to int to get the relative revno change |
65 |
self.assertEqual(self.applyDeprecated( |
66 |
symbol_versioning.deprecated_in((2, 3, 0)), |
|
67 |
result.__int__), |
|
68 |
0) |
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
69 |
|
70 |
def test_push_merged_indirect(self): |
|
71 |
# it should be possible to do a push from one branch into another
|
|
72 |
# when the tip of the target was merged into the source branch
|
|
73 |
# via a third branch - so its buried in the ancestry and is not
|
|
74 |
# directly accessible.
|
|
75 |
mine = self.make_branch_and_tree('mine') |
|
76 |
mine.commit('1st post', rev_id='P1', allow_pointless=True) |
|
77 |
target = mine.bzrdir.sprout('target').open_workingtree() |
|
78 |
target.commit('my change', rev_id='M1', allow_pointless=True) |
|
79 |
other = mine.bzrdir.sprout('other').open_workingtree() |
|
80 |
other.merge_from_branch(target.branch) |
|
81 |
other.commit('merge my change', rev_id='O2') |
|
82 |
mine.merge_from_branch(other.branch) |
|
83 |
mine.commit('merge other', rev_id='P2') |
|
84 |
mine.branch.push(target.branch) |
|
85 |
self.assertEqual(['P1', 'P2'], target.branch.revision_history()) |
|
86 |
||
87 |
def test_push_to_checkout_updates_master(self): |
|
88 |
"""Pushing into a checkout updates the checkout and the master branch"""
|
|
89 |
master_tree = self.make_branch_and_tree('master') |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
90 |
checkout = self.make_branch_and_tree('checkout') |
91 |
try: |
|
92 |
checkout.branch.bind(master_tree.branch) |
|
93 |
except errors.UpgradeRequired: |
|
94 |
# cant bind this format, the test is irrelevant.
|
|
95 |
return
|
|
96 |
rev1 = checkout.commit('master') |
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
97 |
|
98 |
other = master_tree.branch.bzrdir.sprout('other').open_workingtree() |
|
99 |
rev2 = other.commit('other commit') |
|
100 |
# now push, which should update both checkout and master.
|
|
101 |
other.branch.push(checkout.branch) |
|
102 |
self.assertEqual([rev1, rev2], checkout.branch.revision_history()) |
|
103 |
self.assertEqual([rev1, rev2], master_tree.branch.revision_history()) |
|
104 |
||
105 |
def test_push_raises_specific_error_on_master_connection_error(self): |
|
106 |
master_tree = self.make_branch_and_tree('master') |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
107 |
checkout = self.make_branch_and_tree('checkout') |
108 |
try: |
|
109 |
checkout.branch.bind(master_tree.branch) |
|
110 |
except errors.UpgradeRequired: |
|
111 |
# cant bind this format, the test is irrelevant.
|
|
112 |
return
|
|
2245.2.1
by Robert Collins
Split branch pushing out of branch pulling. |
113 |
other = master_tree.branch.bzrdir.sprout('other').open_workingtree() |
114 |
# move the branch out of the way on disk to cause a connection
|
|
115 |
# error.
|
|
116 |
os.rename('master', 'master_gone') |
|
117 |
# try to push, which should raise a BoundBranchConnectionFailure.
|
|
118 |
self.assertRaises(errors.BoundBranchConnectionFailure, |
|
119 |
other.branch.push, checkout.branch) |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
120 |
|
2279.1.1
by John Arbash Meinel
Branch.push() only needs a read lock. |
121 |
def test_push_uses_read_lock(self): |
122 |
"""Push should only need a read lock on the source side."""
|
|
123 |
source = self.make_branch_and_tree('source') |
|
124 |
target = self.make_branch('target') |
|
125 |
||
2381.1.3
by Robert Collins
Review feedback. |
126 |
self.build_tree(['source/a']) |
2279.1.1
by John Arbash Meinel
Branch.push() only needs a read lock. |
127 |
source.add(['a']) |
128 |
source.commit('a') |
|
129 |
||
130 |
source.branch.lock_read() |
|
131 |
try: |
|
132 |
target.lock_write() |
|
133 |
try: |
|
134 |
source.branch.push(target, stop_revision=source.last_revision()) |
|
135 |
finally: |
|
136 |
target.unlock() |
|
137 |
finally: |
|
138 |
source.branch.unlock() |
|
139 |
||
2279.1.3
by John Arbash Meinel
Switch the test to being a branch_implementation test. |
140 |
def test_push_within_repository(self): |
141 |
"""Push from one branch to another inside the same repository."""
|
|
142 |
try: |
|
143 |
repo = self.make_repository('repo', shared=True) |
|
144 |
except (errors.IncompatibleFormat, errors.UninitializableFormat): |
|
145 |
# This Branch format cannot create shared repositories
|
|
146 |
return
|
|
147 |
# This is a little bit trickier because make_branch_and_tree will not
|
|
148 |
# re-use a shared repository.
|
|
149 |
a_bzrdir = self.make_bzrdir('repo/tree') |
|
150 |
try: |
|
151 |
a_branch = self.branch_format.initialize(a_bzrdir) |
|
152 |
except (errors.UninitializableFormat): |
|
153 |
# Cannot create these branches
|
|
154 |
return
|
|
2018.5.97
by Andrew Bennetts
Fix more tests. |
155 |
try: |
156 |
tree = a_branch.bzrdir.create_workingtree() |
|
157 |
except errors.NotLocalUrl: |
|
5017.3.29
by Vincent Ladeuil
-s bt.per_branch.test_push passing |
158 |
if self.vfs_transport_factory is test_server.LocalURLServer: |
2018.5.130
by Robert Collins
Make all branch_implementations tests pass. |
159 |
# the branch is colocated on disk, we cannot create a checkout.
|
160 |
# hopefully callers will expect this.
|
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
161 |
local_controldir= bzrdir.BzrDir.open( |
162 |
self.get_vfs_only_url('repo/tree')) |
|
2018.5.130
by Robert Collins
Make all branch_implementations tests pass. |
163 |
tree = local_controldir.create_workingtree() |
164 |
else: |
|
165 |
tree = a_branch.create_checkout('repo/tree', lightweight=True) |
|
2381.1.3
by Robert Collins
Review feedback. |
166 |
self.build_tree(['repo/tree/a']) |
2279.1.3
by John Arbash Meinel
Switch the test to being a branch_implementation test. |
167 |
tree.add(['a']) |
168 |
tree.commit('a') |
|
169 |
||
170 |
to_bzrdir = self.make_bzrdir('repo/branch') |
|
171 |
to_branch = self.branch_format.initialize(to_bzrdir) |
|
172 |
tree.branch.push(to_branch) |
|
173 |
||
174 |
self.assertEqual(tree.branch.last_revision(), |
|
175 |
to_branch.last_revision()) |
|
176 |
||
3449.1.2
by Andrew Bennetts
Add test and NEWS entry. |
177 |
def test_push_overwrite_of_non_tip_with_stop_revision(self): |
178 |
"""Combining the stop_revision and overwrite options works.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
179 |
|
3449.1.2
by Andrew Bennetts
Add test and NEWS entry. |
180 |
This was <https://bugs.launchpad.net/bzr/+bug/234229>.
|
181 |
"""
|
|
182 |
source = self.make_branch_and_tree('source') |
|
183 |
target = self.make_branch('target') |
|
184 |
||
185 |
source.commit('1st commit') |
|
186 |
source.branch.push(target) |
|
187 |
source.commit('2nd commit', rev_id='rev-2') |
|
188 |
source.commit('3rd commit') |
|
189 |
||
190 |
source.branch.push(target, stop_revision='rev-2', overwrite=True) |
|
191 |
self.assertEqual('rev-2', target.last_revision()) |
|
192 |
||
3904.3.5
by Andrew Bennetts
Improve the test; now 4/7 passing. |
193 |
def test_push_with_default_stacking_does_not_create_broken_branch(self): |
3904.3.7
by Andrew Bennetts
Comment the new tests. |
194 |
"""Pushing a new standalone branch works even when there's a default
|
195 |
stacking policy at the destination.
|
|
196 |
||
197 |
The new branch will preserve the repo format (even if it isn't the
|
|
198 |
default for the branch), and will be stacked when the repo format
|
|
199 |
allows (which means that the branch format isn't necessarly preserved).
|
|
200 |
"""
|
|
3904.3.6
by Andrew Bennetts
Skip test for two formats, and fix format 5 by avoiding a full history sync with non-format5 branches. |
201 |
if isinstance(self.branch_format, branch.BzrBranchFormat4): |
202 |
raise tests.TestNotApplicable('Not a metadir format.') |
|
203 |
if isinstance(self.branch_format, branch.BranchReferenceFormat): |
|
3904.3.7
by Andrew Bennetts
Comment the new tests. |
204 |
# This test could in principle apply to BranchReferenceFormat, but
|
205 |
# make_branch_builder doesn't support it.
|
|
3904.3.6
by Andrew Bennetts
Skip test for two formats, and fix format 5 by avoiding a full history sync with non-format5 branches. |
206 |
raise tests.TestSkipped( |
207 |
"BranchBuilder can't make reference branches.") |
|
3904.3.7
by Andrew Bennetts
Comment the new tests. |
208 |
# Make a branch called "local" in a stackable repository
|
209 |
# The branch has 3 revisions:
|
|
210 |
# - rev-1, adds a file
|
|
211 |
# - rev-2, no changes
|
|
212 |
# - rev-3, modifies the file.
|
|
3904.3.5
by Andrew Bennetts
Improve the test; now 4/7 passing. |
213 |
repo = self.make_repository('repo', shared=True, format='1.6') |
214 |
builder = self.make_branch_builder('repo/local') |
|
3904.3.4
by Andrew Bennetts
First cut of a branch_implementations test. It fails. |
215 |
builder.start_series() |
216 |
builder.build_snapshot('rev-1', None, [ |
|
217 |
('add', ('', 'root-id', 'directory', '')), |
|
218 |
('add', ('filename', 'f-id', 'file', 'content\n'))]) |
|
219 |
builder.build_snapshot('rev-2', ['rev-1'], []) |
|
220 |
builder.build_snapshot('rev-3', ['rev-2'], |
|
221 |
[('modify', ('f-id', 'new-content\n'))]) |
|
222 |
builder.finish_series() |
|
3904.3.6
by Andrew Bennetts
Skip test for two formats, and fix format 5 by avoiding a full history sync with non-format5 branches. |
223 |
trunk = builder.get_branch() |
3904.3.7
by Andrew Bennetts
Comment the new tests. |
224 |
# Sprout rev-1 to "trunk", so that we can stack on it.
|
3904.3.6
by Andrew Bennetts
Skip test for two formats, and fix format 5 by avoiding a full history sync with non-format5 branches. |
225 |
trunk.bzrdir.sprout(self.get_url('trunk'), revision_id='rev-1') |
3904.3.7
by Andrew Bennetts
Comment the new tests. |
226 |
# Set a default stacking policy so that new branches will automatically
|
227 |
# stack on trunk.
|
|
3904.3.4
by Andrew Bennetts
First cut of a branch_implementations test. It fails. |
228 |
self.make_bzrdir('.').get_config().set_default_stack_on('trunk') |
3904.3.7
by Andrew Bennetts
Comment the new tests. |
229 |
# Push rev-2 to a new branch "remote". It will be stacked on "trunk".
|
3904.3.5
by Andrew Bennetts
Improve the test; now 4/7 passing. |
230 |
output = StringIO() |
3904.3.6
by Andrew Bennetts
Skip test for two formats, and fix format 5 by avoiding a full history sync with non-format5 branches. |
231 |
push._show_push_branch(trunk, 'rev-2', self.get_url('remote'), output) |
3904.3.7
by Andrew Bennetts
Comment the new tests. |
232 |
# Push rev-3 onto "remote". If "remote" not stacked and is missing the
|
233 |
# fulltext record for f-id @ rev-1, then this will fail.
|
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
234 |
remote_branch = branch.Branch.open(self.get_url('remote')) |
3904.3.6
by Andrew Bennetts
Skip test for two formats, and fix format 5 by avoiding a full history sync with non-format5 branches. |
235 |
trunk.push(remote_branch) |
4332.3.35
by Robert Collins
Fix failing tests. |
236 |
check.check_dwim(remote_branch.base, False, True, True) |
3904.3.4
by Andrew Bennetts
First cut of a branch_implementations test. It fails. |
237 |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
238 |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
239 |
class TestPushHook(per_branch.TestCaseWithBranch): |
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
240 |
|
241 |
def setUp(self): |
|
242 |
self.hook_calls = [] |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
243 |
super(TestPushHook, self).setUp() |
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
244 |
|
2297.1.4
by Martin Pool
Push now returns a PushResult rather than just an integer. |
245 |
def capture_post_push_hook(self, result): |
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
246 |
"""Capture post push hook calls to self.hook_calls.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
247 |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
248 |
The call is logged, as is some state of the two branches.
|
249 |
"""
|
|
2297.1.6
by Martin Pool
Add docs for Results, give some members cleaner names |
250 |
if result.local_branch: |
251 |
local_locked = result.local_branch.is_locked() |
|
252 |
local_base = result.local_branch.base |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
253 |
else: |
254 |
local_locked = None |
|
255 |
local_base = None |
|
256 |
self.hook_calls.append( |
|
2297.1.6
by Martin Pool
Add docs for Results, give some members cleaner names |
257 |
('post_push', result.source_branch, local_base, |
258 |
result.master_branch.base, |
|
2297.1.4
by Martin Pool
Push now returns a PushResult rather than just an integer. |
259 |
result.old_revno, result.old_revid, |
2297.1.6
by Martin Pool
Add docs for Results, give some members cleaner names |
260 |
result.new_revno, result.new_revid, |
261 |
result.source_branch.is_locked(), local_locked, |
|
262 |
result.master_branch.is_locked())) |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
263 |
|
264 |
def test_post_push_empty_history(self): |
|
265 |
target = self.make_branch('target') |
|
266 |
source = self.make_branch('source') |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
267 |
branch.Branch.hooks.install_named_hook( |
268 |
'post_push', self.capture_post_push_hook, None) |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
269 |
source.push(target) |
270 |
# with nothing there we should still get a notification, and
|
|
271 |
# have both branches locked at the notification time.
|
|
272 |
self.assertEqual([ |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
273 |
('post_push', source, None, target.base, 0, revision.NULL_REVISION, |
274 |
0, revision.NULL_REVISION, True, None, True) |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
275 |
],
|
276 |
self.hook_calls) |
|
277 |
||
278 |
def test_post_push_bound_branch(self): |
|
279 |
# pushing to a bound branch should pass in the master branch to the
|
|
280 |
# hook, allowing the correct number of emails to be sent, while still
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
281 |
# allowing hooks that want to modify the target to do so to both
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
282 |
# instances.
|
283 |
target = self.make_branch('target') |
|
284 |
local = self.make_branch('local') |
|
285 |
try: |
|
286 |
local.bind(target) |
|
287 |
except errors.UpgradeRequired: |
|
2477.1.2
by Martin Pool
Rename push/pull back to 'run_hooks' (jameinel) |
288 |
# We can't bind this format to itself- typically it is the local
|
289 |
# branch that doesn't support binding. As of May 2007
|
|
290 |
# remotebranches can't be bound. Let's instead make a new local
|
|
291 |
# branch of the default type, which does allow binding.
|
|
292 |
# See https://bugs.launchpad.net/bzr/+bug/112020
|
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
293 |
local = bzrdir.BzrDir.create_branch_convenience('local2') |
2477.1.9
by Martin Pool
Review cleanups from John, mostly docs |
294 |
local.bind(target) |
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
295 |
source = self.make_branch('source') |
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
296 |
branch.Branch.hooks.install_named_hook( |
297 |
'post_push', self.capture_post_push_hook, None) |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
298 |
source.push(local) |
299 |
# with nothing there we should still get a notification, and
|
|
300 |
# have both branches locked at the notification time.
|
|
301 |
self.assertEqual([ |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
302 |
('post_push', source, local.base, target.base, 0, |
303 |
revision.NULL_REVISION, 0, revision.NULL_REVISION, |
|
304 |
True, True, True) |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
305 |
],
|
306 |
self.hook_calls) |
|
307 |
||
308 |
def test_post_push_nonempty_history(self): |
|
309 |
target = self.make_branch_and_memory_tree('target') |
|
310 |
target.lock_write() |
|
311 |
target.add('') |
|
312 |
rev1 = target.commit('rev 1') |
|
313 |
target.unlock() |
|
314 |
sourcedir = target.bzrdir.clone(self.get_url('source')) |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
315 |
source = memorytree.MemoryTree.create_on_branch(sourcedir.open_branch()) |
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
316 |
rev2 = source.commit('rev 2') |
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
317 |
branch.Branch.hooks.install_named_hook( |
318 |
'post_push', self.capture_post_push_hook, None) |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
319 |
source.branch.push(target.branch) |
320 |
# with nothing there we should still get a notification, and
|
|
321 |
# have both branches locked at the notification time.
|
|
322 |
self.assertEqual([ |
|
323 |
('post_push', source.branch, None, target.branch.base, 1, rev1, |
|
324 |
2, rev2, True, None, True) |
|
325 |
],
|
|
326 |
self.hook_calls) |
|
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
327 |
|
328 |
||
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
329 |
class EmptyPushSmartEffortTests(per_branch.TestCaseWithBranch): |
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
330 |
"""Tests that a push of 0 revisions should make a limited number of smart
|
331 |
protocol RPCs.
|
|
332 |
"""
|
|
333 |
||
334 |
def setUp(self): |
|
335 |
# Skip some scenarios that don't apply to these tests.
|
|
5247.3.38
by Vincent Ladeuil
Fix the last remaining failures. |
336 |
if (self.transport_server is not None |
337 |
and issubclass(self.transport_server, |
|
338 |
test_server.SmartTCPServer_for_testing)): |
|
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
339 |
raise tests.TestNotApplicable( |
340 |
'Does not apply when remote backing branch is also '
|
|
341 |
'a smart branch') |
|
342 |
if isinstance(self.branch_format, branch.BzrBranchFormat4): |
|
343 |
raise tests.TestNotApplicable( |
|
344 |
'Branch format 4 is not usable via HPSS.') |
|
345 |
super(EmptyPushSmartEffortTests, self).setUp() |
|
346 |
# Create a smart server that publishes whatever the backing VFS server
|
|
347 |
# does.
|
|
5017.3.29
by Vincent Ladeuil
-s bt.per_branch.test_push passing |
348 |
self.smart_server = test_server.SmartTCPServer_for_testing() |
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
349 |
self.start_server(self.smart_server, self.get_server()) |
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
350 |
# Make two empty branches, 'empty' and 'target'.
|
351 |
self.empty_branch = self.make_branch('empty') |
|
352 |
self.make_branch('target') |
|
353 |
# Log all HPSS calls into self.hpss_calls.
|
|
354 |
client._SmartClient.hooks.install_named_hook( |
|
355 |
'call', self.capture_hpss_call, None) |
|
356 |
self.hpss_calls = [] |
|
357 |
||
358 |
def capture_hpss_call(self, params): |
|
359 |
self.hpss_calls.append(params.method) |
|
360 |
||
361 |
def test_empty_branch_api(self): |
|
362 |
"""The branch_obj.push API should make a limited number of HPSS calls.
|
|
363 |
"""
|
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
364 |
t = transport.get_transport(self.smart_server.get_url()).clone('target') |
365 |
target = branch.Branch.open_from_transport(t) |
|
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
366 |
self.empty_branch.push(target) |
367 |
self.assertEqual( |
|
4634.47.8
by Andrew Bennetts
Fix per_branch.test_push effort test to expect new verb. |
368 |
['BzrDir.open_2.1', |
4734.4.13
by Andrew Bennetts
Fix trivial test failure. |
369 |
'BzrDir.open_branchV3', |
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
370 |
'BzrDir.find_repositoryV3', |
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
371 |
'Branch.get_stacked_on_url', |
372 |
'Branch.lock_write', |
|
373 |
'Branch.last_revision_info', |
|
374 |
'Branch.unlock'], |
|
375 |
self.hpss_calls) |
|
376 |
||
377 |
def test_empty_branch_command(self): |
|
378 |
"""The 'bzr push' command should make a limited number of HPSS calls.
|
|
379 |
"""
|
|
380 |
cmd = builtins.cmd_push() |
|
381 |
cmd.outf = tests.StringIOWrapper() |
|
382 |
cmd.run( |
|
4420.1.2
by Vincent Ladeuil
Fix bug #284038 by adding a --strict option to push. |
383 |
directory=self.get_url('empty'), |
4420.1.4
by Vincent Ladeuil
Cleanup. |
384 |
location=self.smart_server.get_url() + 'target') |
3703.3.7
by Andrew Bennetts
Move empty push effort tests to branch_implementations. |
385 |
# HPSS calls as of 2008/09/22:
|
386 |
# [BzrDir.open, BzrDir.open_branch, BzrDir.find_repositoryV2,
|
|
387 |
# Branch.get_stacked_on_url, get, get, Branch.lock_write,
|
|
388 |
# Branch.last_revision_info, Branch.unlock]
|
|
389 |
self.assertTrue(len(self.hpss_calls) <= 9, self.hpss_calls) |
|
390 |
||
391 |
||
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
392 |
class TestLossyPush(per_branch.TestCaseWithBranch): |
4347.3.2
by Jelmer Vernooij
Add some basic tests for lossy_push. |
393 |
|
394 |
def setUp(self): |
|
395 |
self.hook_calls = [] |
|
5010.2.18
by Vincent Ladeuil
Fix imports in per_branch/test_push.py. |
396 |
super(TestLossyPush, self).setUp() |
4347.3.2
by Jelmer Vernooij
Add some basic tests for lossy_push. |
397 |
|
398 |
def test_lossy_push_raises_same_vcs(self): |
|
399 |
target = self.make_branch('target') |
|
400 |
source = self.make_branch('source') |
|
401 |
self.assertRaises(errors.LossyPushToSameVCS, source.lossy_push, target) |