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) 2005 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
18 |
"""Tests of bound branches (binding, unbinding, commit, etc) command."""
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
19 |
|
20 |
import os |
|
21 |
from cStringIO import StringIO |
|
22 |
||
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
23 |
from bzrlib import ( |
24 |
bzrdir, |
|
25 |
)
|
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
26 |
from bzrlib.branch import Branch |
|
1694.2.6
by Martin Pool
[merge] bzr.dev |
27 |
from bzrlib.bzrdir import (BzrDir, BzrDirFormat, BzrDirMetaFormat1) |
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
28 |
from bzrlib.osutils import getcwd |
29 |
from bzrlib.tests import TestCaseWithTransport |
|
30 |
import bzrlib.urlutils as urlutils |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
31 |
from bzrlib.workingtree import WorkingTree |
32 |
||
33 |
||
34 |
class TestLegacyFormats(TestCaseWithTransport): |
|
35 |
||
36 |
def setUp(self): |
|
37 |
super(TestLegacyFormats, self).setUp() |
|
38 |
self.build_tree(['master/', 'child/']) |
|
39 |
self.run_bzr('init', 'master') |
|
|
1857.1.20
by Aaron Bentley
Strip out all the EnumOption stuff |
40 |
self.run_bzr('init', '--format=weave', 'child') |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
41 |
os.chdir('child') |
42 |
||
43 |
def test_bind_format_6_bzrdir(self): |
|
44 |
# bind on a format 6 bzrdir should error
|
|
45 |
out,err = self.run_bzr('bind', '../master', retcode=3) |
|
46 |
self.assertEqual('', out) |
|
|
1685.1.34
by John Arbash Meinel
Another test which assumed the output was a local path not a url |
47 |
# TODO: jam 20060427 Probably something like this really should
|
48 |
# print out the actual path, rather than the URL
|
|
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
49 |
cwd = urlutils.local_path_to_url(getcwd()) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
50 |
self.assertEqual('bzr: ERROR: To use this feature you must ' |
|
1685.1.34
by John Arbash Meinel
Another test which assumed the output was a local path not a url |
51 |
'upgrade your branch at %s/.\n' % cwd, err) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
52 |
|
53 |
def test_unbind_format_6_bzrdir(self): |
|
54 |
# bind on a format 6 bzrdir should error
|
|
55 |
out,err = self.run_bzr('unbind', retcode=3) |
|
56 |
self.assertEqual('', out) |
|
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
57 |
cwd = urlutils.local_path_to_url(getcwd()) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
58 |
self.assertEqual('bzr: ERROR: To use this feature you must ' |
|
1685.1.34
by John Arbash Meinel
Another test which assumed the output was a local path not a url |
59 |
'upgrade your branch at %s/.\n' % cwd, err) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
60 |
|
61 |
||
62 |
class TestBoundBranches(TestCaseWithTransport): |
|
63 |
||
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
64 |
def create_branches(self): |
|
1505.1.6
by John Arbash Meinel
Cleaned up tests and code, all bound branch tests succeed. |
65 |
bzr = self.run_bzr |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
66 |
self.build_tree(['base/', 'base/a', 'base/b']) |
67 |
||
|
1607.1.14
by Robert Collins
Reduce lock thrashing somewhat - drops bound branch tests lock count from 6554 to 4456 locks. |
68 |
branch = self.init_meta_branch('base') |
69 |
tree = branch.bzrdir.open_workingtree() |
|
70 |
tree.lock_write() |
|
71 |
tree.add(['a', 'b']) |
|
72 |
tree.commit('init') |
|
73 |
tree.unlock() |
|
74 |
||
75 |
self.run_bzr('checkout', 'base', 'child') |
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
76 |
|
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
77 |
self.check_revno(1, 'child') |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
78 |
d = BzrDir.open('child') |
79 |
self.assertNotEqual(None, d.open_branch().get_master_branch()) |
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
80 |
|
|
1607.1.14
by Robert Collins
Reduce lock thrashing somewhat - drops bound branch tests lock count from 6554 to 4456 locks. |
81 |
def check_revno(self, val, loc='.'): |
82 |
self.assertEqual( |
|
83 |
val, len(BzrDir.open(loc).open_branch().revision_history())) |
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
84 |
|
|
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
85 |
def test_simple_binding(self): |
86 |
self.build_tree(['base/', 'base/a', 'base/b']) |
|
87 |
||
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
88 |
self.init_meta_branch('base') |
89 |
self.run_bzr('add', 'base') |
|
90 |
self.run_bzr('commit', '-m', 'init', 'base') |
|
|
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
91 |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
92 |
self.run_bzr('branch', 'base', 'child') |
|
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
93 |
|
94 |
os.chdir('child') |
|
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
95 |
self.run_bzr('bind', '../base') |
96 |
||
97 |
d = BzrDir.open('') |
|
98 |
self.assertNotEqual(None, d.open_branch().get_master_branch()) |
|
99 |
||
100 |
self.run_bzr('unbind') |
|
101 |
self.assertEqual(None, d.open_branch().get_master_branch()) |
|
102 |
||
103 |
self.run_bzr('unbind', retcode=3) |
|
104 |
||
105 |
def init_meta_branch(self, path): |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
106 |
format = bzrdir.format_registry.make_bzrdir('knit') |
107 |
return BzrDir.create_branch_convenience(path, format=format) |
|
|
1505.1.5
by John Arbash Meinel
Added a test for the unbind command. |
108 |
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
109 |
def test_bound_commit(self): |
110 |
bzr = self.run_bzr |
|
111 |
self.create_branches() |
|
112 |
||
113 |
os.chdir('child') |
|
114 |
open('a', 'wb').write('new contents\n') |
|
115 |
bzr('commit', '-m', 'child') |
|
116 |
||
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
117 |
self.check_revno(2) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
118 |
|
119 |
# Make sure it committed on the parent
|
|
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
120 |
self.check_revno(2, '../base') |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
121 |
|
|
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
122 |
def test_bound_fail(self): |
|
1505.1.26
by John Arbash Meinel
Created a set of tests which bind to an sftp branch. Found some bugs, need to fix commit. |
123 |
# Make sure commit fails if out of date.
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
124 |
bzr = self.run_bzr |
125 |
self.create_branches() |
|
126 |
||
127 |
os.chdir('base') |
|
128 |
open('a', 'wb').write('new base contents\n') |
|
129 |
bzr('commit', '-m', 'base') |
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
130 |
self.check_revno(2) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
131 |
|
132 |
os.chdir('../child') |
|
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
133 |
self.check_revno(1) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
134 |
open('b', 'wb').write('new b child contents\n') |
|
1505.1.16
by John Arbash Meinel
[merge] robertc's integration, updated tests to check for retcode=3 |
135 |
bzr('commit', '-m', 'child', retcode=3) |
|
1587.1.11
by Robert Collins
Local commits appear to be working properly. |
136 |
self.check_revno(1) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
137 |
|
|
1505.1.13
by John Arbash Meinel
Adding the bzr update command, to update checkouts and bound branches. |
138 |
bzr('update') |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
139 |
self.check_revno(2) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
140 |
|
141 |
bzr('commit', '-m', 'child') |
|
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
142 |
self.check_revno(3) |
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
143 |
self.check_revno(3, '../base') |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
144 |
|
|
1505.1.2
by John Arbash Meinel
(broken) working on implementing bound branches. |
145 |
def test_double_binding(self): |
146 |
bzr = self.run_bzr |
|
147 |
self.create_branches() |
|
148 |
||
149 |
bzr('branch', 'child', 'child2') |
|
150 |
os.chdir('child2') |
|
151 |
||
|
1505.1.6
by John Arbash Meinel
Cleaned up tests and code, all bound branch tests succeed. |
152 |
# Double binding succeeds, but committing to child2 should fail
|
153 |
bzr('bind', '../child') |
|
|
1505.1.2
by John Arbash Meinel
(broken) working on implementing bound branches. |
154 |
|
|
1505.1.16
by John Arbash Meinel
[merge] robertc's integration, updated tests to check for retcode=3 |
155 |
bzr('commit', '-m', 'child2', '--unchanged', retcode=3) |
|
1505.1.2
by John Arbash Meinel
(broken) working on implementing bound branches. |
156 |
|
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
157 |
def test_unbinding(self): |
158 |
bzr = self.run_bzr |
|
159 |
self.create_branches() |
|
160 |
||
161 |
os.chdir('base') |
|
162 |
open('a', 'wb').write('new base contents\n') |
|
163 |
bzr('commit', '-m', 'base') |
|
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
164 |
self.check_revno(2) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
165 |
|
166 |
os.chdir('../child') |
|
167 |
open('b', 'wb').write('new b child contents\n') |
|
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
168 |
self.check_revno(1) |
|
1505.1.16
by John Arbash Meinel
[merge] robertc's integration, updated tests to check for retcode=3 |
169 |
bzr('commit', '-m', 'child', retcode=3) |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
170 |
self.check_revno(1) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
171 |
bzr('unbind') |
172 |
bzr('commit', '-m', 'child') |
|
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
173 |
self.check_revno(2) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
174 |
|
|
1505.1.16
by John Arbash Meinel
[merge] robertc's integration, updated tests to check for retcode=3 |
175 |
bzr('bind', retcode=3) |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
176 |
|
177 |
def test_commit_remote_bound(self): |
|
178 |
# It is not possible to commit to a branch
|
|
179 |
# which is bound to a branch which is bound
|
|
180 |
bzr = self.run_bzr |
|
|
1505.1.6
by John Arbash Meinel
Cleaned up tests and code, all bound branch tests succeed. |
181 |
self.create_branches() |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
182 |
bzr('branch', 'base', 'newbase') |
183 |
os.chdir('base') |
|
184 |
||
185 |
# There is no way to know that B has already
|
|
186 |
# been bound by someone else, otherwise it
|
|
187 |
# might be nice if this would fail
|
|
188 |
bzr('bind', '../newbase') |
|
189 |
||
190 |
os.chdir('../child') |
|
|
1505.1.16
by John Arbash Meinel
[merge] robertc's integration, updated tests to check for retcode=3 |
191 |
bzr('commit', '-m', 'failure', '--unchanged', retcode=3) |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
192 |
|
193 |
def test_pull_updates_both(self): |
|
194 |
bzr = self.run_bzr |
|
195 |
self.create_branches() |
|
196 |
bzr('branch', 'base', 'newchild') |
|
197 |
os.chdir('newchild') |
|
198 |
open('b', 'wb').write('newchild b contents\n') |
|
199 |
bzr('commit', '-m', 'newchild') |
|
200 |
self.check_revno(2) |
|
201 |
||
202 |
os.chdir('../child') |
|
203 |
# The pull should succeed, and update
|
|
204 |
# the bound parent branch
|
|
205 |
bzr('pull', '../newchild') |
|
206 |
self.check_revno(2) |
|
207 |
||
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
208 |
self.check_revno(2, '../base') |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
209 |
|
210 |
def test_bind_diverged(self): |
|
211 |
bzr = self.run_bzr |
|
212 |
self.create_branches() |
|
213 |
||
214 |
os.chdir('child') |
|
215 |
bzr('unbind') |
|
216 |
||
217 |
bzr('commit', '-m', 'child', '--unchanged') |
|
218 |
self.check_revno(2) |
|
219 |
||
220 |
os.chdir('../base') |
|
221 |
self.check_revno(1) |
|
222 |
bzr('commit', '-m', 'base', '--unchanged') |
|
223 |
self.check_revno(2) |
|
224 |
||
225 |
os.chdir('../child') |
|
226 |
# These branches have diverged
|
|
|
1505.1.16
by John Arbash Meinel
[merge] robertc's integration, updated tests to check for retcode=3 |
227 |
bzr('bind', '../base', retcode=3) |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
228 |
|
229 |
# TODO: In the future, this might require actual changes
|
|
230 |
# to have occurred, rather than just a new revision entry
|
|
231 |
bzr('merge', '../base') |
|
232 |
bzr('commit', '-m', 'merged') |
|
233 |
self.check_revno(3) |
|
234 |
||
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
235 |
# After binding, the revision history should be unaltered
|
236 |
base_branch = Branch.open('../base') |
|
237 |
child_branch = Branch.open('.') |
|
238 |
# take a copy before
|
|
239 |
base_history = base_branch.revision_history() |
|
240 |
child_history = child_branch.revision_history() |
|
241 |
||
|
1505.1.13
by John Arbash Meinel
Adding the bzr update command, to update checkouts and bound branches. |
242 |
# After a merge, trying to bind again should succeed
|
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
243 |
# keeping the new change as a local commit.
|
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
244 |
bzr('bind', '../base') |
|
1505.1.13
by John Arbash Meinel
Adding the bzr update command, to update checkouts and bound branches. |
245 |
self.check_revno(3) |
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
246 |
self.check_revno(2, '../base') |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
247 |
|
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
248 |
# and compare the revision history now
|
249 |
self.assertEqual(base_history, base_branch.revision_history()) |
|
250 |
self.assertEqual(child_history, child_branch.revision_history()) |
|
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
251 |
|
252 |
def test_bind_parent_ahead(self): |
|
253 |
bzr = self.run_bzr |
|
254 |
self.create_branches() |
|
255 |
||
256 |
os.chdir('child') |
|
257 |
bzr('unbind') |
|
258 |
||
259 |
os.chdir('../base') |
|
260 |
bzr('commit', '-m', 'base', '--unchanged') |
|
261 |
||
262 |
os.chdir('../child') |
|
263 |
self.check_revno(1) |
|
264 |
bzr('bind', '../base') |
|
265 |
||
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
266 |
# binding does not pull data:
|
267 |
self.check_revno(1) |
|
|
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
268 |
bzr('unbind') |
269 |
||
270 |
# Check and make sure it also works if parent is ahead multiple
|
|
271 |
os.chdir('../base') |
|
272 |
bzr('commit', '-m', 'base 3', '--unchanged') |
|
273 |
bzr('commit', '-m', 'base 4', '--unchanged') |
|
274 |
bzr('commit', '-m', 'base 5', '--unchanged') |
|
275 |
self.check_revno(5) |
|
276 |
||
277 |
os.chdir('../child') |
|
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
278 |
self.check_revno(1) |
|
1587.1.14
by Robert Collins
Make bound branch creation happen via 'checkout' |
279 |
bzr('bind', '../base') |
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
280 |
self.check_revno(1) |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
281 |
|
282 |
def test_bind_child_ahead(self): |
|
|
1607.1.14
by Robert Collins
Reduce lock thrashing somewhat - drops bound branch tests lock count from 6554 to 4456 locks. |
283 |
# test binding when the master branches history is a prefix of the
|
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
284 |
# childs - it should bind ok but the revision histories should not
|
285 |
# be altered
|
|
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
286 |
bzr = self.run_bzr |
287 |
self.create_branches() |
|
288 |
||
289 |
os.chdir('child') |
|
290 |
bzr('unbind') |
|
291 |
bzr('commit', '-m', 'child', '--unchanged') |
|
292 |
self.check_revno(2) |
|
293 |
self.check_revno(1, '../base') |
|
294 |
||
295 |
bzr('bind', '../base') |
|
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
296 |
self.check_revno(1, '../base') |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
297 |
|
|
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
298 |
# Check and make sure it also works if child is ahead multiple
|
299 |
bzr('unbind') |
|
300 |
bzr('commit', '-m', 'child 3', '--unchanged') |
|
301 |
bzr('commit', '-m', 'child 4', '--unchanged') |
|
302 |
bzr('commit', '-m', 'child 5', '--unchanged') |
|
303 |
self.check_revno(5) |
|
304 |
||
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
305 |
self.check_revno(1, '../base') |
|
1587.1.14
by Robert Collins
Make bound branch creation happen via 'checkout' |
306 |
bzr('bind', '../base') |
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
307 |
self.check_revno(1, '../base') |
|
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
308 |
|
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
309 |
def test_commit_after_merge(self): |
310 |
bzr = self.run_bzr |
|
311 |
self.create_branches() |
|
312 |
||
313 |
# We want merge to be able to be a local only
|
|
314 |
# operation, because it can be without violating
|
|
315 |
# the binding invariants.
|
|
316 |
# But we can't fail afterwards
|
|
317 |
||
318 |
bzr('branch', 'child', 'other') |
|
319 |
||
320 |
os.chdir('other') |
|
321 |
open('c', 'wb').write('file c\n') |
|
322 |
bzr('add', 'c') |
|
323 |
bzr('commit', '-m', 'adding c') |
|
324 |
new_rev_id = bzr('revision-history')[0].strip().split('\n')[-1] |
|
325 |
||
326 |
os.chdir('../child') |
|
327 |
bzr('merge', '../other') |
|
328 |
||
329 |
self.failUnlessExists('c') |
|
|
1908.6.11
by Robert Collins
Remove usage of tree.pending_merges(). |
330 |
tree = WorkingTree.open('.') # opens child |
331 |
self.assertEqual([new_rev_id], tree.get_parent_ids()[1:]) |
|
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
332 |
|
333 |
# Make sure the local branch has the installed revision
|
|
334 |
bzr('cat-revision', new_rev_id) |
|
335 |
||
336 |
# And make sure that the base tree does not
|
|
337 |
os.chdir('../base') |
|
338 |
bzr('cat-revision', new_rev_id, retcode=3) |
|
339 |
||
340 |
# Commit should succeed, and cause merged revisions to
|
|
341 |
# be pulled into base
|
|
342 |
os.chdir('../child') |
|
343 |
bzr('commit', '-m', 'merge other') |
|
344 |
||
345 |
self.check_revno(2) |
|
346 |
||
347 |
os.chdir('../base') |
|
348 |
self.check_revno(2) |
|
349 |
||
350 |
bzr('cat-revision', new_rev_id) |
|
351 |
||
|
1505.1.25
by John Arbash Meinel
Updated pull. Now all paths which call set_revision_history maintain the branch invariant. All tests pass. |
352 |
def test_pull_overwrite_fails(self): |
353 |
bzr = self.run_bzr |
|
354 |
self.create_branches() |
|
355 |
||
356 |
bzr('branch', 'child', 'other') |
|
357 |
||
358 |
os.chdir('other') |
|
359 |
open('a', 'wb').write('new contents\n') |
|
360 |
bzr('commit', '-m', 'changed a') |
|
361 |
self.check_revno(2) |
|
362 |
open('a', 'ab').write('and then some\n') |
|
363 |
bzr('commit', '-m', 'another a') |
|
364 |
self.check_revno(3) |
|
365 |
open('a', 'ab').write('and some more\n') |
|
366 |
bzr('commit', '-m', 'yet another a') |
|
367 |
self.check_revno(4) |
|
368 |
||
369 |
os.chdir('../child') |
|
370 |
open('a', 'wb').write('also changed a\n') |
|
371 |
bzr('commit', '-m', 'child modified a') |
|
372 |
||
373 |
self.check_revno(2) |
|
374 |
self.check_revno(2, '../base') |
|
375 |
||
376 |
# It might be possible that we want pull --overwrite to
|
|
377 |
# actually succeed.
|
|
378 |
# If we want it, just change this test to make sure that
|
|
379 |
# both base and child are updated properly
|
|
380 |
bzr('pull', '--overwrite', '../other', retcode=3) |
|
381 |
||
382 |
# It should fail without changing the local revision
|
|
383 |
self.check_revno(2) |
|
384 |
self.check_revno(2, '../base') |
|
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
385 |
|
|
1505.1.28
by John Arbash Meinel
todo |
386 |
# TODO: jam 20051230 Test that commit & pull fail when the branch we
|
387 |
# are bound to is not available
|
|
388 |
||
389 |