/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4988.10.3 by John Arbash Meinel
Merge bzr.dev 5007, resolve conflict, update NEWS
1
# Copyright (C) 2005-2010 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
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.1 by John Arbash Meinel
Adding test for bound behavior
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.1 by John Arbash Meinel
Adding test for bound behavior
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.1 by John Arbash Meinel
Adding test for bound behavior
16
17
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
18
"""Tests of bound branches (binding, unbinding, commit, etc) command."""
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
19
20
import os
21
2204.4.13 by Aaron Bentley
Update all test cases to avoid set_default_format
22
from bzrlib import (
4988.7.2 by Vincent Ladeuil
Fix imports.
23
    errors,
24
    tests,
2204.4.13 by Aaron Bentley
Update all test cases to avoid set_default_format
25
    )
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
26
from bzrlib.branch import Branch
5582.10.91 by Jelmer Vernooij
Fix some tests.
27
from bzrlib.bzrdir import BzrDir
4988.7.2 by Vincent Ladeuil
Fix imports.
28
from bzrlib.tests import script
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
29
30
4988.7.2 by Vincent Ladeuil
Fix imports.
31
class TestBoundBranches(tests.TestCaseWithTransport):
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
32
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
33
    def create_branches(self):
4691.2.1 by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite.
34
        base_tree = self.make_branch_and_tree('base')
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
35
        base_tree.lock_write()
4691.2.1 by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite.
36
        self.build_tree(['base/a', 'base/b'])
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
37
        base_tree.add(['a', 'b'])
38
        base_tree.commit('init')
39
        base_tree.unlock()
4691.2.1 by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite.
40
        branch = base_tree.branch
1607.1.14 by Robert Collins
Reduce lock thrashing somewhat - drops bound branch tests lock count from 6554 to 4456 locks.
41
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
42
        child_tree = branch.create_checkout('child')
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
43
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
44
        self.check_revno(1, 'child')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
45
        d = BzrDir.open('child')
46
        self.assertNotEqual(None, d.open_branch().get_master_branch())
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
47
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
48
        return base_tree, child_tree
49
1607.1.14 by Robert Collins
Reduce lock thrashing somewhat - drops bound branch tests lock count from 6554 to 4456 locks.
50
    def check_revno(self, val, loc='.'):
51
        self.assertEqual(
52
            val, len(BzrDir.open(loc).open_branch().revision_history()))
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
53
1505.1.4 by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work
54
    def test_simple_binding(self):
4691.2.1 by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite.
55
        tree = self.make_branch_and_tree('base')
56
        self.build_tree(['base/a', 'base/b'])
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
57
        tree.add('a', 'b')
58
        tree.commit(message='init')
4691.2.1 by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite.
59
        branch = tree.branch
1505.1.4 by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work
60
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
61
        tree.bzrdir.sprout('child')
1505.1.4 by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work
62
63
        os.chdir('child')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
64
        self.run_bzr('bind ../base')
1587.1.6 by Robert Collins
Update bound branch implementation to 0.8.
65
66
        d = BzrDir.open('')
67
        self.assertNotEqual(None, d.open_branch().get_master_branch())
68
69
        self.run_bzr('unbind')
70
        self.assertEqual(None, d.open_branch().get_master_branch())
71
72
        self.run_bzr('unbind', retcode=3)
73
2230.3.31 by Aaron Bentley
Implement re-binding previously-bound branches
74
    def test_bind_branch6(self):
1551.13.1 by Aaron Bentley
Introduce dirstate-tags format
75
        branch1 = self.make_branch('branch1', format='dirstate-tags')
2230.3.31 by Aaron Bentley
Implement re-binding previously-bound branches
76
        os.chdir('branch1')
77
        error = self.run_bzr('bind', retcode=3)[1]
2230.3.48 by Aaron Bentley
Update blackbox test to handle new error message
78
        self.assertContainsRe(error, 'no previous location known')
2230.3.31 by Aaron Bentley
Implement re-binding previously-bound branches
79
80
    def setup_rebind(self, format):
81
        branch1 = self.make_branch('branch1')
82
        branch2 = self.make_branch('branch2', format=format)
83
        branch2.bind(branch1)
84
        branch2.unbind()
85
86
    def test_rebind_branch6(self):
1551.13.1 by Aaron Bentley
Introduce dirstate-tags format
87
        self.setup_rebind('dirstate-tags')
2230.3.31 by Aaron Bentley
Implement re-binding previously-bound branches
88
        os.chdir('branch2')
89
        self.run_bzr('bind')
90
        b = Branch.open('.')
91
        self.assertContainsRe(b.get_bound_location(), '\/branch1\/$')
92
93
    def test_rebind_branch5(self):
94
        self.setup_rebind('knit')
95
        os.chdir('branch2')
96
        error = self.run_bzr('bind', retcode=3)[1]
97
        self.assertContainsRe(error, 'old locations')
98
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
99
    def test_bound_commit(self):
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
100
        child_tree = self.create_branches()[1]
101
102
        self.build_tree_contents([('child/a', 'new contents')])
103
        child_tree.commit(message='child')
104
105
        self.check_revno(2, 'child')
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
106
107
        # Make sure it committed on the parent
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
108
        self.check_revno(2, 'base')
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
109
1505.1.4 by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work
110
    def test_bound_fail(self):
1505.1.26 by John Arbash Meinel
Created a set of tests which bind to an sftp branch. Found some bugs, need to fix commit.
111
        # Make sure commit fails if out of date.
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
112
        base_tree, child_tree = self.create_branches()
113
114
        self.build_tree_contents([
115
            ('base/a',  'new base contents\n'   ),
116
            ('child/b', 'new b child contents\n')])
117
        base_tree.commit(message='base')
118
        self.check_revno(2, 'base')
119
120
        self.check_revno(1, 'child')
121
        self.assertRaises(errors.BoundBranchOutOfDate, child_tree.commit,
122
                                                            message='child')
123
        self.check_revno(1, 'child')
124
125
        child_tree.update()
126
        self.check_revno(2, 'child')
127
128
        child_tree.commit(message='child')
129
        self.check_revno(3, 'child')
130
        self.check_revno(3, 'base')
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
131
1505.1.2 by John Arbash Meinel
(broken) working on implementing bound branches.
132
    def test_double_binding(self):
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
133
        child_tree = self.create_branches()[1]
134
135
        child2_tree = child_tree.bzrdir.sprout('child2').open_workingtree()
136
1505.1.2 by John Arbash Meinel
(broken) working on implementing bound branches.
137
        os.chdir('child2')
1505.1.6 by John Arbash Meinel
Cleaned up tests and code, all bound branch tests succeed.
138
        # Double binding succeeds, but committing to child2 should fail
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
139
        self.run_bzr('bind ../child')
1505.1.2 by John Arbash Meinel
(broken) working on implementing bound branches.
140
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
141
        self.assertRaises(errors.CommitToDoubleBoundBranch,
142
                child2_tree.commit, message='child2', allow_pointless=True)
1505.1.2 by John Arbash Meinel
(broken) working on implementing bound branches.
143
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
144
    def test_unbinding(self):
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
145
        base_tree, child_tree = self.create_branches()
146
147
        self.build_tree_contents([
148
            ('base/a',  'new base contents\n'   ),
149
            ('child/b', 'new b child contents\n')])
150
151
        base_tree.commit(message='base')
152
        self.check_revno(2, 'base')
153
154
        self.check_revno(1, 'child')
155
        os.chdir('child')
156
        self.run_bzr("commit -m child", retcode=3)
157
        self.check_revno(1)
158
        self.run_bzr('unbind')
159
        child_tree.commit(message='child')
160
        self.check_revno(2)
161
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
162
    def test_commit_remote_bound(self):
163
        # It is not possible to commit to a branch
164
        # which is bound to a branch which is bound
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
165
        base_tree, child_tree = self.create_branches()
166
        base_tree.bzrdir.sprout('newbase')
167
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
168
        os.chdir('base')
169
        # There is no way to know that B has already
170
        # been bound by someone else, otherwise it
171
        # might be nice if this would fail
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
172
        self.run_bzr('bind ../newbase')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
173
174
        os.chdir('../child')
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
175
        self.run_bzr('commit -m failure --unchanged', retcode=3)
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
176
177
    def test_pull_updates_both(self):
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
178
        base_tree = self.create_branches()[0]
179
        newchild_tree = base_tree.bzrdir.sprout('newchild').open_workingtree()
180
        self.build_tree_contents([('newchild/b', 'newchild b contents\n')])
181
        newchild_tree.commit(message='newchild')
182
        self.check_revno(2, 'newchild')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
183
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
184
        os.chdir('child')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
185
        # The pull should succeed, and update
186
        # the bound parent branch
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
187
        self.run_bzr('pull ../newchild')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
188
        self.check_revno(2)
189
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
190
        self.check_revno(2, '../base')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
191
4056.6.2 by Gary van der Merwe
Implement test for pull --local
192
    def test_pull_local_updates_local(self):
193
        base_tree = self.create_branches()[0]
194
        newchild_tree = base_tree.bzrdir.sprout('newchild').open_workingtree()
195
        self.build_tree_contents([('newchild/b', 'newchild b contents\n')])
196
        newchild_tree.commit(message='newchild')
197
        self.check_revno(2, 'newchild')
198
199
        os.chdir('child')
200
        # The pull should succeed, and update
201
        # the bound parent branch
202
        self.run_bzr('pull ../newchild --local')
203
        self.check_revno(2)
204
205
        self.check_revno(1, '../base')
206
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
207
    def test_bind_diverged(self):
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
208
        base_tree, child_tree = self.create_branches()
209
        base_branch = base_tree.branch
210
        child_branch = child_tree.branch
211
212
        os.chdir('child')
213
        self.run_bzr('unbind')
214
215
        child_tree.commit(message='child', allow_pointless=True)
216
        self.check_revno(2)
217
218
        os.chdir('..')
219
        self.check_revno(1, 'base')
220
        base_tree.commit(message='base', allow_pointless=True)
221
        self.check_revno(2, 'base')
222
223
        os.chdir('child')
3099.1.1 by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry
224
        # These branches have diverged, but bind should succeed anyway
225
        self.run_bzr('bind ../base')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
226
3099.1.1 by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry
227
        # This should turn the local commit into a merge
228
        child_tree.update()
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
229
        child_tree.commit(message='merged')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
230
        self.check_revno(3)
231
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
232
        # After binding, the revision history should be unaltered
233
        # take a copy before
234
        base_history = base_branch.revision_history()
235
        child_history = child_branch.revision_history()
236
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
237
    def test_bind_parent_ahead(self):
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
238
        base_tree = self.create_branches()[0]
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
239
240
        os.chdir('child')
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
241
        self.run_bzr('unbind')
242
243
        base_tree.commit(message='base', allow_pointless=True)
244
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
245
        self.check_revno(1)
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
246
        self.run_bzr('bind ../base')
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
247
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
248
        # binding does not pull data:
249
        self.check_revno(1)
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
250
        self.run_bzr('unbind')
1505.1.11 by John Arbash Meinel
Adding a little bit more to the test suite.
251
252
        # Check and make sure it also works if parent is ahead multiple
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
253
        base_tree.commit(message='base 3', allow_pointless=True)
254
        base_tree.commit(message='base 4', allow_pointless=True)
255
        base_tree.commit(message='base 5', allow_pointless=True)
256
        self.check_revno(5, '../base')
1505.1.11 by John Arbash Meinel
Adding a little bit more to the test suite.
257
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
258
        self.check_revno(1)
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
259
        self.run_bzr('bind ../base')
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
260
        self.check_revno(1)
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
261
262
    def test_bind_child_ahead(self):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
263
        # test binding when the master branches history is a prefix of the
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
264
        # childs - it should bind ok but the revision histories should not
265
        # be altered
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
266
        child_tree = self.create_branches()[1]
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
267
268
        os.chdir('child')
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
269
        self.run_bzr('unbind')
270
        child_tree.commit(message='child', allow_pointless=True)
1505.1.3 by John Arbash Meinel
(broken) Adding more tests, and some functionality
271
        self.check_revno(2)
272
        self.check_revno(1, '../base')
273
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
274
        self.run_bzr('bind ../base')
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
275
        self.check_revno(1, '../base')
1505.1.1 by John Arbash Meinel
Adding test for bound behavior
276
1505.1.11 by John Arbash Meinel
Adding a little bit more to the test suite.
277
        # Check and make sure it also works if child is ahead multiple
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
278
        self.run_bzr('unbind')
279
        child_tree.commit(message='child 3', allow_pointless=True)
280
        child_tree.commit(message='child 4', allow_pointless=True)
281
        child_tree.commit(message='child 5', allow_pointless=True)
1505.1.11 by John Arbash Meinel
Adding a little bit more to the test suite.
282
        self.check_revno(5)
283
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
284
        self.check_revno(1, '../base')
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
285
        self.run_bzr('bind ../base')
1997.1.5 by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the
286
        self.check_revno(1, '../base')
1505.1.11 by John Arbash Meinel
Adding a little bit more to the test suite.
287
3099.1.1 by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry
288
    def test_bind_fail_if_missing(self):
289
        """We should not be able to bind to a missing branch."""
290
        tree = self.make_branch_and_tree('tree_1')
291
        tree.commit('dummy commit')
292
        self.run_bzr_error(['Not a branch.*no-such-branch/'], ['bind', '../no-such-branch'],
293
                            working_dir='tree_1')
294
        self.assertIs(None, tree.branch.get_bound_location())
295
3565.6.11 by Marius Kruger
Bind now updates explicit nicks
296
    def test_bind_nick(self):
297
        """Bind should not update implicit nick."""
298
        base = self.make_branch_and_tree('base')
299
        child = self.make_branch_and_tree('child')
300
        os.chdir('child')
301
        self.assertEqual(child.branch.nick, 'child')
302
        self.assertEqual(child.branch.get_config().has_explicit_nickname(),
303
            False)
304
        self.run_bzr('bind ../base')
305
        self.assertEqual(child.branch.nick, base.branch.nick)
306
        self.assertEqual(child.branch.get_config().has_explicit_nickname(),
307
            False)
308
309
    def test_bind_explicit_nick(self):
310
        """Bind should update explicit nick."""
311
        base = self.make_branch_and_tree('base')
312
        child = self.make_branch_and_tree('child')
313
        os.chdir('child')
314
        child.branch.nick = "explicit_nick"
315
        self.assertEqual(child.branch.nick, "explicit_nick")
316
        self.assertEqual(child.branch.get_config()._get_explicit_nickname(),
317
            "explicit_nick")
318
        self.run_bzr('bind ../base')
319
        self.assertEqual(child.branch.nick, base.branch.nick)
320
        self.assertEqual(child.branch.get_config()._get_explicit_nickname(),
321
            base.branch.nick)
322
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
323
    def test_commit_after_merge(self):
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
324
        base_tree, child_tree = self.create_branches()
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
325
326
        # We want merge to be able to be a local only
327
        # operation, because it can be without violating
328
        # the binding invariants.
329
        # But we can't fail afterwards
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
330
        other_tree = child_tree.bzrdir.sprout('other').open_workingtree()
331
        other_branch = other_tree.branch
332
333
        self.build_tree_contents([('other/c', 'file c\n')])
334
        other_tree.add('c')
335
        other_tree.commit(message='adding c')
336
        new_rev_id = other_branch.revision_history()[-1]
337
338
        child_tree.merge_from_branch(other_branch)
339
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
340
        self.assertPathExists('child/c')
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
341
        self.assertEqual([new_rev_id], child_tree.get_parent_ids()[1:])
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
342
343
        # Make sure the local branch has the installed revision
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
344
        self.assertTrue(child_tree.branch.repository.has_revision(new_rev_id))
345
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
346
        # And make sure that the base tree does not
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
347
        self.assertFalse(base_tree.branch.repository.has_revision(new_rev_id))
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
348
349
        # Commit should succeed, and cause merged revisions to
350
        # be pulled into base
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
351
        os.chdir('child')
352
        self.run_bzr(['commit', '-m', 'merge other'])
353
354
        self.check_revno(2)
355
356
        self.check_revno(2, '../base')
357
358
        self.assertTrue(base_tree.branch.repository.has_revision(new_rev_id))
1505.1.24 by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge
359
2246.1.3 by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These
360
    def test_pull_overwrite(self):
361
        # XXX: This test should be moved to branch-implemenations/test_pull
2664.8.1 by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate.
362
        child_tree = self.create_branches()[1]
363
364
        other_tree = child_tree.bzrdir.sprout('other').open_workingtree()
365
366
        self.build_tree_contents([('other/a', 'new contents\n')])
367
        other_tree.commit(message='changed a')
368
        self.check_revno(2, 'other')
369
        self.build_tree_contents([
370
            ('other/a', 'new contents\nand then some\n')])
371
        other_tree.commit(message='another a')
372
        self.check_revno(3, 'other')
373
        self.build_tree_contents([
374
            ('other/a', 'new contents\nand then some\nand some more\n')])
375
        other_tree.commit('yet another a')
376
        self.check_revno(4, 'other')
377
378
        self.build_tree_contents([('child/a', 'also changed a\n')])
379
        child_tree.commit(message='child modified a')
380
381
        self.check_revno(2, 'child')
382
        self.check_revno(2, 'base')
383
384
        os.chdir('child')
385
        self.run_bzr('pull --overwrite ../other')
2246.1.3 by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These
386
387
        # both the local and master should have been updated.
388
        self.check_revno(4)
389
        self.check_revno(4, '../base')
4988.7.1 by Neil Martinsen-Burrell
better error message for bzr bind on and already bound branch
390
5171.3.7 by Martin von Gagern
Added blackbox tests for --directory option.
391
    def test_bind_directory(self):
392
        """Test --directory option"""
393
        tree = self.make_branch_and_tree('base')
394
        self.build_tree(['base/a', 'base/b'])
395
        tree.add('a', 'b')
396
        tree.commit(message='init')
397
        branch = tree.branch
398
        tree.bzrdir.sprout('child')
399
        self.run_bzr('bind --directory=child base')
400
        d = BzrDir.open('child')
401
        self.assertNotEqual(None, d.open_branch().get_master_branch())
402
        self.run_bzr('unbind -d child')
403
        self.assertEqual(None, d.open_branch().get_master_branch())
404
        self.run_bzr('unbind --directory child', retcode=3)
405
4988.7.1 by Neil Martinsen-Burrell
better error message for bzr bind on and already bound branch
406
407
class TestBind(script.TestCaseWithTransportAndScript):
408
409
    def test_bind_when_bound(self):
410
        self.run_script("""
411
$ bzr init trunk
5422.3.2 by Martin Pool
Update existing script tests to not ignore their output
412
...
4988.7.1 by Neil Martinsen-Burrell
better error message for bzr bind on and already bound branch
413
$ bzr init copy
5422.3.2 by Martin Pool
Update existing script tests to not ignore their output
414
...
4988.7.1 by Neil Martinsen-Burrell
better error message for bzr bind on and already bound branch
415
$ cd copy
416
$ bzr bind ../trunk
417
$ bzr bind
418
2>bzr: ERROR: Branch is already bound
419
""")
420
421
    def test_bind_before_bound(self):
422
        self.run_script("""
423
$ bzr init trunk
5422.3.2 by Martin Pool
Update existing script tests to not ignore their output
424
...
4988.7.1 by Neil Martinsen-Burrell
better error message for bzr bind on and already bound branch
425
$ cd trunk
426
$ bzr bind
427
2>bzr: ERROR: No location supplied and no previous location known
428
""")