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