~ubuntu-branches/ubuntu/lucid/bzr/lucid-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2006-03-20 08:31:00 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060320083100-ovdi2ssuw0epcx8s
Tags: 0.8~200603200831-0ubuntu1
* Snapshot uploaded to Dapper at Martin Pool's request.

* Disable testsuite for upload.  Fakeroot and the testsuite don't
  play along.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 by Canonical Ltd
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
 
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
 
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
 
 
19
"""Tests for the update command of bzr."""
 
20
 
 
21
 
 
22
from bzrlib.tests import TestSkipped
 
23
from bzrlib.tests.blackbox import ExternalBase
 
24
from bzrlib.workingtree import WorkingTree
 
25
 
 
26
 
 
27
class TestUpdate(ExternalBase):
 
28
 
 
29
    def test_update_standalone_trivial(self):
 
30
        self.runbzr("init")
 
31
        out, err = self.runbzr('update')
 
32
        self.assertEqual('Tree is up to date.\n', err)
 
33
        self.assertEqual('', out)
 
34
 
 
35
    def test_update_up_to_date_light_checkout(self):
 
36
        self.make_branch_and_tree('branch')
 
37
        self.runbzr('checkout --lightweight branch checkout')
 
38
        out, err = self.runbzr('update checkout')
 
39
        self.assertEqual('Tree is up to date.\n', err)
 
40
        self.assertEqual('', out)
 
41
 
 
42
    def test_update_out_of_date_standalone_tree(self):
 
43
        # FIXME the default format has to change for this to pass
 
44
        # because it currently uses the branch last-revision marker.
 
45
        raise TestSkipped('default format too old')
 
46
        self.make_branch_and_tree('branch')
 
47
        # make a checkout
 
48
        self.runbzr('checkout --lightweight branch checkout')
 
49
        self.build_tree(['checkout/file'])
 
50
        self.runbzr('add checkout/file')
 
51
        self.runbzr('commit -m add-file checkout')
 
52
        # now branch should be out of date
 
53
        out,err = self.runbzr('update branch')
 
54
        self.assertEqual('Updated to revision 1.\n', out)
 
55
        self.assertEqual('', err)
 
56
        self.failUnlessExists('branch/file')
 
57
 
 
58
    def test_update_out_of_date_light_checkout(self):
 
59
        self.make_branch_and_tree('branch')
 
60
        # make two checkouts
 
61
        self.runbzr('checkout --lightweight branch checkout')
 
62
        self.runbzr('checkout --lightweight branch checkout2')
 
63
        self.build_tree(['checkout/file'])
 
64
        self.runbzr('add checkout/file')
 
65
        self.runbzr('commit -m add-file checkout')
 
66
        # now checkout2 should be out of date
 
67
        out,err = self.runbzr('update checkout2')
 
68
        self.assertEqual('All changes applied successfully.\n'
 
69
                         'Updated to revision 1.\n',
 
70
                         err)
 
71
        self.assertEqual('', out)
 
72
 
 
73
    def test_update_conflicts_returns_2(self):
 
74
        self.make_branch_and_tree('branch')
 
75
        # make two checkouts
 
76
        self.runbzr('checkout --lightweight branch checkout')
 
77
        self.build_tree(['checkout/file'])
 
78
        self.runbzr('add checkout/file')
 
79
        self.runbzr('commit -m add-file checkout')
 
80
        self.runbzr('checkout --lightweight branch checkout2')
 
81
        # now alter file in checkout
 
82
        a_file = file('checkout/file', 'wt')
 
83
        a_file.write('Foo')
 
84
        a_file.close()
 
85
        self.runbzr('commit -m checnge-file checkout')
 
86
        # now checkout2 should be out of date
 
87
        # make a local change to file
 
88
        a_file = file('checkout2/file', 'wt')
 
89
        a_file.write('Bar')
 
90
        a_file.close()
 
91
        out,err = self.runbzr('update checkout2', retcode=1)
 
92
        self.assertEqual(['1 conflicts encountered.',
 
93
                          'Updated to revision 2.'],
 
94
                         err.split('\n')[1:3])
 
95
        self.assertContainsRe(err, 'Text conflict in file\n')
 
96
        self.assertEqual('', out)
 
97
 
 
98
    def test_smoke_update_checkout_bound_branch_local_commits(self):
 
99
        # smoke test for doing an update of a checkout of a bound
 
100
        # branch with local commits.
 
101
        self.make_branch_and_tree('master')
 
102
        # make a bound branch
 
103
        self.run_bzr('checkout', 'master', 'child')
 
104
        # check that out
 
105
        self.run_bzr('checkout', '--lightweight', 'child', 'checkout')
 
106
        # change master
 
107
        a_file = file('master/file', 'wt')
 
108
        a_file.write('Foo')
 
109
        a_file.close()
 
110
        self.run_bzr('add', 'master')
 
111
        self.run_bzr('commit', '-m', 'add file', 'master')
 
112
        # change child
 
113
        a_file = file('child/file_b', 'wt')
 
114
        a_file.write('Foo')
 
115
        a_file.close()
 
116
        self.run_bzr('add', 'child')
 
117
        self.run_bzr('commit', '--local', '-m', 'add file_b', 'child')
 
118
        # check checkout
 
119
        a_file = file('checkout/file_c', 'wt')
 
120
        a_file.write('Foo')
 
121
        a_file.close()
 
122
        self.run_bzr('add', 'checkout')
 
123
 
 
124
        # now, update checkout ->
 
125
        # get all three files and a pending merge.
 
126
        self.run_bzr('update', 'checkout')
 
127
        wt = WorkingTree.open('checkout')
 
128
        self.assertNotEqual([], wt.pending_merges())
 
129
        self.failUnlessExists('checkout/file')
 
130
        self.failUnlessExists('checkout/file_b')
 
131
        self.failUnlessExists('checkout/file_c')
 
132
        self.assertTrue(wt.has_filename('file_c'))