~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_pull.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-27 01:14:33 UTC
  • mfrom: (1686.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060427011433-95634ee1da8a2049
Merge in faster joins from weave to knit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005 by Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
 
#
 
3
 
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
6
6
# the Free Software Foundation; either version 2 of the License, or
7
7
# (at your option) any later version.
8
 
#
 
8
 
9
9
# This program is distributed in the hope that it will be useful,
10
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
12
# GNU General Public License for more details.
13
 
#
 
13
 
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
22
import sys
23
23
 
24
24
from bzrlib.branch import Branch
 
25
from bzrlib.osutils import abspath
25
26
from bzrlib.tests.blackbox import ExternalBase
26
27
from bzrlib.uncommit import uncommit
27
28
 
247
248
        tree_b.commit('commit d')
248
249
        out = self.runbzr('pull ../branch_a', retcode=3)
249
250
        self.assertEquals(out,
250
 
                ('','bzr: ERROR: These branches have diverged.  Use the merge command to reconcile them.\n'))
251
 
        self.assertEquals(branch_b.get_parent(), parent)
 
251
                ('','bzr: ERROR: These branches have diverged.  Try merge.\n'))
 
252
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
252
253
        # test implicit --remember after resolving previous failure
253
254
        uncommit(branch=branch_b, tree=tree_b)
254
255
        transport.delete('branch_b/d')
255
256
        self.runbzr('pull')
256
 
        self.assertEquals(branch_b.get_parent(), parent)
 
257
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
257
258
        # test explicit --remember
258
259
        self.runbzr('pull ../branch_c --remember')
259
 
        self.assertEquals(branch_b.get_parent(),
260
 
                          branch_c.bzrdir.root_transport.base)
261
 
 
262
 
    def test_pull_bundle(self):
263
 
        from bzrlib.testament import Testament
264
 
        # Build up 2 trees and prepare for a pull
265
 
        tree_a = self.make_branch_and_tree('branch_a')
266
 
        f = open('branch_a/a', 'wb')
267
 
        f.write('hello')
268
 
        f.close()
269
 
        tree_a.add('a')
270
 
        tree_a.commit('message')
271
 
 
272
 
        tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree()
273
 
 
274
 
        # Make a change to 'a' that 'b' can pull
275
 
        f = open('branch_a/a', 'wb')
276
 
        f.write('hey there')
277
 
        f.close()
278
 
        tree_a.commit('message')
279
 
 
280
 
        # Create the bundle for 'b' to pull
281
 
        os.chdir('branch_a')
282
 
        bundle_file = open('../bundle', 'wb')
283
 
        bundle_file.write(self.run_bzr('bundle', '../branch_b')[0])
284
 
        bundle_file.close()
285
 
 
286
 
        os.chdir('../branch_b')
287
 
        output = self.run_bzr('pull', '../bundle')
288
 
        self.assertEqual('', output[0])
289
 
        self.assertEqual('All changes applied successfully.\n'
290
 
                         '1 revision(s) pulled.\n', output[1])
291
 
 
292
 
        self.assertEqualDiff(tree_a.branch.revision_history(),
293
 
                             tree_b.branch.revision_history())
294
 
 
295
 
        testament_a = Testament.from_revision(tree_a.branch.repository, 
296
 
                                              tree_a.last_revision())
297
 
        testament_b = Testament.from_revision(tree_b.branch.repository,
298
 
                                              tree_b.last_revision())
299
 
        self.assertEqualDiff(testament_a.as_text(),
300
 
                             testament_b.as_text())
301
 
 
302
 
        # it is legal to attempt to pull an already-merged bundle
303
 
        output = self.run_bzr('pull', '../bundle')
304
 
        self.assertEqual('', output[0])
305
 
        self.assertEqual('0 revision(s) pulled.\n', output[1])
 
260
        self.assertEquals(abspath(branch_b.get_parent()),
 
261
                          abspath(branch_c.bzrdir.root_transport.base))