4988.10.3
by John Arbash Meinel
Merge bzr.dev 5007, resolve conflict, update NEWS |
1 |
# Copyright (C) 2005-2010 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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
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, |
|
4988.7.2
by Vincent Ladeuil
Fix imports. |
25 |
errors, |
26 |
tests, |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
27 |
)
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
28 |
from bzrlib.branch import Branch |
1694.2.6
by Martin Pool
[merge] bzr.dev |
29 |
from bzrlib.bzrdir import (BzrDir, BzrDirFormat, BzrDirMetaFormat1) |
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
30 |
from bzrlib.osutils import getcwd |
4988.7.2
by Vincent Ladeuil
Fix imports. |
31 |
from bzrlib.tests import script |
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
32 |
import bzrlib.urlutils as urlutils |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
33 |
from bzrlib.workingtree import WorkingTree |
34 |
||
35 |
||
4988.7.2
by Vincent Ladeuil
Fix imports. |
36 |
class TestLegacyFormats(tests.TestCaseWithTransport): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
37 |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
38 |
def setUp(self): |
39 |
super(TestLegacyFormats, self).setUp() |
|
40 |
self.build_tree(['master/', 'child/']) |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
41 |
self.make_branch_and_tree('master') |
42 |
self.make_branch_and_tree('child', |
|
43 |
format=bzrdir.format_registry.make_bzrdir('weave')) |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
44 |
os.chdir('child') |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
45 |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
46 |
def test_bind_format_6_bzrdir(self): |
47 |
# bind on a format 6 bzrdir should error
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
48 |
out,err = self.run_bzr('bind ../master', retcode=3) |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
49 |
self.assertEqual('', out) |
1685.1.34
by John Arbash Meinel
Another test which assumed the output was a local path not a url |
50 |
# TODO: jam 20060427 Probably something like this really should
|
51 |
# print out the actual path, rather than the URL
|
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
52 |
cwd = urlutils.local_path_to_url(getcwd()) |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
53 |
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 |
54 |
'upgrade your branch at %s/.\n' % cwd, err) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
55 |
|
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
56 |
def test_unbind_format_6_bzrdir(self): |
57 |
# bind on a format 6 bzrdir should error
|
|
58 |
out,err = self.run_bzr('unbind', retcode=3) |
|
59 |
self.assertEqual('', out) |
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
60 |
cwd = urlutils.local_path_to_url(getcwd()) |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
61 |
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 |
62 |
'upgrade your branch at %s/.\n' % cwd, err) |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
63 |
|
64 |
||
4988.7.2
by Vincent Ladeuil
Fix imports. |
65 |
class TestBoundBranches(tests.TestCaseWithTransport): |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
66 |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
67 |
def create_branches(self): |
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
68 |
base_tree = self.make_branch_and_tree('base') |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
69 |
base_tree.lock_write() |
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
70 |
self.build_tree(['base/a', 'base/b']) |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
71 |
base_tree.add(['a', 'b']) |
72 |
base_tree.commit('init') |
|
73 |
base_tree.unlock() |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
74 |
branch = base_tree.branch |
1607.1.14
by Robert Collins
Reduce lock thrashing somewhat - drops bound branch tests lock count from 6554 to 4456 locks. |
75 |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
76 |
child_tree = branch.create_checkout('child') |
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
77 |
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
78 |
self.check_revno(1, 'child') |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
79 |
d = BzrDir.open('child') |
80 |
self.assertNotEqual(None, d.open_branch().get_master_branch()) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
81 |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
82 |
return base_tree, child_tree |
83 |
||
1607.1.14
by Robert Collins
Reduce lock thrashing somewhat - drops bound branch tests lock count from 6554 to 4456 locks. |
84 |
def check_revno(self, val, loc='.'): |
85 |
self.assertEqual( |
|
86 |
val, len(BzrDir.open(loc).open_branch().revision_history())) |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
87 |
|
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
88 |
def test_simple_binding(self): |
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
89 |
tree = self.make_branch_and_tree('base') |
90 |
self.build_tree(['base/a', 'base/b']) |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
91 |
tree.add('a', 'b') |
92 |
tree.commit(message='init') |
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
93 |
branch = tree.branch |
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
94 |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
95 |
tree.bzrdir.sprout('child') |
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
96 |
|
97 |
os.chdir('child') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
98 |
self.run_bzr('bind ../base') |
1587.1.6
by Robert Collins
Update bound branch implementation to 0.8. |
99 |
|
100 |
d = BzrDir.open('') |
|
101 |
self.assertNotEqual(None, d.open_branch().get_master_branch()) |
|
102 |
||
103 |
self.run_bzr('unbind') |
|
104 |
self.assertEqual(None, d.open_branch().get_master_branch()) |
|
105 |
||
106 |
self.run_bzr('unbind', retcode=3) |
|
107 |
||
2230.3.31
by Aaron Bentley
Implement re-binding previously-bound branches |
108 |
def test_bind_branch6(self): |
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
109 |
branch1 = self.make_branch('branch1', format='dirstate-tags') |
2230.3.31
by Aaron Bentley
Implement re-binding previously-bound branches |
110 |
os.chdir('branch1') |
111 |
error = self.run_bzr('bind', retcode=3)[1] |
|
2230.3.48
by Aaron Bentley
Update blackbox test to handle new error message |
112 |
self.assertContainsRe(error, 'no previous location known') |
2230.3.31
by Aaron Bentley
Implement re-binding previously-bound branches |
113 |
|
114 |
def setup_rebind(self, format): |
|
115 |
branch1 = self.make_branch('branch1') |
|
116 |
branch2 = self.make_branch('branch2', format=format) |
|
117 |
branch2.bind(branch1) |
|
118 |
branch2.unbind() |
|
119 |
||
120 |
def test_rebind_branch6(self): |
|
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
121 |
self.setup_rebind('dirstate-tags') |
2230.3.31
by Aaron Bentley
Implement re-binding previously-bound branches |
122 |
os.chdir('branch2') |
123 |
self.run_bzr('bind') |
|
124 |
b = Branch.open('.') |
|
125 |
self.assertContainsRe(b.get_bound_location(), '\/branch1\/$') |
|
126 |
||
127 |
def test_rebind_branch5(self): |
|
128 |
self.setup_rebind('knit') |
|
129 |
os.chdir('branch2') |
|
130 |
error = self.run_bzr('bind', retcode=3)[1] |
|
131 |
self.assertContainsRe(error, 'old locations') |
|
132 |
||
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
133 |
def test_bound_commit(self): |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
134 |
child_tree = self.create_branches()[1] |
135 |
||
136 |
self.build_tree_contents([('child/a', 'new contents')]) |
|
137 |
child_tree.commit(message='child') |
|
138 |
||
139 |
self.check_revno(2, 'child') |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
140 |
|
141 |
# Make sure it committed on the parent
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
142 |
self.check_revno(2, 'base') |
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
143 |
|
1505.1.4
by John Arbash Meinel
Wrote a simple test which actually makes a branch become bound, and made it work |
144 |
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. |
145 |
# Make sure commit fails if out of date.
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
146 |
base_tree, child_tree = self.create_branches() |
147 |
||
148 |
self.build_tree_contents([ |
|
149 |
('base/a', 'new base contents\n' ), |
|
150 |
('child/b', 'new b child contents\n')]) |
|
151 |
base_tree.commit(message='base') |
|
152 |
self.check_revno(2, 'base') |
|
153 |
||
154 |
self.check_revno(1, 'child') |
|
155 |
self.assertRaises(errors.BoundBranchOutOfDate, child_tree.commit, |
|
156 |
message='child') |
|
157 |
self.check_revno(1, 'child') |
|
158 |
||
159 |
child_tree.update() |
|
160 |
self.check_revno(2, 'child') |
|
161 |
||
162 |
child_tree.commit(message='child') |
|
163 |
self.check_revno(3, 'child') |
|
164 |
self.check_revno(3, 'base') |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
165 |
|
1505.1.2
by John Arbash Meinel
(broken) working on implementing bound branches. |
166 |
def test_double_binding(self): |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
167 |
child_tree = self.create_branches()[1] |
168 |
||
169 |
child2_tree = child_tree.bzrdir.sprout('child2').open_workingtree() |
|
170 |
||
1505.1.2
by John Arbash Meinel
(broken) working on implementing bound branches. |
171 |
os.chdir('child2') |
1505.1.6
by John Arbash Meinel
Cleaned up tests and code, all bound branch tests succeed. |
172 |
# Double binding succeeds, but committing to child2 should fail
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
173 |
self.run_bzr('bind ../child') |
1505.1.2
by John Arbash Meinel
(broken) working on implementing bound branches. |
174 |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
175 |
self.assertRaises(errors.CommitToDoubleBoundBranch, |
176 |
child2_tree.commit, message='child2', allow_pointless=True) |
|
1505.1.2
by John Arbash Meinel
(broken) working on implementing bound branches. |
177 |
|
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
178 |
def test_unbinding(self): |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
179 |
base_tree, child_tree = self.create_branches() |
180 |
||
181 |
self.build_tree_contents([ |
|
182 |
('base/a', 'new base contents\n' ), |
|
183 |
('child/b', 'new b child contents\n')]) |
|
184 |
||
185 |
base_tree.commit(message='base') |
|
186 |
self.check_revno(2, 'base') |
|
187 |
||
188 |
self.check_revno(1, 'child') |
|
189 |
os.chdir('child') |
|
190 |
self.run_bzr("commit -m child", retcode=3) |
|
191 |
self.check_revno(1) |
|
192 |
self.run_bzr('unbind') |
|
193 |
child_tree.commit(message='child') |
|
194 |
self.check_revno(2) |
|
195 |
||
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
196 |
def test_commit_remote_bound(self): |
197 |
# It is not possible to commit to a branch
|
|
198 |
# which is bound to a branch which is bound
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
199 |
base_tree, child_tree = self.create_branches() |
200 |
base_tree.bzrdir.sprout('newbase') |
|
201 |
||
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
202 |
os.chdir('base') |
203 |
# There is no way to know that B has already
|
|
204 |
# been bound by someone else, otherwise it
|
|
205 |
# might be nice if this would fail
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
206 |
self.run_bzr('bind ../newbase') |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
207 |
|
208 |
os.chdir('../child') |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
209 |
self.run_bzr('commit -m failure --unchanged', retcode=3) |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
210 |
|
211 |
def test_pull_updates_both(self): |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
212 |
base_tree = self.create_branches()[0] |
213 |
newchild_tree = base_tree.bzrdir.sprout('newchild').open_workingtree() |
|
214 |
self.build_tree_contents([('newchild/b', 'newchild b contents\n')]) |
|
215 |
newchild_tree.commit(message='newchild') |
|
216 |
self.check_revno(2, 'newchild') |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
217 |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
218 |
os.chdir('child') |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
219 |
# The pull should succeed, and update
|
220 |
# the bound parent branch
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
221 |
self.run_bzr('pull ../newchild') |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
222 |
self.check_revno(2) |
223 |
||
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
224 |
self.check_revno(2, '../base') |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
225 |
|
4056.6.2
by Gary van der Merwe
Implement test for pull --local |
226 |
def test_pull_local_updates_local(self): |
227 |
base_tree = self.create_branches()[0] |
|
228 |
newchild_tree = base_tree.bzrdir.sprout('newchild').open_workingtree() |
|
229 |
self.build_tree_contents([('newchild/b', 'newchild b contents\n')]) |
|
230 |
newchild_tree.commit(message='newchild') |
|
231 |
self.check_revno(2, 'newchild') |
|
232 |
||
233 |
os.chdir('child') |
|
234 |
# The pull should succeed, and update
|
|
235 |
# the bound parent branch
|
|
236 |
self.run_bzr('pull ../newchild --local') |
|
237 |
self.check_revno(2) |
|
238 |
||
239 |
self.check_revno(1, '../base') |
|
240 |
||
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
241 |
def test_bind_diverged(self): |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
242 |
base_tree, child_tree = self.create_branches() |
243 |
base_branch = base_tree.branch |
|
244 |
child_branch = child_tree.branch |
|
245 |
||
246 |
os.chdir('child') |
|
247 |
self.run_bzr('unbind') |
|
248 |
||
249 |
child_tree.commit(message='child', allow_pointless=True) |
|
250 |
self.check_revno(2) |
|
251 |
||
252 |
os.chdir('..') |
|
253 |
self.check_revno(1, 'base') |
|
254 |
base_tree.commit(message='base', allow_pointless=True) |
|
255 |
self.check_revno(2, 'base') |
|
256 |
||
257 |
os.chdir('child') |
|
3099.1.1
by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry |
258 |
# These branches have diverged, but bind should succeed anyway
|
259 |
self.run_bzr('bind ../base') |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
260 |
|
3099.1.1
by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry |
261 |
# This should turn the local commit into a merge
|
262 |
child_tree.update() |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
263 |
child_tree.commit(message='merged') |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
264 |
self.check_revno(3) |
265 |
||
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
266 |
# After binding, the revision history should be unaltered
|
267 |
# take a copy before
|
|
268 |
base_history = base_branch.revision_history() |
|
269 |
child_history = child_branch.revision_history() |
|
270 |
||
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
271 |
def test_bind_parent_ahead(self): |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
272 |
base_tree = self.create_branches()[0] |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
273 |
|
274 |
os.chdir('child') |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
275 |
self.run_bzr('unbind') |
276 |
||
277 |
base_tree.commit(message='base', allow_pointless=True) |
|
278 |
||
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
279 |
self.check_revno(1) |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
280 |
self.run_bzr('bind ../base') |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
281 |
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
282 |
# binding does not pull data:
|
283 |
self.check_revno(1) |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
284 |
self.run_bzr('unbind') |
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
285 |
|
286 |
# Check and make sure it also works if parent is ahead multiple
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
287 |
base_tree.commit(message='base 3', allow_pointless=True) |
288 |
base_tree.commit(message='base 4', allow_pointless=True) |
|
289 |
base_tree.commit(message='base 5', allow_pointless=True) |
|
290 |
self.check_revno(5, '../base') |
|
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
291 |
|
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
292 |
self.check_revno(1) |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
293 |
self.run_bzr('bind ../base') |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
294 |
self.check_revno(1) |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
295 |
|
296 |
def test_bind_child_ahead(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
297 |
# 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 |
298 |
# childs - it should bind ok but the revision histories should not
|
299 |
# be altered
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
300 |
child_tree = self.create_branches()[1] |
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
301 |
|
302 |
os.chdir('child') |
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
303 |
self.run_bzr('unbind') |
304 |
child_tree.commit(message='child', allow_pointless=True) |
|
1505.1.3
by John Arbash Meinel
(broken) Adding more tests, and some functionality |
305 |
self.check_revno(2) |
306 |
self.check_revno(1, '../base') |
|
307 |
||
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
308 |
self.run_bzr('bind ../base') |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
309 |
self.check_revno(1, '../base') |
1505.1.1
by John Arbash Meinel
Adding test for bound behavior |
310 |
|
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
311 |
# Check and make sure it also works if child is ahead multiple
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
312 |
self.run_bzr('unbind') |
313 |
child_tree.commit(message='child 3', allow_pointless=True) |
|
314 |
child_tree.commit(message='child 4', allow_pointless=True) |
|
315 |
child_tree.commit(message='child 5', allow_pointless=True) |
|
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
316 |
self.check_revno(5) |
317 |
||
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
318 |
self.check_revno(1, '../base') |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
319 |
self.run_bzr('bind ../base') |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
320 |
self.check_revno(1, '../base') |
1505.1.11
by John Arbash Meinel
Adding a little bit more to the test suite. |
321 |
|
3099.1.1
by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry |
322 |
def test_bind_fail_if_missing(self): |
323 |
"""We should not be able to bind to a missing branch."""
|
|
324 |
tree = self.make_branch_and_tree('tree_1') |
|
325 |
tree.commit('dummy commit') |
|
326 |
self.run_bzr_error(['Not a branch.*no-such-branch/'], ['bind', '../no-such-branch'], |
|
327 |
working_dir='tree_1') |
|
328 |
self.assertIs(None, tree.branch.get_bound_location()) |
|
329 |
||
3565.6.11
by Marius Kruger
Bind now updates explicit nicks |
330 |
def test_bind_nick(self): |
331 |
"""Bind should not update implicit nick."""
|
|
332 |
base = self.make_branch_and_tree('base') |
|
333 |
child = self.make_branch_and_tree('child') |
|
334 |
os.chdir('child') |
|
335 |
self.assertEqual(child.branch.nick, 'child') |
|
336 |
self.assertEqual(child.branch.get_config().has_explicit_nickname(), |
|
337 |
False) |
|
338 |
self.run_bzr('bind ../base') |
|
339 |
self.assertEqual(child.branch.nick, base.branch.nick) |
|
340 |
self.assertEqual(child.branch.get_config().has_explicit_nickname(), |
|
341 |
False) |
|
342 |
||
343 |
def test_bind_explicit_nick(self): |
|
344 |
"""Bind should update explicit nick."""
|
|
345 |
base = self.make_branch_and_tree('base') |
|
346 |
child = self.make_branch_and_tree('child') |
|
347 |
os.chdir('child') |
|
348 |
child.branch.nick = "explicit_nick" |
|
349 |
self.assertEqual(child.branch.nick, "explicit_nick") |
|
350 |
self.assertEqual(child.branch.get_config()._get_explicit_nickname(), |
|
351 |
"explicit_nick") |
|
352 |
self.run_bzr('bind ../base') |
|
353 |
self.assertEqual(child.branch.nick, base.branch.nick) |
|
354 |
self.assertEqual(child.branch.get_config()._get_explicit_nickname(), |
|
355 |
base.branch.nick) |
|
356 |
||
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
357 |
def test_commit_after_merge(self): |
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
358 |
base_tree, child_tree = self.create_branches() |
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
359 |
|
360 |
# We want merge to be able to be a local only
|
|
361 |
# operation, because it can be without violating
|
|
362 |
# the binding invariants.
|
|
363 |
# But we can't fail afterwards
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
364 |
other_tree = child_tree.bzrdir.sprout('other').open_workingtree() |
365 |
other_branch = other_tree.branch |
|
366 |
||
367 |
self.build_tree_contents([('other/c', 'file c\n')]) |
|
368 |
other_tree.add('c') |
|
369 |
other_tree.commit(message='adding c') |
|
370 |
new_rev_id = other_branch.revision_history()[-1] |
|
371 |
||
372 |
child_tree.merge_from_branch(other_branch) |
|
373 |
||
374 |
self.failUnlessExists('child/c') |
|
375 |
self.assertEqual([new_rev_id], child_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 |
376 |
|
377 |
# Make sure the local branch has the installed revision
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
378 |
self.assertTrue(child_tree.branch.repository.has_revision(new_rev_id)) |
379 |
||
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
380 |
# And make sure that the base tree does not
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
381 |
self.assertFalse(base_tree.branch.repository.has_revision(new_rev_id)) |
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
382 |
|
383 |
# Commit should succeed, and cause merged revisions to
|
|
384 |
# be pulled into base
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
385 |
os.chdir('child') |
386 |
self.run_bzr(['commit', '-m', 'merge other']) |
|
387 |
||
388 |
self.check_revno(2) |
|
389 |
||
390 |
self.check_revno(2, '../base') |
|
391 |
||
392 |
self.assertTrue(base_tree.branch.repository.has_revision(new_rev_id)) |
|
1505.1.24
by John Arbash Meinel
Updated commit to handle bound branches. Included test to handle commit after merge |
393 |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
394 |
def test_pull_overwrite(self): |
395 |
# XXX: This test should be moved to branch-implemenations/test_pull
|
|
2664.8.1
by Daniel Watkins
tests.blackbox.test_bound_branches now uses internals where appropriate. |
396 |
child_tree = self.create_branches()[1] |
397 |
||
398 |
other_tree = child_tree.bzrdir.sprout('other').open_workingtree() |
|
399 |
||
400 |
self.build_tree_contents([('other/a', 'new contents\n')]) |
|
401 |
other_tree.commit(message='changed a') |
|
402 |
self.check_revno(2, 'other') |
|
403 |
self.build_tree_contents([ |
|
404 |
('other/a', 'new contents\nand then some\n')]) |
|
405 |
other_tree.commit(message='another a') |
|
406 |
self.check_revno(3, 'other') |
|
407 |
self.build_tree_contents([ |
|
408 |
('other/a', 'new contents\nand then some\nand some more\n')]) |
|
409 |
other_tree.commit('yet another a') |
|
410 |
self.check_revno(4, 'other') |
|
411 |
||
412 |
self.build_tree_contents([('child/a', 'also changed a\n')]) |
|
413 |
child_tree.commit(message='child modified a') |
|
414 |
||
415 |
self.check_revno(2, 'child') |
|
416 |
self.check_revno(2, 'base') |
|
417 |
||
418 |
os.chdir('child') |
|
419 |
self.run_bzr('pull --overwrite ../other') |
|
2246.1.3
by Robert Collins
New branch hooks: post_push, post_pull, post_commit, post_uncommit. These |
420 |
|
421 |
# both the local and master should have been updated.
|
|
422 |
self.check_revno(4) |
|
423 |
self.check_revno(4, '../base') |
|
4988.7.1
by Neil Martinsen-Burrell
better error message for bzr bind on and already bound branch |
424 |
|
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
425 |
def test_bind_directory(self): |
426 |
"""Test --directory option"""
|
|
427 |
tree = self.make_branch_and_tree('base') |
|
428 |
self.build_tree(['base/a', 'base/b']) |
|
429 |
tree.add('a', 'b') |
|
430 |
tree.commit(message='init') |
|
431 |
branch = tree.branch |
|
432 |
tree.bzrdir.sprout('child') |
|
433 |
self.run_bzr('bind --directory=child base') |
|
434 |
d = BzrDir.open('child') |
|
435 |
self.assertNotEqual(None, d.open_branch().get_master_branch()) |
|
436 |
self.run_bzr('unbind -d child') |
|
437 |
self.assertEqual(None, d.open_branch().get_master_branch()) |
|
438 |
self.run_bzr('unbind --directory child', retcode=3) |
|
439 |
||
4988.7.1
by Neil Martinsen-Burrell
better error message for bzr bind on and already bound branch |
440 |
|
441 |
class TestBind(script.TestCaseWithTransportAndScript): |
|
442 |
||
443 |
def test_bind_when_bound(self): |
|
444 |
self.run_script(""" |
|
445 |
$ bzr init trunk
|
|
446 |
$ bzr init copy
|
|
447 |
$ cd copy
|
|
448 |
$ bzr bind ../trunk
|
|
449 |
$ bzr bind
|
|
450 |
2>bzr: ERROR: Branch is already bound
|
|
451 |
""") |
|
452 |
||
453 |
def test_bind_before_bound(self): |
|
454 |
self.run_script(""" |
|
455 |
$ bzr init trunk
|
|
456 |
$ cd trunk
|
|
457 |
$ bzr bind
|
|
458 |
2>bzr: ERROR: No location supplied and no previous location known
|
|
459 |
""") |