1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
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.
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.
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
19
"""Tests for the update command of bzr."""
22
from bzrlib.tests import TestSkipped
23
from bzrlib.tests.blackbox import ExternalBase
26
class TestUpdate(ExternalBase):
28
def test_update_standalone_trivial(self):
30
out, err = self.runbzr('update')
31
self.assertEqual('Tree is up to date.\n', err)
32
self.assertEqual('', out)
34
def test_update_up_to_date_checkout(self):
35
self.make_branch_and_tree('branch')
36
self.runbzr('checkout branch checkout')
37
out, err = self.runbzr('update branch')
38
self.assertEqual('Tree is up to date.\n', err)
39
self.assertEqual('', out)
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')
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')
57
def test_update_out_of_date_checkout(self):
58
self.make_branch_and_tree('branch')
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',
70
self.assertEqual('', out)
72
def test_update_conflicts_returns_2(self):
73
self.make_branch_and_tree('branch')
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')
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')
90
out,err = self.runbzr('update checkout2', retcode=1)
91
self.assertEqual(['1 conflicts encountered.',
92
'Updated to revision 2.'],
94
self.assertContainsRe(err, 'Diff3 conflict encountered in.*file\n')
95
self.assertEqual('', out)
96
self.failUnlessExists('checkout2/file')