/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
1508.1.24 by Robert Collins
Add update command for use with checkouts.
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
25
26
class TestUpdate(ExternalBase):
27
28
    def test_update_standalone_trivial(self):
29
        self.runbzr("init")
30
        out, err = self.runbzr('update')
31
        self.assertEqual('Tree is up to date.\n', err)
32
        self.assertEqual('', out)
33
34
    def test_update_up_to_date_checkout(self):
35
        self.make_branch_and_tree('branch')
36
        self.runbzr('checkout branch checkout')
1534.5.1 by Robert Collins
Give info some reasonable output and tests.
37
        out, err = self.runbzr('update checkout')
1508.1.24 by Robert Collins
Add update command for use with checkouts.
38
        self.assertEqual('Tree is up to date.\n', err)
39
        self.assertEqual('', out)
40
41
    def test_update_out_of_date_standalone_tree(self):
42
        # FIXME the default format has to change for this to pass
43
        # because it currently uses the branch last-revision marker.
44
        raise TestSkipped('default format too old')
45
        self.make_branch_and_tree('branch')
46
        # make a checkout
47
        self.runbzr('checkout branch checkout')
48
        self.build_tree(['checkout/file'])
49
        self.runbzr('add checkout/file')
50
        self.runbzr('commit -m add-file checkout')
51
        # now branch should be out of date
52
        out,err = self.runbzr('update branch')
53
        self.assertEqual('Updated to revision 1.\n', out)
54
        self.assertEqual('', err)
55
        self.failUnlessExists('branch/file')
56
57
    def test_update_out_of_date_checkout(self):
58
        self.make_branch_and_tree('branch')
59
        # make two checkouts
60
        self.runbzr('checkout branch checkout')
61
        self.runbzr('checkout branch checkout2')
62
        self.build_tree(['checkout/file'])
63
        self.runbzr('add checkout/file')
64
        self.runbzr('commit -m add-file checkout')
65
        # now checkout2 should be out of date
66
        out,err = self.runbzr('update checkout2')
67
        self.assertEqual('All changes applied successfully.\n'
68
                         'Updated to revision 1.\n',
69
                         err)
70
        self.assertEqual('', out)
71
72
    def test_update_conflicts_returns_2(self):
73
        self.make_branch_and_tree('branch')
74
        # make two checkouts
75
        self.runbzr('checkout branch checkout')
76
        self.build_tree(['checkout/file'])
77
        self.runbzr('add checkout/file')
78
        self.runbzr('commit -m add-file checkout')
79
        self.runbzr('checkout branch checkout2')
80
        # now alter file in checkout
81
        a_file = file('checkout/file', 'wt')
82
        a_file.write('Foo')
83
        a_file.close()
84
        self.runbzr('commit -m checnge-file checkout')
85
        # now checkout2 should be out of date
86
        # make a local change to file
87
        a_file = file('checkout2/file', 'wt')
88
        a_file.write('Bar')
89
        a_file.close()
90
        out,err = self.runbzr('update checkout2', retcode=1)
91
        self.assertEqual(['1 conflicts encountered.',
92
                          'Updated to revision 2.'],
93
                         err.split('\n')[1:3])
1534.7.164 by Aaron Bentley
Updated test to new conflict message
94
        self.assertContainsRe(err, 'Text conflict in file\n')
1508.1.24 by Robert Collins
Add update command for use with checkouts.
95
        self.assertEqual('', out)