/brz/remove-bazaar

To get this branch, use:
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
2204.4.13 by Aaron Bentley
Update all test cases to avoid set_default_format
23
from bzrlib import (
24
    bzrdir,
25
    )
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
26
from bzrlib.branch import Branch
27
from bzrlib.bzrdir import (BzrDir,
28
                           BzrDirFormat,
29
                           BzrDirFormat6,
30
                           BzrDirMetaFormat1,
31
                           )
32
import bzrlib.errors as errors
2018.5.86 by Andrew Bennetts
Skip BoundSFTPTests when a workingtree can't be created at a non-local URL.
33
from bzrlib.tests import TestSkipped
2414.2.1 by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch.
34
from bzrlib.tests import TestCaseWithTransport
35
from bzrlib.transport.local import LocalURLServer
36
from bzrlib.transport.memory import MemoryServer
37
38
39
class BoundSFTPBranch(TestCaseWithTransport):
40
41
    def setUp(self):
42
        TestCaseWithTransport.setUp(self)
43
        self.vfs_transport_factory = MemoryServer
44
        if self.transport_server is LocalURLServer:
45
            self.transport_server = None
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
46
47
    def create_branches(self):
48
        self.build_tree(['base/', 'base/a', 'base/b'])
2204.4.13 by Aaron Bentley
Update all test cases to avoid set_default_format
49
        format = bzrdir.format_registry.make_bzrdir('knit')
2018.5.86 by Andrew Bennetts
Skip BoundSFTPTests when a workingtree can't be created at a non-local URL.
50
        try:
51
            wt_base = BzrDir.create_standalone_workingtree(
52
                self.get_url('base'), format=format)
53
        except errors.NotLocalUrl:
54
            raise TestSkipped('Not a local URL')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
55
    
56
        b_base = wt_base.branch
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
57
58
        wt_base.add('a')
59
        wt_base.add('b')
60
        wt_base.commit('first', rev_id='r@b-1')
61
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
62
        wt_child = b_base.bzrdir.sprout('child').open_workingtree()
63
        self.sftp_base = Branch.open(self.get_url('base'))
64
        wt_child.branch.bind(self.sftp_base)
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
65
        # check the branch histories are ready for using in tests.
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
66
        self.assertEqual(['r@b-1'], b_base.revision_history())
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
67
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
68
        return b_base, wt_child
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
69
70
    def test_simple_binding(self):
71
        self.build_tree(['base/', 'base/a', 'base/b', 'child/'])
2018.5.86 by Andrew Bennetts
Skip BoundSFTPTests when a workingtree can't be created at a non-local URL.
72
        try:
73
            wt_base = BzrDir.create_standalone_workingtree(self.get_url('base'))
74
        except errors.NotLocalUrl:
75
            raise TestSkipped('Not a local URL')
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
76
77
        wt_base.add('a')
78
        wt_base.add('b')
79
        wt_base.commit('first', rev_id='r@b-1')
80
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
81
        b_base = wt_base.branch
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
82
        # manually make a branch we can bind, because the default format
83
        # may not be bindable-from, and we want to test the side effects etc
84
        # of bondage.
2204.4.13 by Aaron Bentley
Update all test cases to avoid set_default_format
85
        format = bzrdir.format_registry.make_bzrdir('knit')
86
        b_child = BzrDir.create_branch_convenience('child', format=format)
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
87
        self.assertEqual(None, b_child.get_bound_location())
88
        self.assertEqual(None, b_child.get_master_branch())
89
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
90
        sftp_b_base = Branch.open(self.get_url('base'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
91
        b_child.bind(sftp_b_base)
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
92
        self.assertEqual(sftp_b_base.base, b_child.get_bound_location())
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
93
        # the bind must not have given b_child history:
94
        self.assertEqual([], b_child.revision_history())
95
        # we should be able to update the branch at this point:
96
        self.assertEqual(None, b_child.update())
97
        # and now there must be history.
98
        self.assertEqual(['r@b-1'], b_child.revision_history())
99
        # this line is more of a working tree test line, but - what the hey,
100
        # it has work to do.
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
101
        b_child.bzrdir.open_workingtree().update()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
102
        self.failUnlessExists('child/a')
103
        self.failUnlessExists('child/b')
104
105
        b_child.unbind()
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
106
        self.assertEqual(None, b_child.get_bound_location())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
107
108
    def test_bound_commit(self):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
109
        b_base, wt_child = self.create_branches()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
110
111
        open('child/a', 'wb').write('new contents\n')
112
        wt_child.commit('modified a', rev_id='r@c-2')
113
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
114
        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.
115
        self.assertEqual(['r@b-1', 'r@c-2'], b_base.revision_history())
116
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
117
    def test_bound_commit_fails_when_out_of_date(self):
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
118
        # Make sure commit fails if out of date.
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
119
        b_base, wt_child = self.create_branches()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
120
121
        open('base/a', 'wb').write('new base contents\n')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
122
        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.
123
124
        open('child/b', 'wb').write('new b child contents\n')
125
        self.assertRaises(errors.BoundBranchOutOfDate,
126
                wt_child.commit, 'child', rev_id='r@c-2')
127
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
128
        sftp_b_base = Branch.open(self.get_url('base'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
129
130
        # This is all that cmd_update does
131
        wt_child.pull(sftp_b_base, overwrite=False)
132
133
        wt_child.commit('child', rev_id='r@c-3')
134
135
        self.assertEqual(['r@b-1', 'r@b-2', 'r@c-3'],
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
136
                wt_child.branch.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
137
        self.assertEqual(['r@b-1', 'r@b-2', 'r@c-3'],
138
                b_base.revision_history())
139
        self.assertEqual(['r@b-1', 'r@b-2', 'r@c-3'],
140
                sftp_b_base.revision_history())
141
142
    def test_double_binding(self):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
143
        b_base, wt_child = self.create_branches()
144
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
145
        wt_child2 = wt_child.branch.create_checkout('child2')
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
146
147
        open('child2/a', 'wb').write('new contents\n')
148
        self.assertRaises(errors.CommitToDoubleBoundBranch,
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
149
                wt_child2.commit, 'child2', rev_id='r@d-2')
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
150
151
    def test_unbinding(self):
152
        from bzrlib.transport import get_transport
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
153
        b_base, wt_child = self.create_branches()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
154
155
        # TestCaseWithSFTPServer only allows you to connect one time
156
        # to the SFTP server. So we have to create a connection and
157
        # keep it around, so that it can be reused
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
158
        __unused_t = get_transport(self.get_url('.'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
159
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
160
        wt_base = b_base.bzrdir.open_workingtree()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
161
        open('base/a', 'wb').write('new base contents\n')
162
        wt_base.commit('base', rev_id='r@b-2')
163
164
        open('child/b', 'wb').write('new b child contents\n')
165
        self.assertRaises(errors.BoundBranchOutOfDate,
166
                wt_child.commit, 'child', rev_id='r@c-2')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
167
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
168
        wt_child.branch.unbind()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
169
        wt_child.commit('child', rev_id='r@c-2')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
170
        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.
171
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
172
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
173
        sftp_b_base = Branch.open(self.get_url('base'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
174
        self.assertRaises(errors.DivergedBranches,
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
175
                wt_child.branch.bind, sftp_b_base)
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
176
177
    def test_commit_remote_bound(self):
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
178
        # Make sure it is detected if the current base is bound during the
179
        # objects lifetime, when the child goes to commit.
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
180
        b_base, wt_child = self.create_branches()
181
182
        b_base.bzrdir.sprout('newbase')
183
184
        sftp_b_base = Branch.open(self.get_url('base'))
185
        sftp_b_newbase = Branch.open(self.get_url('newbase'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
186
187
        sftp_b_base.bind(sftp_b_newbase)
188
189
        open('child/a', 'wb').write('new contents\n')
190
        self.assertRaises(errors.CommitToDoubleBoundBranch,
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
191
                wt_child.commit, 'failure', rev_id='r@c-2')
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
192
193
        self.assertEqual(['r@b-1'], b_base.revision_history())
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
194
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
195
        self.assertEqual(['r@b-1'], sftp_b_newbase.revision_history())
196
197
    def test_bind_diverged(self):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
198
        from bzrlib.builtins import merge
199
200
        b_base, wt_child = self.create_branches()
201
202
        wt_child.branch.unbind()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
203
        open('child/a', 'ab').write('child contents\n')
1908.6.11 by Robert Collins
Remove usage of tree.pending_merges().
204
        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.
205
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
206
        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.
207
        self.assertEqual(['r@b-1'], b_base.revision_history())
208
209
        open('base/b', 'ab').write('base contents\n')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
210
        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.
211
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
212
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
213
        sftp_b_base = Branch.open(self.get_url('base'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
214
215
        self.assertRaises(errors.DivergedBranches,
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
216
                wt_child.branch.bind, sftp_b_base)
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
217
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
218
        wt_child.merge_from_branch(sftp_b_base)
1908.6.11 by Robert Collins
Remove usage of tree.pending_merges().
219
        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.
220
        wt_child.commit('merged', rev_id='r@c-3')
221
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
222
        # After a merge, trying to bind again should succeed but not push the
223
        # new change.
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
224
        wt_child.branch.bind(sftp_b_base)
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
225
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
226
        self.assertEqual(['r@b-1', 'r@b-2'], b_base.revision_history())
227
        self.assertEqual(['r@b-1', 'r@c-2', 'r@c-3'],
228
            wt_child.branch.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
229
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
230
    def test_bind_parent_ahead_preserves_parent(self):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
231
        b_base, wt_child = self.create_branches()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
232
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
233
        wt_child.branch.unbind()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
234
235
        open('a', 'ab').write('base changes\n')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
236
        wt_base = b_base.bzrdir.open_workingtree()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
237
        wt_base.commit('base', rev_id='r@b-2')
238
        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.
239
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
240
241
        sftp_b_base = Branch.open(self.get_url('base'))
242
        wt_child.branch.bind(sftp_b_base)
243
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
244
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
245
246
        wt_child.branch.unbind()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
247
248
        # Check and make sure it also works if parent is ahead multiple
249
        wt_base.commit('base 3', rev_id='r@b-3', allow_pointless=True)
250
        wt_base.commit('base 4', rev_id='r@b-4', allow_pointless=True)
251
        wt_base.commit('base 5', rev_id='r@b-5', allow_pointless=True)
252
253
        self.assertEqual(['r@b-1', 'r@b-2', 'r@b-3', 'r@b-4', 'r@b-5'],
254
                b_base.revision_history())
255
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
256
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
257
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
258
        wt_child.branch.bind(sftp_b_base)
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
259
        self.assertEqual(['r@b-1'], wt_child.branch.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
260
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
261
    def test_bind_child_ahead_preserves_child(self):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
262
        b_base, wt_child = self.create_branches()
263
264
        wt_child.branch.unbind()
265
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
266
        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.
267
        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.
268
        self.assertEqual(['r@b-1'], b_base.revision_history())
269
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
270
        sftp_b_base = Branch.open(self.get_url('base'))
271
        wt_child.branch.bind(sftp_b_base)
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
272
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
273
        self.assertEqual(['r@b-1'], b_base.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
274
275
        # 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.
276
        wt_child.branch.unbind()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
277
        wt_child.commit('child 3', rev_id='r@c-3', allow_pointless=True)
278
        wt_child.commit('child 4', rev_id='r@c-4', allow_pointless=True)
279
        wt_child.commit('child 5', rev_id='r@c-5', allow_pointless=True)
280
281
        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.
282
                wt_child.branch.revision_history())
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
283
        self.assertEqual(['r@b-1'], b_base.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
284
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
285
        wt_child.branch.bind(sftp_b_base)
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
286
        self.assertEqual(['r@b-1'], b_base.revision_history())
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
287
288
    def test_commit_after_merge(self):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
289
        from bzrlib.builtins import merge
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
290
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
291
        b_base, wt_child = self.create_branches()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
292
293
        # We want merge to be able to be a local only
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
294
        # operation, because it does not alter the branch data.
295
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
296
        # But we can't fail afterwards
297
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
298
        wt_other = wt_child.bzrdir.sprout('other').open_workingtree()
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
299
300
        open('other/c', 'wb').write('file c\n')
301
        wt_other.add('c')
302
        wt_other.commit('adding c', rev_id='r@d-2')
303
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
304
        self.failIf(wt_child.branch.repository.has_revision('r@d-2'))
305
        self.failIf(b_base.repository.has_revision('r@d-2'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
306
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
307
        wt_child.merge_from_branch(wt_other.branch)
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
308
309
        self.failUnlessExists('child/c')
1908.6.11 by Robert Collins
Remove usage of tree.pending_merges().
310
        self.assertEqual(['r@d-2'], wt_child.get_parent_ids()[1:])
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
311
        self.failUnless(wt_child.branch.repository.has_revision('r@d-2'))
312
        self.failIf(b_base.repository.has_revision('r@d-2'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
313
314
        # Commit should succeed, and cause merged revisions to
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
315
        # be pushed into base
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
316
        wt_child.commit('merge other', rev_id='r@c-2')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
317
        self.assertEqual(['r@b-1', 'r@c-2'], wt_child.branch.revision_history())
318
        self.assertEqual(['r@b-1', 'r@c-2'], b_base.revision_history())
319
        self.failUnless(b_base.repository.has_revision('r@d-2'))
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
320
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
321
    def test_commit_fails(self):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
322
        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
323
324
        open('a', 'ab').write('child adds some text\n')
325
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
326
        # this deletes the branch from memory
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
327
        del b_base
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
328
        # and this moves it out of the way on disk
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
329
        os.rename('base', 'hidden_base')
330
331
        self.assertRaises(errors.BoundBranchConnectionFailure,
332
                wt_child.commit, 'added text', rev_id='r@c-2')
333
334
    # TODO: jam 20051231 We need invasive failure tests, so that we can show
335
    #       performance even when something fails.
1505.1.28 by John Arbash Meinel
todo
336
1505.1.27 by John Arbash Meinel
Adding tests against an sftp branch.
337