/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2220.2.9 by Martin Pool
Add specific tests for push -d and pull -d
1
# Copyright (C) 2005, 2006 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
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
#
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
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
#
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
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
17
1666.1.5 by Robert Collins
Merge bound branch test performance improvements.
18
"""Black-box tests for bzr pull."""
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
19
20
import os
21
import sys
22
23
from bzrlib.branch import Branch
24
from bzrlib.tests.blackbox import ExternalBase
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
25
from bzrlib.uncommit import uncommit
2220.2.9 by Martin Pool
Add specific tests for push -d and pull -d
26
from bzrlib import urlutils
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
27
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
28
1185.50.7 by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull
29
class TestPull(ExternalBase):
30
31
    def example_branch(test):
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
32
        test.run_bzr('init')
1185.50.7 by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull
33
        file('hello', 'wt').write('foo')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
34
        test.run_bzr('add hello')
35
        test.run_bzr('commit -m setup hello')
1185.50.7 by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull
36
        file('goodbye', 'wt').write('baz')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
37
        test.run_bzr('add goodbye')
38
        test.run_bzr('commit -m setup goodbye')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
39
40
    def test_pull(self):
41
        """Pull changes from one branch to another."""
42
        os.mkdir('a')
43
        os.chdir('a')
44
45
        self.example_branch()
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
46
        self.run_bzr('pull', retcode=3)
47
        self.run_bzr('missing', retcode=3)
48
        self.run_bzr('missing .')
49
        self.run_bzr('missing')
1666.1.5 by Robert Collins
Merge bound branch test performance improvements.
50
        # this will work on windows because we check for the same branch
51
        # in pull - if it fails, it is a regression
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
52
        self.run_bzr('pull')
53
        self.run_bzr('pull /', retcode=3)
1185.31.31 by John Arbash Meinel
avoiding 'bzr pull .' means all tests pass under cygwin
54
        if sys.platform not in ('win32', 'cygwin'):
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
55
            self.run_bzr('pull')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
56
57
        os.chdir('..')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
58
        self.run_bzr('branch a b')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
59
        os.chdir('b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
60
        self.run_bzr('pull')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
61
        os.mkdir('subdir')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
62
        self.run_bzr('add subdir')
63
        self.run_bzr('commit -m blah --unchanged')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
64
        os.chdir('../a')
65
        a = Branch.open('.')
66
        b = Branch.open('../b')
67
        self.assertEquals(a.revision_history(), b.revision_history()[:-1])
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
68
        self.run_bzr('pull ../b')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
69
        self.assertEquals(a.revision_history(), b.revision_history())
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
70
        self.run_bzr('commit -m blah2 --unchanged')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
71
        os.chdir('../b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
72
        self.run_bzr('commit -m blah3 --unchanged')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
73
        # no overwrite
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
74
        self.run_bzr('pull ../a', retcode=3)
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
75
        os.chdir('..')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
76
        self.run_bzr('branch b overwriteme')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
77
        os.chdir('overwriteme')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
78
        self.run_bzr('pull --overwrite ../a')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
79
        overwritten = Branch.open('.')
80
        self.assertEqual(overwritten.revision_history(),
81
                         a.revision_history())
82
        os.chdir('../a')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
83
        self.run_bzr('merge ../b')
84
        self.run_bzr('commit -m blah4 --unchanged')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
85
        os.chdir('../b/subdir')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
86
        self.run_bzr('pull ../../a')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
87
        self.assertEquals(a.revision_history()[-1], b.revision_history()[-1])
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
88
        self.run_bzr('commit -m blah5 --unchanged')
89
        self.run_bzr('commit -m blah6 --unchanged')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
90
        os.chdir('..')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
91
        self.run_bzr('pull ../a')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
92
        os.chdir('../a')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
93
        self.run_bzr('commit -m blah7 --unchanged')
94
        self.run_bzr('merge ../b')
95
        self.run_bzr('commit -m blah8 --unchanged')
96
        self.run_bzr('pull ../b')
97
        self.run_bzr('pull ../b')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
98
2220.2.9 by Martin Pool
Add specific tests for push -d and pull -d
99
    def test_pull_dash_d(self):
100
        os.mkdir('a')
101
        os.chdir('a')
102
        self.example_branch()
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
103
        self.run_bzr('init ../b')
104
        self.run_bzr('init ../c')
2220.2.9 by Martin Pool
Add specific tests for push -d and pull -d
105
        # pull into that branch
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
106
        self.run_bzr('pull -d ../b .')
2220.2.9 by Martin Pool
Add specific tests for push -d and pull -d
107
        # pull into a branch specified by a url
108
        c_url = urlutils.local_path_to_url('../c')
109
        self.assertStartsWith(c_url, 'file://')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
110
        self.run_bzr('pull -d %s .' % c_url)
2220.2.9 by Martin Pool
Add specific tests for push -d and pull -d
111
1185.76.2 by Erik Bågfors
test for pull --revision
112
    def test_pull_revision(self):
113
        """Pull some changes from one branch to another."""
114
        os.mkdir('a')
115
        os.chdir('a')
116
117
        self.example_branch()
118
        file('hello2', 'wt').write('foo')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
119
        self.run_bzr('add hello2')
120
        self.run_bzr('commit -m setup hello2')
1185.76.2 by Erik Bågfors
test for pull --revision
121
        file('goodbye2', 'wt').write('baz')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
122
        self.run_bzr('add goodbye2')
123
        self.run_bzr('commit -m setup goodbye2')
1185.76.2 by Erik Bågfors
test for pull --revision
124
125
        os.chdir('..')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
126
        self.run_bzr('branch -r 1 a b')
1185.76.2 by Erik Bågfors
test for pull --revision
127
        os.chdir('b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
128
        self.run_bzr('pull -r 2')
1185.76.2 by Erik Bågfors
test for pull --revision
129
        a = Branch.open('../a')
130
        b = Branch.open('.')
1185.76.4 by Erik Bågfors
expanded tabs
131
        self.assertEquals(a.revno(),4)
132
        self.assertEquals(b.revno(),2)
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
133
        self.run_bzr('pull -r 3')
1185.76.4 by Erik Bågfors
expanded tabs
134
        self.assertEquals(b.revno(),3)
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
135
        self.run_bzr('pull -r 4')
1185.76.2 by Erik Bågfors
test for pull --revision
136
        self.assertEquals(a.revision_history(), b.revision_history())
137
138
1185.50.7 by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull
139
    def test_overwrite_uptodate(self):
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
140
        # Make sure pull --overwrite overwrites
141
        # even if the target branch has merged
142
        # everything already.
143
        bzr = self.run_bzr
144
145
        def get_rh(expected_len):
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
146
            rh = self.run_bzr('revision-history')[0]
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
147
            # Make sure we don't have trailing empty revisions
148
            rh = rh.strip().split('\n')
149
            self.assertEqual(len(rh), expected_len)
150
            return rh
151
152
        os.mkdir('a')
153
        os.chdir('a')
154
        bzr('init')
155
        open('foo', 'wb').write('original\n')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
156
        bzr('add foo')
2552.2.5 by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings.
157
        bzr(['commit', '-m', 'initial commit'])
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
158
159
        os.chdir('..')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
160
        bzr('branch a b')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
161
162
        os.chdir('a')
163
        open('foo', 'wb').write('changed\n')
2552.2.5 by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings.
164
        bzr(['commit', '-m', 'later change'])
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
165
166
        open('foo', 'wb').write('another\n')
2552.2.5 by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings.
167
        bzr(['commit', '-m', 'a third change'])
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
168
169
        rev_history_a = get_rh(3)
170
171
        os.chdir('../b')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
172
        bzr('merge ../a')
173
        bzr('commit -m merge')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
174
175
        rev_history_b = get_rh(2)
176
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
177
        bzr('pull --overwrite ../a')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
178
        rev_history_b = get_rh(3)
179
180
        self.assertEqual(rev_history_b, rev_history_a)
181
1185.50.7 by John Arbash Meinel
Fix broken test from refactoring blackbox/test_pull
182
    def test_overwrite_children(self):
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
183
        # Make sure pull --overwrite sets the revision-history
184
        # to be identical to the pull source, even if we have convergence
185
        bzr = self.run_bzr
186
187
        def get_rh(expected_len):
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
188
            rh = self.run_bzr('revision-history')[0]
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
189
            # Make sure we don't have trailing empty revisions
190
            rh = rh.strip().split('\n')
191
            self.assertEqual(len(rh), expected_len)
192
            return rh
193
194
        os.mkdir('a')
195
        os.chdir('a')
196
        bzr('init')
197
        open('foo', 'wb').write('original\n')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
198
        bzr('add foo')
2552.2.5 by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings.
199
        bzr(['commit', '-m', 'initial commit'])
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
200
201
        os.chdir('..')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
202
        bzr('branch a b')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
203
204
        os.chdir('a')
205
        open('foo', 'wb').write('changed\n')
2552.2.5 by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings.
206
        bzr(['commit', '-m', 'later change'])
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
207
208
        open('foo', 'wb').write('another\n')
2552.2.5 by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings.
209
        bzr(['commit', '-m', 'a third change'])
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
210
211
        rev_history_a = get_rh(3)
212
213
        os.chdir('../b')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
214
        bzr('merge ../a')
215
        bzr('commit -m merge')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
216
217
        rev_history_b = get_rh(2)
218
219
        os.chdir('../a')
220
        open('foo', 'wb').write('a fourth change\n')
2552.2.5 by Vincent Ladeuil
Revert the intrusive run_bzr('commit') rewritings.
221
        bzr(['commit', '-m', 'a fourth change'])
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
222
223
        rev_history_a = get_rh(4)
224
225
        # With convergence, we could just pull over the
226
        # new change, but with --overwrite, we want to switch our history
227
        os.chdir('../b')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
228
        bzr('pull --overwrite ../a')
1185.50.5 by John Arbash Meinel
pull --overwrite should always overwrite, not just if diverged. (Test case from Robey Pointer)
229
        rev_history_b = get_rh(4)
230
231
        self.assertEqual(rev_history_b, rev_history_a)
232
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
233
    def test_pull_remember(self):
234
        """Pull changes from one branch to another and test parent location."""
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
235
        transport = self.get_transport()
236
        tree_a = self.make_branch_and_tree('branch_a')
237
        branch_a = tree_a.branch
238
        self.build_tree(['branch_a/a'])
239
        tree_a.add('a')
240
        tree_a.commit('commit a')
1666.1.4 by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in
241
        tree_b = branch_a.bzrdir.sprout('branch_b').open_workingtree()
242
        branch_b = tree_b.branch
243
        tree_c = branch_a.bzrdir.sprout('branch_c').open_workingtree()
244
        branch_c = tree_c.branch
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
245
        self.build_tree(['branch_a/b'])
246
        tree_a.add('b')
247
        tree_a.commit('commit b')
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
248
        # reset parent
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
249
        parent = branch_b.get_parent()
250
        branch_b.set_parent(None)
251
        self.assertEqual(None, branch_b.get_parent())
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
252
        # test pull for failure without parent set
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
253
        os.chdir('branch_b')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
254
        out = self.run_bzr('pull', retcode=3)
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
255
        self.assertEquals(out,
256
                ('','bzr: ERROR: No pull location known or specified.\n'))
257
        # test implicit --remember when no parent set, this pull conflicts
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
258
        self.build_tree(['d'])
259
        tree_b.add('d')
260
        tree_b.commit('commit d')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
261
        out = self.run_bzr('pull ../branch_a', retcode=3)
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
262
        self.assertEquals(out,
2221.5.13 by Dmitry Vasiliev
Fixed expected message in test
263
                ('','bzr: ERROR: These branches have diverged.'
264
                    ' Use the merge command to reconcile them.\n'))
1685.1.19 by John Arbash Meinel
pull/merge/branch/missing should all save the absolute path to the other branch, not the relative one
265
        self.assertEquals(branch_b.get_parent(), parent)
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
266
        # test implicit --remember after resolving previous failure
1614.2.16 by Olaf Conradi
Modified blackbox test cases to use bzrlib API.
267
        uncommit(branch=branch_b, tree=tree_b)
268
        transport.delete('branch_b/d')
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
269
        self.run_bzr('pull')
1685.1.19 by John Arbash Meinel
pull/merge/branch/missing should all save the absolute path to the other branch, not the relative one
270
        self.assertEquals(branch_b.get_parent(), parent)
1614.2.8 by Olaf Conradi
Added testcases for using pull with --remember. Moved remember code to
271
        # test explicit --remember
2530.3.1 by Martin Pool
Cleanup old variations on run_bzr in the test suite
272
        self.run_bzr('pull ../branch_c --remember')
1685.1.19 by John Arbash Meinel
pull/merge/branch/missing should all save the absolute path to the other branch, not the relative one
273
        self.assertEquals(branch_b.get_parent(),
274
                          branch_c.bzrdir.root_transport.base)
1711.3.3 by John Arbash Meinel
Allow pull to use a bundle as a target,
275
276
    def test_pull_bundle(self):
277
        from bzrlib.testament import Testament
278
        # Build up 2 trees and prepare for a pull
279
        tree_a = self.make_branch_and_tree('branch_a')
280
        f = open('branch_a/a', 'wb')
281
        f.write('hello')
282
        f.close()
283
        tree_a.add('a')
284
        tree_a.commit('message')
285
286
        tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree()
287
288
        # Make a change to 'a' that 'b' can pull
289
        f = open('branch_a/a', 'wb')
290
        f.write('hey there')
291
        f.close()
292
        tree_a.commit('message')
293
294
        # Create the bundle for 'b' to pull
295
        os.chdir('branch_a')
296
        bundle_file = open('../bundle', 'wb')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
297
        bundle_file.write(self.run_bzr('bundle ../branch_b')[0])
1711.3.3 by John Arbash Meinel
Allow pull to use a bundle as a target,
298
        bundle_file.close()
299
300
        os.chdir('../branch_b')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
301
        out, err = self.run_bzr('pull ../bundle')
2220.2.39 by Martin Pool
Pull also merges tags and warns if they conflict
302
        self.assertEqual(out,
303
                         'Now on revision 2.\n')
304
        self.assertEqual(err,
305
                ' M  a\nAll changes applied successfully.\n')
1711.3.3 by John Arbash Meinel
Allow pull to use a bundle as a target,
306
307
        self.assertEqualDiff(tree_a.branch.revision_history(),
308
                             tree_b.branch.revision_history())
309
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
310
        testament_a = Testament.from_revision(tree_a.branch.repository,
311
                                              tree_a.get_parent_ids()[0])
1711.3.3 by John Arbash Meinel
Allow pull to use a bundle as a target,
312
        testament_b = Testament.from_revision(tree_b.branch.repository,
1908.7.6 by Robert Collins
Deprecate WorkingTree.last_revision.
313
                                              tree_b.get_parent_ids()[0])
1711.3.3 by John Arbash Meinel
Allow pull to use a bundle as a target,
314
        self.assertEqualDiff(testament_a.as_text(),
315
                             testament_b.as_text())
316
317
        # it is legal to attempt to pull an already-merged bundle
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
318
        out, err = self.run_bzr('pull ../bundle')
2220.2.39 by Martin Pool
Pull also merges tags and warns if they conflict
319
        self.assertEqual(err, '')
320
        self.assertEqual(out, 'No revisions to pull.\n')