1
1
# Copyright (C) 2006 by Canonical Ltd
2
2
# -*- coding: utf-8 -*-
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.
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.
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
31
29
def test_update_standalone_trivial(self):
32
30
self.runbzr("init")
33
31
out, err = self.runbzr('update')
34
self.assertEqual('Tree is up to date at revision 0.\n', err)
35
self.assertEqual('', out)
37
def test_update_standalone_trivial_with_alias_up(self):
39
out, err = self.runbzr('up')
40
self.assertEqual('Tree is up to date at revision 0.\n', err)
32
self.assertEqual('Tree is up to date.\n', err)
41
33
self.assertEqual('', out)
43
35
def test_update_up_to_date_light_checkout(self):
44
36
self.make_branch_and_tree('branch')
45
37
self.runbzr('checkout --lightweight branch checkout')
46
38
out, err = self.runbzr('update checkout')
47
self.assertEqual('Tree is up to date at revision 0.\n', err)
48
self.assertEqual('', out)
50
def test_update_up_to_date_checkout(self):
51
self.make_branch_and_tree('branch')
52
self.run_bzr('checkout', 'branch', 'checkout')
53
out, err = self.run_bzr('update', 'checkout')
54
self.assertEqual('Tree is up to date at revision 0.\n', err)
39
self.assertEqual('Tree is up to date.\n', err)
55
40
self.assertEqual('', out)
57
42
def test_update_out_of_date_standalone_tree(self):
58
43
# FIXME the default format has to change for this to pass
59
44
# because it currently uses the branch last-revision marker.
45
raise TestSkipped('default format too old')
60
46
self.make_branch_and_tree('branch')
62
48
self.runbzr('checkout --lightweight branch checkout')
65
51
self.runbzr('commit -m add-file checkout')
66
52
# now branch should be out of date
67
53
out,err = self.runbzr('update branch')
68
self.assertEqual('', out)
69
self.assertEqual('All changes applied successfully.\n'
70
'Updated to revision 1.\n', err)
54
self.assertEqual('Updated to revision 1.\n', out)
55
self.assertEqual('', err)
71
56
self.failUnlessExists('branch/file')
73
58
def test_update_out_of_date_light_checkout(self):
139
124
# now, update checkout ->
140
125
# get all three files and a pending merge.
141
out, err = self.run_bzr('update', 'checkout')
142
self.assertEqual('', out)
143
self.assertContainsRe(err, 'Updated to revision 1.\n'
144
'Your local commits will now show as'
126
self.run_bzr('update', 'checkout')
146
127
wt = WorkingTree.open('checkout')
147
128
self.assertNotEqual([], wt.pending_merges())
148
129
self.failUnlessExists('checkout/file')
149
130
self.failUnlessExists('checkout/file_b')
150
131
self.failUnlessExists('checkout/file_c')
151
132
self.assertTrue(wt.has_filename('file_c'))
153
def test_update_with_merges(self):
154
# Test that 'bzr update' works correctly when you have
155
# an update in the master tree, and a lightweight checkout
156
# which has merged another branch
157
master = self.make_branch_and_tree('master')
158
self.build_tree(['master/file'])
160
master.commit('one', rev_id='m1')
162
self.build_tree(['checkout1/'])
163
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
164
branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
165
checkout1 = checkout_dir.create_workingtree('m1')
167
# Create a second branch, with an extra commit
168
other = master.bzrdir.sprout('other').open_workingtree()
169
self.build_tree(['other/file2'])
171
other.commit('other2', rev_id='o2')
173
# Create a new commit in the master branch
174
self.build_tree(['master/file3'])
175
master.add(['file3'])
176
master.commit('f3', rev_id='m2')
178
# Merge the other branch into checkout
179
os.chdir('checkout1')
180
self.run_bzr('merge', '../other')
182
self.assertEqual(['o2'], checkout1.pending_merges())
184
# At this point, 'commit' should fail, because we are out of date
185
self.run_bzr_error(["please run 'bzr update'"],
186
'commit', '-m', 'merged')
188
# This should not report about local commits being pending
189
# merges, because they were real merges
190
out, err = self.run_bzr('update')
191
self.assertEqual('', out)
192
self.assertEqual('All changes applied successfully.\n'
193
'Updated to revision 2.\n', err)
195
# The pending merges should still be there
196
self.assertEqual(['o2'], checkout1.pending_merges())