~bzr-pqm/bzr/bzr.dev

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