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