bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
2 |
# -*- coding: utf-8 -*-
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
3 |
#
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
8 |
#
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
13 |
#
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
17 |
|
18 |
||
19 |
"""Tests for the update command of bzr."""
|
|
20 |
||
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
21 |
import os |
22 |
import re |
|
23 |
||
24 |
from bzrlib import ( |
|
25 |
branch, |
|
26 |
bzrdir, |
|
27 |
osutils, |
|
28 |
tests, |
|
29 |
urlutils, |
|
30 |
workingtree, |
|
31 |
)
|
|
32 |
||
33 |
||
34 |
class TestUpdate(tests.TestCaseWithTransport): |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
35 |
|
36 |
def test_update_standalone_trivial(self): |
|
|
2664.7.2
by Daniel Watkins
tests.blackbox.test_update now uses internals where appropriate. |
37 |
self.make_branch_and_tree('.') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
38 |
out, err = self.run_bzr('update') |
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
39 |
self.assertEqual( |
40 |
'Tree is up to date at revision 0 of branch %s\n' % self.test_dir, |
|
41 |
err) |
|
|
4879.1.1
by Neil Martinsen-Burrell
update provides feedback on which branch it is up to date with. |
42 |
self.assertEqual('', out) |
43 |
||
44 |
def test_update_quiet(self): |
|
45 |
self.make_branch_and_tree('.') |
|
46 |
out, err = self.run_bzr('update --quiet') |
|
47 |
self.assertEqual('', err) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
48 |
self.assertEqual('', out) |
49 |
||
|
1815.3.4
by Stefan (metze) Metzmacher
add simple test for 'bzr up' |
50 |
def test_update_standalone_trivial_with_alias_up(self): |
|
2664.7.2
by Daniel Watkins
tests.blackbox.test_update now uses internals where appropriate. |
51 |
self.make_branch_and_tree('.') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
52 |
out, err = self.run_bzr('up') |
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
53 |
self.assertEqual('Tree is up to date at revision 0 of branch %s\n' |
54 |
% self.test_dir, |
|
55 |
err) |
|
|
1815.3.4
by Stefan (metze) Metzmacher
add simple test for 'bzr up' |
56 |
self.assertEqual('', out) |
57 |
||
|
1587.1.14
by Robert Collins
Make bound branch creation happen via 'checkout' |
58 |
def test_update_up_to_date_light_checkout(self): |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
59 |
self.make_branch_and_tree('branch') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
60 |
self.run_bzr('checkout --lightweight branch checkout') |
61 |
out, err = self.run_bzr('update checkout') |
|
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
62 |
self.assertEqual('Tree is up to date at revision 0 of branch %s\n' |
63 |
% osutils.pathjoin(self.test_dir, 'branch'), |
|
64 |
err) |
|
|
1830.1.1
by John Arbash Meinel
Print up to date even if bound, also always print out current revno. |
65 |
self.assertEqual('', out) |
66 |
||
67 |
def test_update_up_to_date_checkout(self): |
|
68 |
self.make_branch_and_tree('branch') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
69 |
self.run_bzr('checkout branch checkout') |
70 |
out, err = self.run_bzr('update checkout') |
|
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
71 |
self.assertEqual('Tree is up to date at revision 0 of branch %s\n' |
72 |
% osutils.pathjoin(self.test_dir, 'branch'), |
|
73 |
err) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
74 |
self.assertEqual('', out) |
75 |
||
76 |
def test_update_out_of_date_standalone_tree(self): |
|
77 |
# FIXME the default format has to change for this to pass
|
|
78 |
# because it currently uses the branch last-revision marker.
|
|
79 |
self.make_branch_and_tree('branch') |
|
80 |
# make a checkout
|
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
81 |
self.run_bzr('checkout --lightweight branch checkout') |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
82 |
self.build_tree(['checkout/file']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
83 |
self.run_bzr('add checkout/file') |
84 |
self.run_bzr('commit -m add-file checkout') |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
85 |
# now branch should be out of date
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
86 |
out,err = self.run_bzr('update branch') |
|
1711.2.107
by John Arbash Meinel
re-enable a skipped update test, and clean it up |
87 |
self.assertEqual('', out) |
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
88 |
self.assertEqualDiff("""+N file |
89 |
All changes applied successfully.
|
|
90 |
Updated to revision 1 of branch %s |
|
91 |
""" % osutils.pathjoin(self.test_dir, 'branch',), |
|
92 |
err) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
93 |
self.failUnlessExists('branch/file') |
94 |
||
|
1587.1.14
by Robert Collins
Make bound branch creation happen via 'checkout' |
95 |
def test_update_out_of_date_light_checkout(self): |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
96 |
self.make_branch_and_tree('branch') |
97 |
# make two checkouts
|
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
98 |
self.run_bzr('checkout --lightweight branch checkout') |
99 |
self.run_bzr('checkout --lightweight branch checkout2') |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
100 |
self.build_tree(['checkout/file']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
101 |
self.run_bzr('add checkout/file') |
102 |
self.run_bzr('commit -m add-file checkout') |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
103 |
# now checkout2 should be out of date
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
104 |
out,err = self.run_bzr('update checkout2') |
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
105 |
self.assertEqualDiff('''+N file |
106 |
All changes applied successfully.
|
|
107 |
Updated to revision 1 of branch %s |
|
108 |
''' % osutils.pathjoin(self.test_dir, 'branch',), |
|
109 |
err) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
110 |
self.assertEqual('', out) |
111 |
||
112 |
def test_update_conflicts_returns_2(self): |
|
113 |
self.make_branch_and_tree('branch') |
|
114 |
# make two checkouts
|
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
115 |
self.run_bzr('checkout --lightweight branch checkout') |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
116 |
self.build_tree(['checkout/file']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
117 |
self.run_bzr('add checkout/file') |
118 |
self.run_bzr('commit -m add-file checkout') |
|
119 |
self.run_bzr('checkout --lightweight branch checkout2') |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
120 |
# now alter file in checkout
|
121 |
a_file = file('checkout/file', 'wt') |
|
122 |
a_file.write('Foo') |
|
123 |
a_file.close() |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
124 |
self.run_bzr('commit -m checnge-file checkout') |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
125 |
# now checkout2 should be out of date
|
126 |
# make a local change to file
|
|
127 |
a_file = file('checkout2/file', 'wt') |
|
128 |
a_file.write('Bar') |
|
129 |
a_file.close() |
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
130 |
out,err = self.run_bzr('update checkout2', retcode=1) |
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
131 |
self.assertEqualDiff(''' M file |
132 |
Text conflict in file
|
|
133 |
1 conflicts encountered.
|
|
134 |
Updated to revision 2 of branch %s |
|
135 |
''' % osutils.pathjoin(self.test_dir, 'branch',), |
|
136 |
err) |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
137 |
self.assertEqual('', out) |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
138 |
|
139 |
def test_smoke_update_checkout_bound_branch_local_commits(self): |
|
140 |
# smoke test for doing an update of a checkout of a bound
|
|
141 |
# branch with local commits.
|
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
142 |
master = self.make_branch_and_tree('master') |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
143 |
# make a bound branch
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
144 |
self.run_bzr('checkout master child') |
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
145 |
# get an object form of child
|
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
146 |
child = workingtree.WorkingTree.open('child') |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
147 |
# check that out
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
148 |
self.run_bzr('checkout --lightweight child checkout') |
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
149 |
# get an object form of the checkout to manipulate
|
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
150 |
wt = workingtree.WorkingTree.open('checkout') |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
151 |
# change master
|
152 |
a_file = file('master/file', 'wt') |
|
153 |
a_file.write('Foo') |
|
154 |
a_file.close() |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
155 |
master.add(['file']) |
156 |
master_tip = master.commit('add file') |
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
157 |
# change child
|
158 |
a_file = file('child/file_b', 'wt') |
|
159 |
a_file.write('Foo') |
|
160 |
a_file.close() |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
161 |
child.add(['file_b']) |
162 |
child_tip = child.commit('add file_b', local=True) |
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
163 |
# check checkout
|
164 |
a_file = file('checkout/file_c', 'wt') |
|
165 |
a_file.write('Foo') |
|
166 |
a_file.close() |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
167 |
wt.add(['file_c']) |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
168 |
|
169 |
# now, update checkout ->
|
|
170 |
# get all three files and a pending merge.
|
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
171 |
out, err = self.run_bzr('update checkout') |
|
1711.2.108
by John Arbash Meinel
Assert that update informs the user about where their local commits went. |
172 |
self.assertEqual('', out) |
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
173 |
self.assertEqualDiff("""+N file |
174 |
All changes applied successfully.
|
|
175 |
+N file_b
|
|
176 |
All changes applied successfully.
|
|
177 |
Updated to revision 1 of branch %s |
|
178 |
Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
|
|
179 |
""" % osutils.pathjoin(self.test_dir, 'master',), |
|
180 |
err) |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
181 |
self.assertEqual([master_tip, child_tip], wt.get_parent_ids()) |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
182 |
self.failUnlessExists('checkout/file') |
183 |
self.failUnlessExists('checkout/file_b') |
|
184 |
self.failUnlessExists('checkout/file_c') |
|
185 |
self.assertTrue(wt.has_filename('file_c')) |
|
|
1711.2.109
by John Arbash Meinel
Add a test for handling a pending merge plus an update. |
186 |
|
187 |
def test_update_with_merges(self): |
|
188 |
# Test that 'bzr update' works correctly when you have
|
|
189 |
# an update in the master tree, and a lightweight checkout
|
|
190 |
# which has merged another branch
|
|
191 |
master = self.make_branch_and_tree('master') |
|
192 |
self.build_tree(['master/file']) |
|
193 |
master.add(['file']) |
|
194 |
master.commit('one', rev_id='m1') |
|
195 |
||
196 |
self.build_tree(['checkout1/']) |
|
197 |
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1') |
|
198 |
branch.BranchReferenceFormat().initialize(checkout_dir, master.branch) |
|
199 |
checkout1 = checkout_dir.create_workingtree('m1') |
|
200 |
||
201 |
# Create a second branch, with an extra commit
|
|
202 |
other = master.bzrdir.sprout('other').open_workingtree() |
|
203 |
self.build_tree(['other/file2']) |
|
204 |
other.add(['file2']) |
|
205 |
other.commit('other2', rev_id='o2') |
|
206 |
||
207 |
# Create a new commit in the master branch
|
|
208 |
self.build_tree(['master/file3']) |
|
209 |
master.add(['file3']) |
|
210 |
master.commit('f3', rev_id='m2') |
|
211 |
||
212 |
# Merge the other branch into checkout
|
|
213 |
os.chdir('checkout1') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
214 |
self.run_bzr('merge ../other') |
|
1711.2.109
by John Arbash Meinel
Add a test for handling a pending merge plus an update. |
215 |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
216 |
self.assertEqual(['o2'], checkout1.get_parent_ids()[1:]) |
|
1711.2.109
by John Arbash Meinel
Add a test for handling a pending merge plus an update. |
217 |
|
218 |
# At this point, 'commit' should fail, because we are out of date
|
|
219 |
self.run_bzr_error(["please run 'bzr update'"], |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
220 |
'commit -m merged') |
|
1711.2.109
by John Arbash Meinel
Add a test for handling a pending merge plus an update. |
221 |
|
222 |
# This should not report about local commits being pending
|
|
223 |
# merges, because they were real merges
|
|
224 |
out, err = self.run_bzr('update') |
|
225 |
self.assertEqual('', out) |
|
|
4879.1.3
by Vincent Ladeuil
Cleanup tests and tweak the text displayed. |
226 |
self.assertEqualDiff('''+N file3 |
227 |
All changes applied successfully.
|
|
228 |
Updated to revision 2 of branch %s |
|
229 |
''' % osutils.pathjoin(self.test_dir, 'master',), |
|
230 |
err) |
|
|
1711.2.109
by John Arbash Meinel
Add a test for handling a pending merge plus an update. |
231 |
# The pending merges should still be there
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
232 |
self.assertEqual(['o2'], checkout1.get_parent_ids()[1:]) |
|
2084.2.1
by Aaron Bentley
Support updating lightweight checkouts of readonly branches |
233 |
|
234 |
def test_readonly_lightweight_update(self): |
|
235 |
"""Update a light checkout of a readonly branch""" |
|
236 |
tree = self.make_branch_and_tree('branch') |
|
237 |
readonly_branch = branch.Branch.open(self.get_readonly_url('branch')) |
|
|
2255.7.55
by Robert Collins
Whitespace fix. |
238 |
checkout = readonly_branch.create_checkout('checkout', |
|
2084.2.1
by Aaron Bentley
Support updating lightweight checkouts of readonly branches |
239 |
lightweight=True) |
240 |
tree.commit('empty commit') |
|
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
241 |
self.run_bzr('update checkout') |