bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
1 |
# Copyright (C) 2005 Robey Pointer <robey@lag.net>, Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
17 |
"""Tests for branches bound to an sftp branch."""
|
18 |
||
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
19 |
|
20 |
import os |
|
21 |
||
|
1607.1.13
by Robert Collins
Add a clear_connection_cache to the SFTP transport and use it in fixing the bound branch test speed performance problem which was cause by the server thread timing out - it was blocked on a read and closing the client side causes the server to unblock and exit. |
22 |
import bzrlib |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
23 |
from bzrlib.branch import Branch |
24 |
from bzrlib.bzrdir import (BzrDir, |
|
25 |
BzrDirFormat, |
|
26 |
BzrDirFormat6, |
|
27 |
BzrDirMetaFormat1, |
|
28 |
)
|
|
29 |
import bzrlib.errors as errors |
|
|
1505.1.30
by John Arbash Meinel
[merge] jam-integration 1495 |
30 |
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer, paramiko_loaded |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
31 |
|
32 |
||
33 |
class BoundSFTPBranch(TestCaseWithSFTPServer): |
|
34 |
||
35 |
def create_branches(self): |
|
36 |
self.build_tree(['base/', 'base/a', 'base/b']) |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
37 |
old_format = BzrDirFormat.get_default_format() |
38 |
BzrDirFormat.set_default_format(BzrDirMetaFormat1()) |
|
39 |
try: |
|
40 |
wt_base = BzrDir.create_standalone_workingtree('base') |
|
41 |
finally: |
|
42 |
BzrDirFormat.set_default_format(old_format) |
|
43 |
||
44 |
b_base = wt_base.branch |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
45 |
|
46 |
wt_base.add('a') |
|
47 |
wt_base.add('b') |
|
48 |
wt_base.commit('first', rev_id='r@b-1') |
|
49 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
50 |
wt_child = b_base.bzrdir.sprout('child').open_workingtree() |
51 |
self.sftp_base = Branch.open(self.get_url('base')) |
|
52 |
wt_child.branch.bind(self.sftp_base) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
53 |
|
54 |
self.assertEqual(['r@b-1'], b_base.revision_history()) |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
55 |
self.assertEqual(['r@b-1'], wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
56 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
57 |
return b_base, wt_child |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
58 |
|
|
1607.1.13
by Robert Collins
Add a clear_connection_cache to the SFTP transport and use it in fixing the bound branch test speed performance problem which was cause by the server thread timing out - it was blocked on a read and closing the client side causes the server to unblock and exit. |
59 |
def tearDown(self): |
60 |
self.sftp_base = None |
|
61 |
bzrlib.transport.sftp.clear_connection_cache() |
|
62 |
super(BoundSFTPBranch, self).tearDown() |
|
63 |
||
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
64 |
def test_simple_binding(self): |
65 |
self.build_tree(['base/', 'base/a', 'base/b', 'child/']) |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
66 |
wt_base = BzrDir.create_standalone_workingtree('base') |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
67 |
|
68 |
wt_base.add('a') |
|
69 |
wt_base.add('b') |
|
70 |
wt_base.commit('first', rev_id='r@b-1') |
|
71 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
72 |
b_base = wt_base.branch |
73 |
old_format = BzrDirFormat.get_default_format() |
|
74 |
BzrDirFormat.set_default_format(BzrDirMetaFormat1()) |
|
75 |
try: |
|
76 |
b_child = BzrDir.create_branch_convenience('child') |
|
77 |
finally: |
|
78 |
BzrDirFormat.set_default_format(old_format) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
79 |
self.assertEqual(None, b_child.get_bound_location()) |
80 |
self.assertEqual(None, b_child.get_master_branch()) |
|
81 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
82 |
sftp_b_base = Branch.open(self.get_url('base')) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
83 |
b_child.bind(sftp_b_base) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
84 |
self.assertEqual(sftp_b_base.base, b_child.get_bound_location()) |
85 |
# this line is more of a working tree test line, but - what the hey.
|
|
86 |
b_child.bzrdir.open_workingtree().update() |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
87 |
self.failUnlessExists('child/a') |
88 |
self.failUnlessExists('child/b') |
|
89 |
||
90 |
b_child.unbind() |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
91 |
self.assertEqual(None, b_child.get_bound_location()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
92 |
|
93 |
def test_bound_commit(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
94 |
b_base, wt_child = self.create_branches() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
95 |
|
96 |
open('child/a', 'wb').write('new contents\n') |
|
97 |
wt_child.commit('modified a', rev_id='r@c-2') |
|
98 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
99 |
self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
100 |
self.assertEqual(['r@b-1', 'r@c-2'], b_base.revision_history()) |
101 |
||
102 |
def test_bound_fail(self): |
|
103 |
# Make sure commit fails if out of date.
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
104 |
b_base, wt_child = self.create_branches() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
105 |
|
106 |
open('base/a', 'wb').write('new base contents\n') |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
107 |
b_base.bzrdir.open_workingtree().commit('base', rev_id='r@b-2') |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
108 |
|
109 |
open('child/b', 'wb').write('new b child contents\n') |
|
110 |
self.assertRaises(errors.BoundBranchOutOfDate, |
|
111 |
wt_child.commit, 'child', rev_id='r@c-2') |
|
112 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
113 |
sftp_b_base = Branch.open(self.get_url('base')) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
114 |
|
115 |
# This is all that cmd_update does
|
|
116 |
wt_child.pull(sftp_b_base, overwrite=False) |
|
117 |
||
118 |
wt_child.commit('child', rev_id='r@c-3') |
|
119 |
||
120 |
self.assertEqual(['r@b-1', 'r@b-2', 'r@c-3'], |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
121 |
wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
122 |
self.assertEqual(['r@b-1', 'r@b-2', 'r@c-3'], |
123 |
b_base.revision_history()) |
|
124 |
self.assertEqual(['r@b-1', 'r@b-2', 'r@c-3'], |
|
125 |
sftp_b_base.revision_history()) |
|
126 |
||
127 |
def test_double_binding(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
128 |
b_base, wt_child = self.create_branches() |
129 |
||
130 |
wt_child2 = wt_child.bzrdir.sprout('child2').open_workingtree() |
|
131 |
||
132 |
wt_child2.branch.bind(wt_child.branch) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
133 |
|
134 |
open('child2/a', 'wb').write('new contents\n') |
|
135 |
self.assertRaises(errors.CommitToDoubleBoundBranch, |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
136 |
wt_child2.commit, 'child2', rev_id='r@d-2') |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
137 |
|
138 |
def test_unbinding(self): |
|
139 |
from bzrlib.transport import get_transport |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
140 |
b_base, wt_child = self.create_branches() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
141 |
|
142 |
# TestCaseWithSFTPServer only allows you to connect one time
|
|
143 |
# to the SFTP server. So we have to create a connection and
|
|
144 |
# keep it around, so that it can be reused
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
145 |
__unused_t = get_transport(self.get_url('.')) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
146 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
147 |
wt_base = b_base.bzrdir.open_workingtree() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
148 |
open('base/a', 'wb').write('new base contents\n') |
149 |
wt_base.commit('base', rev_id='r@b-2') |
|
150 |
||
151 |
open('child/b', 'wb').write('new b child contents\n') |
|
152 |
self.assertRaises(errors.BoundBranchOutOfDate, |
|
153 |
wt_child.commit, 'child', rev_id='r@c-2') |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
154 |
self.assertEqual(['r@b-1'], wt_child.branch.revision_history()) |
155 |
wt_child.branch.unbind() |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
156 |
wt_child.commit('child', rev_id='r@c-2') |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
157 |
self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
158 |
self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history()) |
159 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
160 |
sftp_b_base = Branch.open(self.get_url('base')) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
161 |
self.assertRaises(errors.DivergedBranches, |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
162 |
wt_child.branch.bind, sftp_b_base) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
163 |
|
164 |
def test_commit_remote_bound(self): |
|
165 |
# Make sure it is detected if the current base
|
|
166 |
# suddenly is bound when child goes to commit
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
167 |
b_base, wt_child = self.create_branches() |
168 |
||
169 |
b_base.bzrdir.sprout('newbase') |
|
170 |
||
171 |
sftp_b_base = Branch.open(self.get_url('base')) |
|
172 |
sftp_b_newbase = Branch.open(self.get_url('newbase')) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
173 |
|
174 |
sftp_b_base.bind(sftp_b_newbase) |
|
175 |
||
176 |
open('child/a', 'wb').write('new contents\n') |
|
177 |
self.assertRaises(errors.CommitToDoubleBoundBranch, |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
178 |
wt_child.commit, 'failure', rev_id='r@c-2') |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
179 |
|
180 |
self.assertEqual(['r@b-1'], b_base.revision_history()) |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
181 |
self.assertEqual(['r@b-1'], wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
182 |
self.assertEqual(['r@b-1'], sftp_b_newbase.revision_history()) |
183 |
||
184 |
def test_pull_updates_both(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
185 |
b_base, wt_child = self.create_branches() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
186 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
187 |
wt_newchild = b_base.bzrdir.sprout('newchild').open_workingtree() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
188 |
open('newchild/b', 'wb').write('newchild b contents\n') |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
189 |
wt_newchild.commit('newchild', rev_id='r@d-2') |
190 |
self.assertEqual(['r@b-1', 'r@d-2'], wt_newchild.branch.revision_history()) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
191 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
192 |
wt_child.pull(wt_newchild.branch) |
193 |
self.assertEqual(['r@b-1', 'r@d-2'], wt_child.branch.revision_history()) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
194 |
self.assertEqual(['r@b-1', 'r@d-2'], b_base.revision_history()) |
195 |
||
196 |
def test_bind_diverged(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
197 |
from bzrlib.builtins import merge |
198 |
||
199 |
b_base, wt_child = self.create_branches() |
|
200 |
||
201 |
wt_child.branch.unbind() |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
202 |
open('child/a', 'ab').write('child contents\n') |
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
203 |
wt_child_rev = wt_child.commit('child', rev_id='r@c-2') |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
204 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
205 |
self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
206 |
self.assertEqual(['r@b-1'], b_base.revision_history()) |
207 |
||
208 |
open('base/b', 'ab').write('base contents\n') |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
209 |
b_base.bzrdir.open_workingtree().commit('base', rev_id='r@b-2') |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
210 |
self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history()) |
211 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
212 |
sftp_b_base = Branch.open(self.get_url('base')) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
213 |
|
214 |
self.assertRaises(errors.DivergedBranches, |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
215 |
wt_child.branch.bind, sftp_b_base) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
216 |
|
217 |
# TODO: jam 20051230 merge_inner doesn't set pending merges
|
|
218 |
# Is this on purpose?
|
|
219 |
# merge_inner also doesn't fetch any missing revisions
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
220 |
#merge_inner(wt_child.branch, sftp_b_base.revision_tree('r@b-2'),
|
221 |
# wt_child.branch.revision_tree('r@b-1'))
|
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
222 |
# TODO: jam 20051230 merge(..., (None, None), ...) seems to
|
223 |
# cause an infinite loop of some sort. It definitely doesn't
|
|
224 |
# work, you have to use list notation
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
225 |
merge((sftp_b_base.base, 2), [None, None], this_dir=wt_child.branch.base) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
226 |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
227 |
self.assertEqual([wt_child_rev, 'r@b-2'], wt_child.get_parent_ids()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
228 |
wt_child.commit('merged', rev_id='r@c-3') |
229 |
||
230 |
# After a merge, trying to bind again should succeed
|
|
231 |
# by pushing the new change to base
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
232 |
wt_child.branch.bind(sftp_b_base) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
233 |
|
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
234 |
self.assertEqual(['r@b-1', 'r@c-2', 'r@c-3'], |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
235 |
b_base.revision_history()) |
|
1649.1.1
by Robert Collins
* 'pull' and 'push' now normalise the revision history, so that any two |
236 |
self.assertEqual(['r@b-1', 'r@c-2', 'r@c-3'], |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
237 |
wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
238 |
|
239 |
def test_bind_parent_ahead(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
240 |
b_base, wt_child = self.create_branches() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
241 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
242 |
wt_child.branch.unbind() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
243 |
|
244 |
open('a', 'ab').write('base changes\n') |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
245 |
wt_base = b_base.bzrdir.open_workingtree() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
246 |
wt_base.commit('base', rev_id='r@b-2') |
247 |
self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history()) |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
248 |
self.assertEqual(['r@b-1'], wt_child.branch.revision_history()) |
249 |
||
250 |
sftp_b_base = Branch.open(self.get_url('base')) |
|
251 |
wt_child.branch.bind(sftp_b_base) |
|
252 |
||
253 |
self.assertEqual(['r@b-1', 'r@b-2'], wt_child.branch.revision_history()) |
|
254 |
||
255 |
wt_child.branch.unbind() |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
256 |
|
257 |
# Check and make sure it also works if parent is ahead multiple
|
|
258 |
wt_base.commit('base 3', rev_id='r@b-3', allow_pointless=True) |
|
259 |
wt_base.commit('base 4', rev_id='r@b-4', allow_pointless=True) |
|
260 |
wt_base.commit('base 5', rev_id='r@b-5', allow_pointless=True) |
|
261 |
||
262 |
self.assertEqual(['r@b-1', 'r@b-2', 'r@b-3', 'r@b-4', 'r@b-5'], |
|
263 |
b_base.revision_history()) |
|
264 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
265 |
self.assertEqual(['r@b-1', 'r@b-2'], wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
266 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
267 |
wt_child.branch.bind(sftp_b_base) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
268 |
self.assertEqual(['r@b-1', 'r@b-2', 'r@b-3', 'r@b-4', 'r@b-5'], |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
269 |
wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
270 |
|
271 |
def test_bind_child_ahead(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
272 |
b_base, wt_child = self.create_branches() |
273 |
||
274 |
wt_child.branch.unbind() |
|
275 |
||
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
276 |
wt_child.commit('child', rev_id='r@c-2', allow_pointless=True) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
277 |
self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
278 |
self.assertEqual(['r@b-1'], b_base.revision_history()) |
279 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
280 |
sftp_b_base = Branch.open(self.get_url('base')) |
281 |
wt_child.branch.bind(sftp_b_base) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
282 |
|
283 |
self.assertEqual(['r@b-1', 'r@c-2'], b_base.revision_history()) |
|
284 |
||
285 |
# Check and make sure it also works if child is ahead multiple
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
286 |
wt_child.branch.unbind() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
287 |
wt_child.commit('child 3', rev_id='r@c-3', allow_pointless=True) |
288 |
wt_child.commit('child 4', rev_id='r@c-4', allow_pointless=True) |
|
289 |
wt_child.commit('child 5', rev_id='r@c-5', allow_pointless=True) |
|
290 |
||
291 |
self.assertEqual(['r@b-1', 'r@c-2', 'r@c-3', 'r@c-4', 'r@c-5'], |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
292 |
wt_child.branch.revision_history()) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
293 |
self.assertEqual(['r@b-1', 'r@c-2'], b_base.revision_history()) |
294 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
295 |
wt_child.branch.bind(sftp_b_base) |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
296 |
self.assertEqual(['r@b-1', 'r@c-2', 'r@c-3', 'r@c-4', 'r@c-5'], |
297 |
b_base.revision_history()) |
|
298 |
||
299 |
def test_commit_after_merge(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
300 |
from bzrlib.builtins import merge |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
301 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
302 |
b_base, wt_child = self.create_branches() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
303 |
|
304 |
# We want merge to be able to be a local only
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
305 |
# operation, because it does not alter the branch data.
|
306 |
||
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
307 |
# But we can't fail afterwards
|
308 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
309 |
wt_other = wt_child.bzrdir.sprout('other').open_workingtree() |
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
310 |
|
311 |
open('other/c', 'wb').write('file c\n') |
|
312 |
wt_other.add('c') |
|
313 |
wt_other.commit('adding c', rev_id='r@d-2') |
|
314 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
315 |
self.failIf(wt_child.branch.repository.has_revision('r@d-2')) |
316 |
self.failIf(b_base.repository.has_revision('r@d-2')) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
317 |
|
318 |
# TODO: jam 20051230 merge_inner doesn't set pending merges
|
|
319 |
# Is this on purpose?
|
|
320 |
# merge_inner also doesn't fetch any missing revisions
|
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
321 |
#merge_inner(wt_child.branch, b_other.revision_tree('r@d-2'),
|
322 |
# wt_child.branch.revision_tree('r@b-1'))
|
|
323 |
merge((wt_other.branch.base, 2), [None, None], this_dir=wt_child.branch.base) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
324 |
|
325 |
self.failUnlessExists('child/c') |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
326 |
self.assertEqual(['r@d-2'], wt_child.get_parent_ids()[1:]) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
327 |
self.failUnless(wt_child.branch.repository.has_revision('r@d-2')) |
328 |
self.failIf(b_base.repository.has_revision('r@d-2')) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
329 |
|
330 |
# Commit should succeed, and cause merged revisions to
|
|
331 |
# be pulled into base
|
|
332 |
wt_child.commit('merge other', rev_id='r@c-2') |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
333 |
self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history()) |
334 |
self.assertEqual(['r@b-1', 'r@c-2'], b_base.revision_history()) |
|
335 |
self.failUnless(b_base.repository.has_revision('r@d-2')) |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
336 |
|
|
1505.1.29
by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree |
337 |
def test_commit_fails(self): |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
338 |
b_base, wt_child = self.create_branches() |
|
1505.1.29
by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree |
339 |
|
340 |
open('a', 'ab').write('child adds some text\n') |
|
341 |
||
342 |
del b_base |
|
343 |
os.rename('base', 'hidden_base') |
|
344 |
||
345 |
self.assertRaises(errors.BoundBranchConnectionFailure, |
|
346 |
wt_child.commit, 'added text', rev_id='r@c-2') |
|
347 |
||
348 |
def test_pull_fails(self): |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
349 |
b_base, wt_child = self.create_branches() |
|
1505.1.29
by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree |
350 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
351 |
wt_other = wt_child.bzrdir.sprout('other').open_workingtree() |
|
1505.1.29
by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree |
352 |
open('other/a', 'wb').write('new contents\n') |
353 |
wt_other.commit('changed a', rev_id='r@d-2') |
|
354 |
||
355 |
self.assertEqual(['r@b-1'], b_base.revision_history()) |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
356 |
self.assertEqual(['r@b-1'], wt_child.branch.revision_history()) |
357 |
self.assertEqual(['r@b-1', 'r@d-2'], wt_other.branch.revision_history()) |
|
|
1505.1.29
by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree |
358 |
|
359 |
del b_base |
|
360 |
os.rename('base', 'hidden_base') |
|
361 |
||
362 |
self.assertRaises(errors.BoundBranchConnectionFailure, |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
363 |
wt_child.pull, wt_other.branch) |
|
1505.1.29
by John Arbash Meinel
Added special exceptions when unable to contact parent branch. Added tests for failure. bind() no longer updates the remote working tree |
364 |
|
365 |
# TODO: jam 20051231 We need invasive failure tests, so that we can show
|
|
366 |
# performance even when something fails.
|
|
|
1505.1.28
by John Arbash Meinel
todo |
367 |
|
|
1505.1.27
by John Arbash Meinel
Adding tests against an sftp branch. |
368 |
|
369 |
if not paramiko_loaded: |
|
370 |
del BoundSFTPBranch |
|
371 |