5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2005-2011 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
905
by Martin Pool
- merge aaron's append_multiple.patch |
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 |
#
|
905
by Martin Pool
- merge aaron's append_multiple.patch |
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 |
#
|
905
by Martin Pool
- merge aaron's append_multiple.patch |
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
|
905
by Martin Pool
- merge aaron's append_multiple.patch |
16 |
|
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
17 |
"""Tests for branch implementations - tests a branch format."""
|
18 |
||
1878.1.3
by John Arbash Meinel
some test cleanups |
19 |
from bzrlib import ( |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
20 |
branch as _mod_branch, |
1878.1.3
by John Arbash Meinel
some test cleanups |
21 |
bzrdir, |
5345.1.19
by Vincent Ladeuil
Cleanup bt.per_branch.test_branch. |
22 |
config, |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
23 |
delta as _mod_delta, |
1878.1.3
by John Arbash Meinel
some test cleanups |
24 |
errors, |
25 |
gpg, |
|
4273.1.8
by Aaron Bentley
Handle references in push, pull, merge. |
26 |
merge, |
1878.1.3
by John Arbash Meinel
some test cleanups |
27 |
urlutils, |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
28 |
transport, |
2018.5.129
by Robert Collins
Branch implementations test test_set_get_parent should not depend on local urls : the test can be valid for any url namespace. Change it to be valid in that manner. (Robert Collins, Andrew Bennetts) |
29 |
remote, |
1878.1.3
by John Arbash Meinel
some test cleanups |
30 |
repository, |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
31 |
revision, |
5718.7.6
by Jelmer Vernooij
Fix import. |
32 |
symbol_versioning, |
3099.1.1
by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry |
33 |
tests, |
1878.1.3
by John Arbash Meinel
some test cleanups |
34 |
)
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
35 |
from bzrlib.tests import ( |
36 |
per_branch, |
|
37 |
)
|
|
4523.1.5
by Vincent Ladeuil
Fixed as asked in review. |
38 |
from bzrlib.tests.http_server import HttpServer |
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
39 |
from bzrlib.transport import memory |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
40 |
|
41 |
||
42 |
class TestTestCaseWithBranch(per_branch.TestCaseWithBranch): |
|
3834.5.2
by John Arbash Meinel
Track down the various BranchFormats that weren't setting the branch format as part of the _matchingbzrdir format. |
43 |
|
44 |
def test_branch_format_matches_bzrdir_branch_format(self): |
|
45 |
bzrdir_branch_format = self.bzrdir_format.get_branch_format() |
|
46 |
self.assertIs(self.branch_format.__class__, |
|
47 |
bzrdir_branch_format.__class__) |
|
48 |
||
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
49 |
def test_make_branch_gets_expected_format(self): |
50 |
branch = self.make_branch('.') |
|
51 |
self.assertIs(self.branch_format.__class__, |
|
52 |
branch._format.__class__) |
|
53 |
||
3834.5.2
by John Arbash Meinel
Track down the various BranchFormats that weren't setting the branch format as part of the _matchingbzrdir format. |
54 |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
55 |
class TestBranch(per_branch.TestCaseWithBranch): |
1185.10.1
by Aaron Bentley
Added --basis option to bzr branch |
56 |
|
2418.5.1
by John Arbash Meinel
Make a Branch helper which can create a very basic MemoryTree with history. |
57 |
def test_create_tree_with_merge(self): |
58 |
tree = self.create_tree_with_merge() |
|
3287.6.9
by Robert Collins
One last use of deprecated methods. |
59 |
tree.lock_read() |
60 |
self.addCleanup(tree.unlock) |
|
61 |
graph = tree.branch.repository.get_graph() |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
62 |
ancestry_graph = graph.get_parent_map( |
63 |
tree.branch.repository.all_revision_ids()) |
|
3287.6.9
by Robert Collins
One last use of deprecated methods. |
64 |
self.assertEqual({'rev-1':('null:',), |
2625.8.1
by Robert Collins
LIBRARY API BREAKS: |
65 |
'rev-2':('rev-1', ), |
66 |
'rev-1.1.1':('rev-1', ), |
|
67 |
'rev-3':('rev-2', 'rev-1.1.1', ), |
|
2418.5.1
by John Arbash Meinel
Make a Branch helper which can create a very basic MemoryTree with history. |
68 |
}, ancestry_graph) |
69 |
||
2249.5.6
by John Arbash Meinel
Make sure Branch.revision_history() also works in utf-8 revision ids. |
70 |
def test_revision_ids_are_utf8(self): |
2249.5.17
by John Arbash Meinel
[merge] bzr.dev 2293 and resolve conflicts, but still broken |
71 |
wt = self.make_branch_and_tree('tree') |
72 |
wt.commit('f', rev_id='rev1') |
|
73 |
wt.commit('f', rev_id='rev2') |
|
74 |
wt.commit('f', rev_id='rev3') |
|
75 |
||
2249.5.6
by John Arbash Meinel
Make sure Branch.revision_history() also works in utf-8 revision ids. |
76 |
br = self.get_branch() |
2249.5.17
by John Arbash Meinel
[merge] bzr.dev 2293 and resolve conflicts, but still broken |
77 |
br.fetch(wt.branch) |
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
78 |
br.generate_revision_history('rev3') |
2249.5.6
by John Arbash Meinel
Make sure Branch.revision_history() also works in utf-8 revision ids. |
79 |
rh = br.revision_history() |
80 |
self.assertEqual(['rev1', 'rev2', 'rev3'], rh) |
|
81 |
for revision_id in rh: |
|
82 |
self.assertIsInstance(revision_id, str) |
|
83 |
last = br.last_revision() |
|
84 |
self.assertEqual('rev3', last) |
|
85 |
self.assertIsInstance(last, str) |
|
2249.5.19
by John Arbash Meinel
Track through the new Branch6 code, and make sure revision ids are utf8 |
86 |
revno, last = br.last_revision_info() |
87 |
self.assertEqual(3, revno) |
|
88 |
self.assertEqual('rev3', last) |
|
89 |
self.assertIsInstance(last, str) |
|
2249.5.6
by John Arbash Meinel
Make sure Branch.revision_history() also works in utf-8 revision ids. |
90 |
|
1260
by Martin Pool
- some updates for fetch/update function |
91 |
def test_fetch_revisions(self): |
92 |
"""Test fetch-revision operation."""
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
93 |
wt = self.make_branch_and_tree('b1') |
94 |
b1 = wt.branch |
|
2381.1.3
by Robert Collins
Review feedback. |
95 |
self.build_tree_contents([('b1/foo', 'hello')]) |
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
96 |
wt.add(['foo'], ['foo-id']) |
97 |
wt.commit('lala!', rev_id='revision-1', allow_pointless=False) |
|
1260
by Martin Pool
- some updates for fetch/update function |
98 |
|
2381.1.3
by Robert Collins
Review feedback. |
99 |
b2 = self.make_branch('b2') |
4060.1.4
by Robert Collins
Streaming fetch from remote servers. |
100 |
b2.fetch(b1) |
1260
by Martin Pool
- some updates for fetch/update function |
101 |
|
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
102 |
rev = b2.repository.get_revision('revision-1') |
103 |
tree = b2.repository.revision_tree('revision-1') |
|
3015.2.1
by Robert Collins
Lock correctness in branch implementation tests. |
104 |
tree.lock_read() |
105 |
self.addCleanup(tree.unlock) |
|
1534.1.32
by Robert Collins
Deprecate direct use of fetch.Fetcher. |
106 |
self.assertEqual(tree.get_file_text('foo-id'), 'hello') |
1260
by Martin Pool
- some updates for fetch/update function |
107 |
|
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
108 |
def test_get_revision_delta(self): |
109 |
tree_a = self.make_branch_and_tree('a') |
|
2381.1.3
by Robert Collins
Review feedback. |
110 |
self.build_tree(['a/foo']) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
111 |
tree_a.add('foo', 'file1') |
112 |
tree_a.commit('rev1', rev_id='rev1') |
|
2381.1.3
by Robert Collins
Review feedback. |
113 |
self.build_tree(['a/vla']) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
114 |
tree_a.add('vla', 'file2') |
115 |
tree_a.commit('rev2', rev_id='rev2') |
|
116 |
||
6171.1.2
by Jelmer Vernooij
Use applyDeprecated for Branch.get_revision_delta tests. |
117 |
delta = self.applyDeprecated(symbol_versioning.deprecated_in( |
118 |
(2, 5, 0)), tree_a.branch.get_revision_delta, 1) |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
119 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
120 |
self.assertEqual([('foo', 'file1', 'file')], delta.added) |
6171.1.2
by Jelmer Vernooij
Use applyDeprecated for Branch.get_revision_delta tests. |
121 |
delta = self.applyDeprecated(symbol_versioning.deprecated_in( |
122 |
(2, 5, 0)), tree_a.branch.get_revision_delta, 2) |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
123 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
124 |
self.assertEqual([('vla', 'file2', 'file')], delta.added) |
125 |
||
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
126 |
def get_unbalanced_tree_pair(self): |
1442.1.67
by Robert Collins
Factor out the guts of 'pull' from the command into WorkingTree.pull(). |
127 |
"""Return two branches, a and b, with one file in a."""
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
128 |
tree_a = self.make_branch_and_tree('a') |
2381.1.3
by Robert Collins
Review feedback. |
129 |
self.build_tree_contents([('a/b', 'b')]) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
130 |
tree_a.add('b') |
131 |
tree_a.commit("silly commit", rev_id='A') |
|
132 |
||
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
133 |
tree_b = self.make_branch_and_tree('b') |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
134 |
return tree_a, tree_b |
1442.1.67
by Robert Collins
Factor out the guts of 'pull' from the command into WorkingTree.pull(). |
135 |
|
136 |
def get_balanced_branch_pair(self): |
|
137 |
"""Returns br_a, br_b as with one commit in a, and b has a's stores."""
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
138 |
tree_a, tree_b = self.get_unbalanced_tree_pair() |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
139 |
tree_b.branch.repository.fetch(tree_a.branch.repository) |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
140 |
return tree_a, tree_b |
1442.1.67
by Robert Collins
Factor out the guts of 'pull' from the command into WorkingTree.pull(). |
141 |
|
1185.66.8
by Aaron Bentley
Applied Jelmer's patch to make clone a branch operation |
142 |
def test_clone_partial(self): |
1393.1.23
by Martin Pool
- fix cloning of part of a branch |
143 |
"""Copy only part of the history of a branch."""
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
144 |
# TODO: RBC 20060208 test with a revision not on revision-history.
|
145 |
# what should that behaviour be ? Emailed the list.
|
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
146 |
# First, make a branch with two commits.
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
147 |
wt_a = self.make_branch_and_tree('a') |
2381.1.3
by Robert Collins
Review feedback. |
148 |
self.build_tree(['a/one']) |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
149 |
wt_a.add(['one']) |
150 |
wt_a.commit('commit one', rev_id='1') |
|
2381.1.3
by Robert Collins
Review feedback. |
151 |
self.build_tree(['a/two']) |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
152 |
wt_a.add(['two']) |
153 |
wt_a.commit('commit two', rev_id='2') |
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
154 |
# Now make a copy of the repository.
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
155 |
repo_b = self.make_repository('b') |
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
156 |
wt_a.branch.repository.copy_content_into(repo_b) |
157 |
# wt_a might be a lightweight checkout, so get a hold of the actual
|
|
158 |
# branch (because you can't do a partial clone of a lightweight
|
|
159 |
# checkout).
|
|
160 |
branch = wt_a.branch.bzrdir.open_branch() |
|
161 |
# Then make a branch where the new repository is, but specify a revision
|
|
162 |
# ID. The new branch's history will stop at the specified revision.
|
|
163 |
br_b = branch.clone(repo_b.bzrdir, revision_id='1') |
|
1908.7.6
by Robert Collins
Deprecate WorkingTree.last_revision. |
164 |
self.assertEqual('1', br_b.last_revision()) |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
165 |
|
1864.7.2
by John Arbash Meinel
Test that we copy the parent across properly (if it is available) |
166 |
def get_parented_branch(self): |
167 |
wt_a = self.make_branch_and_tree('a') |
|
2381.1.3
by Robert Collins
Review feedback. |
168 |
self.build_tree(['a/one']) |
1864.7.2
by John Arbash Meinel
Test that we copy the parent across properly (if it is available) |
169 |
wt_a.add(['one']) |
170 |
wt_a.commit('commit one', rev_id='1') |
|
171 |
||
3489.2.4
by Andrew Bennetts
Fix all tests broken by fixing make_branch_and_tree. |
172 |
branch_b = wt_a.branch.bzrdir.sprout('b', revision_id='1').open_branch() |
1864.7.2
by John Arbash Meinel
Test that we copy the parent across properly (if it is available) |
173 |
self.assertEqual(wt_a.branch.base, branch_b.get_parent()) |
174 |
return branch_b |
|
175 |
||
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
176 |
def test_clone_branch_nickname(self): |
177 |
# test the nick name is preserved always
|
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
178 |
raise tests.TestSkipped('XXX branch cloning is not yet tested.') |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
179 |
|
180 |
def test_clone_branch_parent(self): |
|
181 |
# test the parent is preserved always
|
|
1864.7.2
by John Arbash Meinel
Test that we copy the parent across properly (if it is available) |
182 |
branch_b = self.get_parented_branch() |
183 |
repo_c = self.make_repository('c') |
|
184 |
branch_b.repository.copy_content_into(repo_c) |
|
185 |
branch_c = branch_b.clone(repo_c.bzrdir) |
|
186 |
self.assertNotEqual(None, branch_c.get_parent()) |
|
187 |
self.assertEqual(branch_b.get_parent(), branch_c.get_parent()) |
|
188 |
||
189 |
# We can also set a specific parent, and it should be honored
|
|
5560.2.1
by Vincent Ladeuil
Fix the remaining references to http://bazaar-vcs.org (except the explicitly historical ones). |
190 |
random_parent = 'http://example.com/path/to/branch' |
1864.7.2
by John Arbash Meinel
Test that we copy the parent across properly (if it is available) |
191 |
branch_b.set_parent(random_parent) |
192 |
repo_d = self.make_repository('d') |
|
193 |
branch_b.repository.copy_content_into(repo_d) |
|
194 |
branch_d = branch_b.clone(repo_d.bzrdir) |
|
195 |
self.assertEqual(random_parent, branch_d.get_parent()) |
|
196 |
||
1804.1.1
by Aaron Bentley
Add support for submit location to bundles |
197 |
def test_submit_branch(self): |
198 |
"""Submit location can be queried and set"""
|
|
199 |
branch = self.make_branch('branch') |
|
200 |
self.assertEqual(branch.get_submit_branch(), None) |
|
201 |
branch.set_submit_branch('sftp://example.com') |
|
202 |
self.assertEqual(branch.get_submit_branch(), 'sftp://example.com') |
|
203 |
branch.set_submit_branch('sftp://example.net') |
|
204 |
self.assertEqual(branch.get_submit_branch(), 'sftp://example.net') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
205 |
|
1551.12.44
by Aaron Bentley
Add (set|get)_public_branch |
206 |
def test_public_branch(self): |
207 |
"""public location can be queried and set"""
|
|
208 |
branch = self.make_branch('branch') |
|
209 |
self.assertEqual(branch.get_public_branch(), None) |
|
210 |
branch.set_public_branch('sftp://example.com') |
|
211 |
self.assertEqual(branch.get_public_branch(), 'sftp://example.com') |
|
212 |
branch.set_public_branch('sftp://example.net') |
|
213 |
self.assertEqual(branch.get_public_branch(), 'sftp://example.net') |
|
214 |
branch.set_public_branch(None) |
|
215 |
self.assertEqual(branch.get_public_branch(), None) |
|
216 |
||
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
217 |
def test_record_initial_ghost(self): |
218 |
"""Branches should support having ghosts."""
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
219 |
wt = self.make_branch_and_tree('.') |
6164.2.1
by Jelmer Vernooij
Skip tests if the repository doesn't support ghosts. |
220 |
if not wt.branch.repository._format.supports_ghosts: |
221 |
raise tests.TestNotApplicable("repository format does not " |
|
222 |
"support ghosts") |
|
1908.6.7
by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly. |
223 |
wt.set_parent_ids(['non:existent@rev--ision--0--2'], |
224 |
allow_leftmost_as_ghost=True) |
|
3240.1.3
by Aaron Bentley
Use Graph to generate revision_history |
225 |
self.assertEqual(['non:existent@rev--ision--0--2'], |
226 |
wt.get_parent_ids()) |
|
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
227 |
rev_id = wt.commit('commit against a ghost first parent.') |
228 |
rev = wt.branch.repository.get_revision(rev_id) |
|
229 |
self.assertEqual(rev.parent_ids, ['non:existent@rev--ision--0--2']) |
|
1092.2.25
by Robert Collins
support ghosts in commits |
230 |
# parent_sha1s is not populated now, WTF. rbc 20051003
|
231 |
self.assertEqual(len(rev.parent_sha1s), 0) |
|
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
232 |
|
233 |
def test_record_two_ghosts(self): |
|
234 |
"""Recording with all ghosts works."""
|
|
235 |
wt = self.make_branch_and_tree('.') |
|
6164.2.1
by Jelmer Vernooij
Skip tests if the repository doesn't support ghosts. |
236 |
if not wt.branch.repository._format.supports_ghosts: |
237 |
raise tests.TestNotApplicable("repository format does not " |
|
238 |
"support ghosts") |
|
1908.6.7
by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly. |
239 |
wt.set_parent_ids([ |
240 |
'foo@azkhazan-123123-abcabc', |
|
241 |
'wibble@fofof--20050401--1928390812', |
|
242 |
],
|
|
243 |
allow_leftmost_as_ghost=True) |
|
1927.2.1
by Robert Collins
Alter set_pending_merges to shove the left most merge into the trees last-revision if that is not set. Related bugfixes include basis_tree handling ghosts, de-duping the merges with the last-revision and update changing where and how it adds its pending merge. |
244 |
rev_id = wt.commit("commit from ghost base with one merge") |
245 |
# the revision should have been committed with two parents
|
|
246 |
rev = wt.branch.repository.get_revision(rev_id) |
|
247 |
self.assertEqual(['foo@azkhazan-123123-abcabc', |
|
248 |
'wibble@fofof--20050401--1928390812'], |
|
249 |
rev.parent_ids) |
|
1092.2.25
by Robert Collins
support ghosts in commits |
250 |
|
1185.12.90
by Aaron Bentley
Fixed InvalidRevisionID handling in Branch.get_revision_xml |
251 |
def test_bad_revision(self): |
1534.4.28
by Robert Collins
first cut at merge from integration. |
252 |
self.assertRaises(errors.InvalidRevisionId, |
253 |
self.get_branch().repository.get_revision, |
|
254 |
None) |
|
1185.12.90
by Aaron Bentley
Fixed InvalidRevisionID handling in Branch.get_revision_xml |
255 |
|
1092.2.28
by Robert Collins
reenable test of fetching a branch with ghosts |
256 |
# TODO 20051003 RBC:
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
257 |
# compare the gpg-to-sign info for a commit with a ghost and
|
1092.2.25
by Robert Collins
support ghosts in commits |
258 |
# an identical tree without a ghost
|
259 |
# fetch missing should rewrite the TOC of weaves to list newly available parents.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
260 |
|
1442.1.60
by Robert Collins
gpg sign commits if the policy says we need to |
261 |
def test_sign_existing_revision(self): |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
262 |
wt = self.make_branch_and_tree('.') |
263 |
branch = wt.branch |
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
264 |
wt.commit("base", allow_pointless=True, rev_id='A') |
1442.1.60
by Robert Collins
gpg sign commits if the policy says we need to |
265 |
from bzrlib.testament import Testament |
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
266 |
strategy = gpg.LoopbackGPGStrategy(None) |
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
267 |
branch.repository.lock_write() |
268 |
branch.repository.start_write_group() |
|
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
269 |
branch.repository.sign_revision('A', strategy) |
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
270 |
branch.repository.commit_write_group() |
271 |
branch.repository.unlock() |
|
1551.12.36
by Aaron Bentley
Fix failing tests |
272 |
self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' + |
273 |
Testament.from_revision(branch.repository, |
|
274 |
'A').as_short_text() + |
|
1551.12.52
by Aaron Bentley
speling fix |
275 |
'-----END PSEUDO-SIGNED CONTENT-----\n', |
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
276 |
branch.repository.get_signature_text('A')) |
1442.1.60
by Robert Collins
gpg sign commits if the policy says we need to |
277 |
|
1442.1.62
by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions. |
278 |
def test_store_signature(self): |
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
279 |
wt = self.make_branch_and_tree('.') |
280 |
branch = wt.branch |
|
3015.2.3
by Robert Collins
Use write groups around revision signature tests for branch. |
281 |
branch.lock_write() |
282 |
try: |
|
283 |
branch.repository.start_write_group() |
|
284 |
try: |
|
285 |
branch.repository.store_revision_signature( |
|
286 |
gpg.LoopbackGPGStrategy(None), 'FOO', 'A') |
|
287 |
except: |
|
288 |
branch.repository.abort_write_group() |
|
289 |
raise
|
|
290 |
else: |
|
291 |
branch.repository.commit_write_group() |
|
292 |
finally: |
|
293 |
branch.unlock() |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
294 |
# A signature without a revision should not be accessible.
|
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
295 |
self.assertRaises(errors.NoSuchRevision, |
296 |
branch.repository.has_signature_for_revision_id, |
|
297 |
'A') |
|
298 |
wt.commit("base", allow_pointless=True, rev_id='A') |
|
1551.12.36
by Aaron Bentley
Fix failing tests |
299 |
self.assertEqual('-----BEGIN PSEUDO-SIGNED CONTENT-----\n' |
1551.12.52
by Aaron Bentley
speling fix |
300 |
'FOO-----END PSEUDO-SIGNED CONTENT-----\n', |
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
301 |
branch.repository.get_signature_text('A')) |
1469
by Robert Collins
Change Transport.* to work with URL's. |
302 |
|
1534.4.30
by Robert Collins
Test signature preservation on clone and upgrade. |
303 |
def test_branch_keeps_signatures(self): |
304 |
wt = self.make_branch_and_tree('source') |
|
305 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
306 |
repo = wt.branch.repository |
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
307 |
repo.lock_write() |
308 |
repo.start_write_group() |
|
2818.4.2
by Robert Collins
Review feedback. |
309 |
repo.sign_revision('A', gpg.LoopbackGPGStrategy(None)) |
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
310 |
repo.commit_write_group() |
311 |
repo.unlock() |
|
1534.4.30
by Robert Collins
Test signature preservation on clone and upgrade. |
312 |
#FIXME: clone should work to urls,
|
313 |
# wt.clone should work to disks.
|
|
314 |
self.build_tree(['target/']) |
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
315 |
d2 = repo.bzrdir.clone(urlutils.local_path_to_url('target')) |
316 |
self.assertEqual(repo.get_signature_text('A'), |
|
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
317 |
d2.open_repository().get_signature_text('A')) |
1534.4.30
by Robert Collins
Test signature preservation on clone and upgrade. |
318 |
|
6162.2.3
by Jelmer Vernooij
Fix nick tests against foreign formats. |
319 |
def test_nicks_bzr(self): |
320 |
"""Test the behaviour of branch nicks specific to bzr branches.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
321 |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
322 |
Nicknames are implicitly the name of the branch's directory, unless an
|
323 |
explicit nickname is set. That is, an explicit nickname always
|
|
324 |
overrides the implicit one.
|
|
6162.2.3
by Jelmer Vernooij
Fix nick tests against foreign formats. |
325 |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
326 |
"""
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
327 |
t = self.get_transport() |
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
328 |
branch = self.make_branch('bzr.dev') |
6162.2.3
by Jelmer Vernooij
Fix nick tests against foreign formats. |
329 |
if not isinstance(branch, _mod_branch.BzrBranch): |
330 |
raise tests.TestNotApplicable("not a bzr branch format") |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
331 |
# The nick will be 'bzr.dev', because there is no explicit nick set.
|
1185.35.11
by Aaron Bentley
Added support for branch nicks |
332 |
self.assertEqual(branch.nick, 'bzr.dev') |
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
333 |
# Move the branch to a different directory, 'bzr.ab'. Now that branch
|
334 |
# will report its nick as 'bzr.ab'.
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
335 |
t.move('bzr.dev', 'bzr.ab') |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
336 |
branch = _mod_branch.Branch.open(self.get_url('bzr.ab')) |
1185.35.11
by Aaron Bentley
Added support for branch nicks |
337 |
self.assertEqual(branch.nick, 'bzr.ab') |
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
338 |
# Set the branch nick explicitly. This will ensure there's a branch
|
339 |
# config file in the branch.
|
|
340 |
branch.nick = "Aaron's branch" |
|
2018.5.129
by Robert Collins
Branch implementations test test_set_get_parent should not depend on local urls : the test can be valid for any url namespace. Change it to be valid in that manner. (Robert Collins, Andrew Bennetts) |
341 |
if not isinstance(branch, remote.RemoteBranch): |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
342 |
self.assertTrue(branch._transport.has("branch.conf")) |
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
343 |
# Because the nick has been set explicitly, the nick is now always
|
344 |
# "Aaron's branch", regardless of directory name.
|
|
1185.35.11
by Aaron Bentley
Added support for branch nicks |
345 |
self.assertEqual(branch.nick, "Aaron's branch") |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
346 |
t.move('bzr.ab', 'integration') |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
347 |
branch = _mod_branch.Branch.open(self.get_url('integration')) |
1185.35.11
by Aaron Bentley
Added support for branch nicks |
348 |
self.assertEqual(branch.nick, "Aaron's branch") |
1185.35.12
by Aaron Bentley
Got writes of existing tree configs working. |
349 |
branch.nick = u"\u1234" |
350 |
self.assertEqual(branch.nick, u"\u1234") |
|
1185.35.11
by Aaron Bentley
Added support for branch nicks |
351 |
|
6162.2.3
by Jelmer Vernooij
Fix nick tests against foreign formats. |
352 |
def test_nicks(self): |
353 |
"""Test explicit and implicit branch nicknames.
|
|
354 |
||
355 |
A nickname is always available, whether set explicitly or not.
|
|
356 |
"""
|
|
357 |
t = self.get_transport() |
|
358 |
branch = self.make_branch('bzr.dev') |
|
359 |
# An implicit nick name is set; what it is exactly depends on the
|
|
360 |
# format.
|
|
361 |
self.assertIsInstance(branch.nick, basestring) |
|
362 |
# Set the branch nick explicitly.
|
|
363 |
branch.nick = "Aaron's branch" |
|
364 |
# Because the nick has been set explicitly, the nick is now always
|
|
365 |
# "Aaron's branch".
|
|
366 |
self.assertEqual(branch.nick, "Aaron's branch") |
|
367 |
branch.nick = u"\u1234" |
|
368 |
self.assertEqual(branch.nick, u"\u1234") |
|
369 |
||
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
370 |
def test_commit_nicks(self): |
371 |
"""Nicknames are committed to the revision"""
|
|
372 |
wt = self.make_branch_and_tree('bzr.dev') |
|
373 |
branch = wt.branch |
|
374 |
branch.nick = "My happy branch" |
|
375 |
wt.commit('My commit respect da nick.') |
|
376 |
committed = branch.repository.get_revision(branch.last_revision()) |
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
377 |
self.assertEqual(committed.properties["branch-nick"], |
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
378 |
"My happy branch") |
379 |
||
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
380 |
def test_create_colocated(self): |
381 |
try: |
|
382 |
repo = self.make_repository('.', shared=True) |
|
383 |
except errors.IncompatibleFormat: |
|
384 |
return
|
|
385 |
self.assertEquals(0, len(repo.bzrdir.list_branches())) |
|
386 |
try: |
|
387 |
child_branch1 = self.branch_format.initialize(repo.bzrdir, |
|
388 |
name='branch1') |
|
389 |
except (errors.UninitializableFormat, errors.NoColocatedBranchSupport): |
|
390 |
# branch references are not default init'able and
|
|
391 |
# not all bzrdirs support colocated branches.
|
|
392 |
return
|
|
393 |
self.assertEquals(1, len(repo.bzrdir.list_branches())) |
|
394 |
self.branch_format.initialize(repo.bzrdir, name='branch2') |
|
395 |
self.assertEquals(2, len(repo.bzrdir.list_branches())) |
|
396 |
||
6123.9.12
by Jelmer Vernooij
Add append_revisions_only argument to BranchFormat.initialize. |
397 |
def test_create_append_revisions_only(self): |
398 |
try: |
|
399 |
repo = self.make_repository('.', shared=True) |
|
400 |
except errors.IncompatibleFormat: |
|
401 |
return
|
|
402 |
for val in (True, False): |
|
403 |
try: |
|
404 |
branch = self.branch_format.initialize(repo.bzrdir, |
|
405 |
append_revisions_only=True) |
|
406 |
except (errors.UninitializableFormat, errors.UpgradeRequired): |
|
407 |
# branch references are not default init'able and
|
|
408 |
# not all branches support append_revisions_only
|
|
409 |
return
|
|
410 |
self.assertEquals(True, branch.get_append_revisions_only()) |
|
411 |
repo.bzrdir.destroy_branch() |
|
412 |
||
6123.9.14
by Jelmer Vernooij
Fix RemoteBranch.get_append_revisions_only(). |
413 |
def test_get_set_append_revisions_only(self): |
414 |
branch = self.make_branch('.') |
|
415 |
if branch._format.supports_set_append_revisions_only(): |
|
416 |
branch.set_append_revisions_only(True) |
|
417 |
self.assertTrue(branch.get_append_revisions_only()) |
|
418 |
branch.set_append_revisions_only(False) |
|
419 |
self.assertFalse(branch.get_append_revisions_only()) |
|
420 |
else: |
|
421 |
self.assertRaises(errors.UpgradeRequired, |
|
422 |
branch.set_append_revisions_only, True) |
|
423 |
self.assertFalse(branch.get_append_revisions_only()) |
|
424 |
||
1534.6.4
by Robert Collins
Creating or opening a branch will use the repository if the format supports that. |
425 |
def test_create_open_branch_uses_repository(self): |
426 |
try: |
|
427 |
repo = self.make_repository('.', shared=True) |
|
428 |
except errors.IncompatibleFormat: |
|
6162.5.1
by Jelmer Vernooij
Skip test if control dir format is not initializable. |
429 |
raise tests.TestNotApplicable("requires shared repository support") |
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
430 |
child_transport = repo.bzrdir.root_transport.clone('child') |
431 |
child_transport.mkdir('.') |
|
6162.3.1
by Jelmer Vernooij
Skip a few tests for uninitializable formats. |
432 |
try: |
433 |
child_dir = self.bzrdir_format.initialize_on_transport(child_transport) |
|
434 |
except errors.UninitializableFormat: |
|
6162.5.1
by Jelmer Vernooij
Skip test if control dir format is not initializable. |
435 |
raise tests.TestNotApplicable("control dir format not initializable") |
1534.6.4
by Robert Collins
Creating or opening a branch will use the repository if the format supports that. |
436 |
try: |
437 |
child_branch = self.branch_format.initialize(child_dir) |
|
438 |
except errors.UninitializableFormat: |
|
439 |
# branch references are not default init'able.
|
|
440 |
return
|
|
441 |
self.assertEqual(repo.bzrdir.root_transport.base, |
|
442 |
child_branch.repository.bzrdir.root_transport.base) |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
443 |
child_branch = _mod_branch.Branch.open(self.get_url('child')) |
1534.6.4
by Robert Collins
Creating or opening a branch will use the repository if the format supports that. |
444 |
self.assertEqual(repo.bzrdir.root_transport.base, |
445 |
child_branch.repository.bzrdir.root_transport.base) |
|
446 |
||
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
447 |
def test_format_description(self): |
448 |
tree = self.make_branch_and_tree('tree') |
|
449 |
text = tree.branch._format.get_format_description() |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
450 |
self.assertTrue(len(text)) |
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
451 |
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
452 |
def test_get_commit_builder(self): |
2617.6.2
by Robert Collins
Add abort_write_group and wire write_groups into fetch and commit. |
453 |
branch = self.make_branch(".") |
454 |
branch.lock_write() |
|
455 |
builder = branch.get_commit_builder([]) |
|
456 |
self.assertIsInstance(builder, repository.CommitBuilder) |
|
457 |
branch.repository.commit_write_group() |
|
458 |
branch.unlock() |
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
459 |
|
1792.1.1
by Robert Collins
Factor out revision-history synthesis to make it reusable as Branch.generate_revision_history. |
460 |
def test_generate_revision_history(self): |
461 |
"""Create a fake revision history easily."""
|
|
462 |
tree = self.make_branch_and_tree('.') |
|
463 |
rev1 = tree.commit('foo') |
|
464 |
orig_history = tree.branch.revision_history() |
|
465 |
rev2 = tree.commit('bar', allow_pointless=True) |
|
466 |
tree.branch.generate_revision_history(rev1) |
|
467 |
self.assertEqual(orig_history, tree.branch.revision_history()) |
|
468 |
||
1836.3.1
by Robert Collins
(robertc) Teach repository.get_revision_graph, and revision.common_ancestor, about NULL_REVISION. |
469 |
def test_generate_revision_history_NULL_REVISION(self): |
470 |
tree = self.make_branch_and_tree('.') |
|
471 |
rev1 = tree.commit('foo') |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
472 |
tree.branch.generate_revision_history(revision.NULL_REVISION) |
1836.3.1
by Robert Collins
(robertc) Teach repository.get_revision_graph, and revision.common_ancestor, about NULL_REVISION. |
473 |
self.assertEqual([], tree.branch.revision_history()) |
474 |
||
1551.8.6
by Aaron Bentley
Rename test |
475 |
def test_create_checkout(self): |
1551.8.3
by Aaron Bentley
Make create_checkout_convenience a Branch method |
476 |
tree_a = self.make_branch_and_tree('a') |
477 |
branch_a = tree_a.branch |
|
1551.8.5
by Aaron Bentley
Change name to create_checkout |
478 |
checkout_b = branch_a.create_checkout('b') |
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
479 |
self.assertEqual('null:', checkout_b.last_revision()) |
1551.8.3
by Aaron Bentley
Make create_checkout_convenience a Branch method |
480 |
checkout_b.commit('rev1', rev_id='rev1') |
481 |
self.assertEqual('rev1', branch_a.last_revision()) |
|
482 |
self.assertNotEqual(checkout_b.branch.base, branch_a.base) |
|
483 |
||
1551.8.5
by Aaron Bentley
Change name to create_checkout |
484 |
checkout_c = branch_a.create_checkout('c', lightweight=True) |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
485 |
self.assertEqual('rev1', checkout_c.last_revision()) |
1551.8.3
by Aaron Bentley
Make create_checkout_convenience a Branch method |
486 |
checkout_c.commit('rev2', rev_id='rev2') |
487 |
self.assertEqual('rev2', branch_a.last_revision()) |
|
488 |
self.assertEqual(checkout_c.branch.base, branch_a.base) |
|
489 |
||
1551.8.5
by Aaron Bentley
Change name to create_checkout |
490 |
checkout_d = branch_a.create_checkout('d', lightweight=True) |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
491 |
self.assertEqual('rev2', checkout_d.last_revision()) |
1551.8.5
by Aaron Bentley
Change name to create_checkout |
492 |
checkout_e = branch_a.create_checkout('e') |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
493 |
self.assertEqual('rev2', checkout_e.last_revision()) |
1425
by Robert Collins
merge from Aaron - unbreaks open_containing and the fetch progress bar |
494 |
|
1997.1.4
by Robert Collins
``bzr checkout --lightweight`` now operates on readonly branches as well |
495 |
def test_create_anonymous_lightweight_checkout(self): |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
496 |
"""A lightweight checkout from a readonly branch should succeed."""
|
1997.1.4
by Robert Collins
``bzr checkout --lightweight`` now operates on readonly branches as well |
497 |
tree_a = self.make_branch_and_tree('a') |
498 |
rev_id = tree_a.commit('put some content in the branch') |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
499 |
# open the branch via a readonly transport
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
500 |
source_branch = _mod_branch.Branch.open(self.get_readonly_url('a')) |
1997.1.4
by Robert Collins
``bzr checkout --lightweight`` now operates on readonly branches as well |
501 |
# sanity check that the test will be valid
|
502 |
self.assertRaises((errors.LockError, errors.TransportNotPossible), |
|
503 |
source_branch.lock_write) |
|
504 |
checkout = source_branch.create_checkout('c', lightweight=True) |
|
505 |
self.assertEqual(rev_id, checkout.last_revision()) |
|
506 |
||
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
507 |
def test_create_anonymous_heavyweight_checkout(self): |
508 |
"""A regular checkout from a readonly branch should succeed."""
|
|
509 |
tree_a = self.make_branch_and_tree('a') |
|
510 |
rev_id = tree_a.commit('put some content in the branch') |
|
2018.5.95
by Andrew Bennetts
Add a Transport.is_readonly remote call, let {Branch,Repository}.lock_write remote call return UnlockableTransport, and miscellaneous test fixes. |
511 |
# open the branch via a readonly transport
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
512 |
source_branch = _mod_branch.Branch.open(self.get_readonly_url('a')) |
1997.1.5
by Robert Collins
``Branch.bind(other_branch)`` no longer takes a write lock on the |
513 |
# sanity check that the test will be valid
|
514 |
self.assertRaises((errors.LockError, errors.TransportNotPossible), |
|
515 |
source_branch.lock_write) |
|
516 |
checkout = source_branch.create_checkout('c') |
|
517 |
self.assertEqual(rev_id, checkout.last_revision()) |
|
518 |
||
2018.12.1
by Andrew Bennetts
Add TestBranch.test_set_revision_history |
519 |
def test_set_revision_history(self): |
2018.5.97
by Andrew Bennetts
Fix more tests. |
520 |
tree = self.make_branch_and_tree('a') |
521 |
tree.commit('a commit', rev_id='rev1') |
|
522 |
br = tree.branch |
|
5718.7.6
by Jelmer Vernooij
Fix import. |
523 |
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)), |
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
524 |
br.set_revision_history, ["rev1"]) |
6165.2.1
by Jelmer Vernooij
Avoid using revision_history in the testsuite, in preparation of deprecating it. |
525 |
self.assertEquals(br.last_revision(), "rev1") |
5718.7.6
by Jelmer Vernooij
Fix import. |
526 |
self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)), |
5718.7.4
by Jelmer Vernooij
Branch.set_revision_history. |
527 |
br.set_revision_history, []) |
6165.2.1
by Jelmer Vernooij
Avoid using revision_history in the testsuite, in preparation of deprecating it. |
528 |
self.assertEquals(br.last_revision(), 'null:') |
2018.12.1
by Andrew Bennetts
Add TestBranch.test_set_revision_history |
529 |
|
5672.1.1
by Andrew Bennetts
Refactor some of FetchSpecFactory into new Branch.heads_to_fetch method so that branch implementations like looms can override it. |
530 |
def test_heads_to_fetch(self): |
531 |
# heads_to_fetch is a method that returns a collection of revids that
|
|
532 |
# need to be fetched to copy this branch into another repo. At a
|
|
533 |
# minimum this will include the tip.
|
|
534 |
# (In native formats, this is the tip + tags, but other formats may
|
|
535 |
# have other revs needed)
|
|
536 |
tree = self.make_branch_and_tree('a') |
|
537 |
tree.commit('first commit', rev_id='rev1') |
|
538 |
tree.commit('second commit', rev_id='rev2') |
|
539 |
must_fetch, should_fetch = tree.branch.heads_to_fetch() |
|
540 |
self.assertTrue('rev2' in must_fetch) |
|
541 |
||
542 |
def test_heads_to_fetch_not_null_revision(self): |
|
543 |
# NULL_REVISION does not appear in the result of heads_to_fetch, even
|
|
544 |
# for an empty branch.
|
|
545 |
tree = self.make_branch_and_tree('a') |
|
546 |
must_fetch, should_fetch = tree.branch.heads_to_fetch() |
|
547 |
self.assertFalse(revision.NULL_REVISION in must_fetch) |
|
548 |
self.assertFalse(revision.NULL_REVISION in should_fetch) |
|
549 |
||
1551.8.4
by Aaron Bentley
Tweak import style |
550 |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
551 |
class TestBranchFormat(per_branch.TestCaseWithBranch): |
4032.3.1
by Robert Collins
Add a BranchFormat.network_name() method as preparation for creating branches via RPC calls. |
552 |
|
553 |
def test_branch_format_network_name(self): |
|
554 |
br = self.make_branch('.') |
|
555 |
format = br._format |
|
556 |
network_name = format.network_name() |
|
557 |
self.assertIsInstance(network_name, str) |
|
558 |
# We want to test that the network_name matches the actual format on
|
|
559 |
# disk. For local branches that means that using network_name as a key
|
|
560 |
# in the registry gives back the same format. For remote branches we
|
|
561 |
# check that the network_name of the RemoteBranchFormat we have locally
|
|
562 |
# matches the actual format present on disk.
|
|
563 |
if isinstance(format, remote.RemoteBranchFormat): |
|
564 |
br._ensure_real() |
|
565 |
real_branch = br._real_branch |
|
566 |
self.assertEqual(real_branch._format.network_name(), network_name) |
|
567 |
else: |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
568 |
registry = _mod_branch.network_format_registry |
4032.3.1
by Robert Collins
Add a BranchFormat.network_name() method as preparation for creating branches via RPC calls. |
569 |
looked_up_format = registry.get(network_name) |
570 |
self.assertEqual(format.__class__, looked_up_format.__class__) |
|
571 |
||
6155.2.2
by Vincent Ladeuil
Add a smoke test as suggested in review. |
572 |
def get_get_config_calls(self): |
573 |
# Smoke test that all branch succeed getting a config
|
|
574 |
br = self.make_branch('.') |
|
575 |
br.get_config() |
|
576 |
br.get_config_stack() |
|
577 |
||
4032.3.1
by Robert Collins
Add a BranchFormat.network_name() method as preparation for creating branches via RPC calls. |
578 |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
579 |
class ChrootedTests(per_branch.TestCaseWithBranch): |
1534.4.11
by Robert Collins
Convert test_open_containing from being a Remote test to being the more accurate Chrooted test. |
580 |
"""A support class that provides readonly urls outside the local namespace.
|
581 |
||
582 |
This is done by checking if self.transport_server is a MemoryServer. if it
|
|
583 |
is then we are chrooted already, if it is not then an HttpServer is used
|
|
584 |
for readonly urls.
|
|
585 |
"""
|
|
586 |
||
587 |
def setUp(self): |
|
588 |
super(ChrootedTests, self).setUp() |
|
5017.3.45
by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry. |
589 |
if not self.vfs_transport_factory == memory.MemoryServer: |
1534.4.11
by Robert Collins
Convert test_open_containing from being a Remote test to being the more accurate Chrooted test. |
590 |
self.transport_readonly_server = HttpServer |
1425
by Robert Collins
merge from Aaron - unbreaks open_containing and the fetch progress bar |
591 |
|
1185.12.18
by Aaron Bentley
Fixed error handling when NotBranch on HTTP |
592 |
def test_open_containing(self): |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
593 |
self.assertRaises(errors.NotBranchError, |
594 |
_mod_branch.Branch.open_containing, |
|
1534.4.11
by Robert Collins
Convert test_open_containing from being a Remote test to being the more accurate Chrooted test. |
595 |
self.get_readonly_url('')) |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
596 |
self.assertRaises(errors.NotBranchError, |
597 |
_mod_branch.Branch.open_containing, |
|
1534.4.11
by Robert Collins
Convert test_open_containing from being a Remote test to being the more accurate Chrooted test. |
598 |
self.get_readonly_url('g/p/q')) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
599 |
branch = self.make_branch('.') |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
600 |
branch, relpath = _mod_branch.Branch.open_containing( |
601 |
self.get_readonly_url('')) |
|
1442.1.64
by Robert Collins
Branch.open_containing now returns a tuple (Branch, relative-path). |
602 |
self.assertEqual('', relpath) |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
603 |
branch, relpath = _mod_branch.Branch.open_containing( |
604 |
self.get_readonly_url('g/p/q')) |
|
1442.1.64
by Robert Collins
Branch.open_containing now returns a tuple (Branch, relative-path). |
605 |
self.assertEqual('g/p/q', relpath) |
2929.3.21
by Vincent Ladeuil
Merge bzr.dev, resolve conflicts. |
606 |
|
1417.1.6
by Robert Collins
introduce transactions for grouping actions done to and with branches |
607 |
|
608 |
class InstrumentedTransaction(object): |
|
609 |
||
610 |
def finish(self): |
|
611 |
self.calls.append('finish') |
|
612 |
||
613 |
def __init__(self): |
|
614 |
self.calls = [] |
|
615 |
||
616 |
||
1442.1.63
by Robert Collins
Remove self.lock_*...finally: self.unlock() dead chickens from branch.py. |
617 |
class TestDecorator(object): |
618 |
||
619 |
def __init__(self): |
|
620 |
self._calls = [] |
|
621 |
||
622 |
def lock_read(self): |
|
623 |
self._calls.append('lr') |
|
624 |
||
625 |
def lock_write(self): |
|
626 |
self._calls.append('lw') |
|
627 |
||
628 |
def unlock(self): |
|
629 |
self._calls.append('ul') |
|
630 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
631 |
@_mod_branch.needs_read_lock |
1442.1.63
by Robert Collins
Remove self.lock_*...finally: self.unlock() dead chickens from branch.py. |
632 |
def do_with_read(self): |
633 |
return 1 |
|
634 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
635 |
@_mod_branch.needs_read_lock |
1442.1.63
by Robert Collins
Remove self.lock_*...finally: self.unlock() dead chickens from branch.py. |
636 |
def except_with_read(self): |
637 |
raise RuntimeError |
|
638 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
639 |
@_mod_branch.needs_write_lock |
1442.1.63
by Robert Collins
Remove self.lock_*...finally: self.unlock() dead chickens from branch.py. |
640 |
def do_with_write(self): |
641 |
return 2 |
|
642 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
643 |
@_mod_branch.needs_write_lock |
1442.1.63
by Robert Collins
Remove self.lock_*...finally: self.unlock() dead chickens from branch.py. |
644 |
def except_with_write(self): |
645 |
raise RuntimeError |
|
646 |
||
647 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
648 |
class TestDecorators(tests.TestCase): |
1442.1.63
by Robert Collins
Remove self.lock_*...finally: self.unlock() dead chickens from branch.py. |
649 |
|
650 |
def test_needs_read_lock(self): |
|
651 |
branch = TestDecorator() |
|
652 |
self.assertEqual(1, branch.do_with_read()) |
|
653 |
self.assertEqual(['lr', 'ul'], branch._calls) |
|
654 |
||
655 |
def test_excepts_in_read_lock(self): |
|
656 |
branch = TestDecorator() |
|
657 |
self.assertRaises(RuntimeError, branch.except_with_read) |
|
658 |
self.assertEqual(['lr', 'ul'], branch._calls) |
|
659 |
||
660 |
def test_needs_write_lock(self): |
|
661 |
branch = TestDecorator() |
|
662 |
self.assertEqual(2, branch.do_with_write()) |
|
663 |
self.assertEqual(['lw', 'ul'], branch._calls) |
|
664 |
||
665 |
def test_excepts_in_write_lock(self): |
|
666 |
branch = TestDecorator() |
|
667 |
self.assertRaises(RuntimeError, branch.except_with_write) |
|
668 |
self.assertEqual(['lw', 'ul'], branch._calls) |
|
669 |
||
670 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
671 |
class TestBranchPushLocations(per_branch.TestCaseWithBranch): |
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
672 |
|
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
673 |
def test_get_push_location_unset(self): |
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
674 |
self.assertEqual(None, self.get_branch().get_push_location()) |
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
675 |
|
676 |
def test_get_push_location_exact(self): |
|
5345.1.19
by Vincent Ladeuil
Cleanup bt.per_branch.test_branch. |
677 |
b = self.get_branch() |
5345.1.26
by Vincent Ladeuil
Merge lockable-config-files into remove-gratuitous-ensure-config-dir-exist-calls resolving conflicts |
678 |
config.LocationConfig.from_string( |
5345.1.25
by Vincent Ladeuil
Move the '_save' parameter from '__init__' to 'from_bytes', fix fallouts. |
679 |
'[%s]\npush_location=foo\n' % (b.base,), b.base, save=True) |
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
680 |
self.assertEqual("foo", self.get_branch().get_push_location()) |
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
681 |
|
682 |
def test_set_push_location(self): |
|
1878.1.3
by John Arbash Meinel
some test cleanups |
683 |
branch = self.get_branch() |
684 |
branch.set_push_location('foo') |
|
2230.3.3
by Aaron Bentley
Add more config testing |
685 |
self.assertEqual('foo', branch.get_push_location()) |
1534.4.1
by Robert Collins
Allow parameterisation of the branch initialisation for bzrlib. |
686 |
|
687 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
688 |
class TestChildSubmitFormats(per_branch.TestCaseWithBranch): |
4382.3.1
by Jelmer Vernooij
Add Branch.get_child_submit_format(), so particular Branch implementations |
689 |
|
690 |
def test_get_child_submit_format_default(self): |
|
6104.2.4
by Jelmer Vernooij
Allow get_child_submit_format to return a string. |
691 |
submit_format = self.get_branch().get_child_submit_format() |
692 |
self.assertTrue(submit_format is None or |
|
693 |
isinstance(submit_format, str)) |
|
4382.3.1
by Jelmer Vernooij
Add Branch.get_child_submit_format(), so particular Branch implementations |
694 |
|
695 |
def test_get_child_submit_format(self): |
|
696 |
branch = self.get_branch() |
|
697 |
branch.get_config().set_user_option('child_submit_format', '10') |
|
698 |
branch = self.get_branch() |
|
699 |
self.assertEqual('10', branch.get_child_submit_format()) |
|
700 |
||
701 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
702 |
class TestFormat(per_branch.TestCaseWithBranch): |
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
703 |
"""Tests for the format itself."""
|
704 |
||
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
705 |
def test_get_reference(self): |
706 |
"""get_reference on all regular branches should return None."""
|
|
707 |
if not self.branch_format.is_supported(): |
|
708 |
# unsupported formats are not loopback testable
|
|
709 |
# because the default open will not open them and
|
|
710 |
# they may not be initializable.
|
|
711 |
return
|
|
712 |
made_branch = self.make_branch('.') |
|
713 |
self.assertEqual(None, |
|
714 |
made_branch._format.get_reference(made_branch.bzrdir)) |
|
715 |
||
3078.2.7
by Ian Clatworthy
added smoke test for set_reference |
716 |
def test_set_reference(self): |
717 |
"""set_reference on all regular branches should be callable."""
|
|
718 |
if not self.branch_format.is_supported(): |
|
719 |
# unsupported formats are not loopback testable
|
|
720 |
# because the default open will not open them and
|
|
721 |
# they may not be initializable.
|
|
722 |
return
|
|
723 |
this_branch = self.make_branch('this') |
|
724 |
other_branch = self.make_branch('other') |
|
725 |
try: |
|
5147.4.4
by Jelmer Vernooij
Support colocated branches in BranchReference. |
726 |
this_branch._format.set_reference(this_branch.bzrdir, None, |
727 |
other_branch) |
|
3078.2.7
by Ian Clatworthy
added smoke test for set_reference |
728 |
except NotImplementedError: |
729 |
# that's ok
|
|
730 |
pass
|
|
731 |
else: |
|
732 |
ref = this_branch._format.get_reference(this_branch.bzrdir) |
|
733 |
self.assertEqual(ref, other_branch.base) |
|
734 |
||
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
735 |
def test_format_initialize_find_open(self): |
736 |
# loopback test to check the current format initializes to itself.
|
|
1534.4.7
by Robert Collins
Move downlevel check up to the Branch.open logic, removing it from the Branch constructor and deprecating relax_version_check to the same. |
737 |
if not self.branch_format.is_supported(): |
738 |
# unsupported formats are not loopback testable
|
|
739 |
# because the default open will not open them and
|
|
740 |
# they may not be initializable.
|
|
741 |
return
|
|
742 |
# supported formats must be able to init and open
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
743 |
t = self.get_transport() |
6039.1.5
by Jelmer Vernooij
Add get_transport_from_url and get_transport_from_path functions. |
744 |
readonly_t = transport.get_transport_from_url(self.get_readonly_url()) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
745 |
made_branch = self.make_branch('.') |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
746 |
self.assertIsInstance(made_branch, _mod_branch.Branch) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
747 |
|
748 |
# find it via bzrdir opening:
|
|
749 |
opened_control = bzrdir.BzrDir.open(readonly_t.base) |
|
750 |
direct_opened_branch = opened_control.open_branch() |
|
751 |
self.assertEqual(direct_opened_branch.__class__, made_branch.__class__) |
|
752 |
self.assertEqual(opened_control, direct_opened_branch.bzrdir) |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
753 |
self.assertIsInstance(direct_opened_branch._format, |
754 |
self.branch_format.__class__) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
755 |
|
756 |
# find it via Branch.open
|
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
757 |
opened_branch = _mod_branch.Branch.open(readonly_t.base) |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
758 |
self.assertIsInstance(opened_branch, made_branch.__class__) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
759 |
self.assertEqual(made_branch._format.__class__, |
760 |
opened_branch._format.__class__) |
|
761 |
# if it has a unique id string, can we probe for it ?
|
|
762 |
try: |
|
763 |
self.branch_format.get_format_string() |
|
764 |
except NotImplementedError: |
|
765 |
return
|
|
1534.4.3
by Robert Collins
Implement BranchTestProviderAdapter, so tests now run across all branch formats. |
766 |
self.assertEqual(self.branch_format, |
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
767 |
opened_control.find_branch_format()) |
1711.8.1
by John Arbash Meinel
Branch.lock_read/lock_write/unlock should handle failures |
768 |
|
2230.3.7
by Aaron Bentley
Fix binding return values |
769 |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
770 |
class TestBound(per_branch.TestCaseWithBranch): |
2230.3.6
by Aaron Bentley
work in progress bind stuff |
771 |
|
772 |
def test_bind_unbind(self): |
|
773 |
branch = self.make_branch('1') |
|
774 |
branch2 = self.make_branch('2') |
|
775 |
try: |
|
776 |
branch.bind(branch2) |
|
777 |
except errors.UpgradeRequired: |
|
3099.1.1
by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry |
778 |
raise tests.TestNotApplicable('Format does not support binding') |
2230.3.7
by Aaron Bentley
Fix binding return values |
779 |
self.assertTrue(branch.unbind()) |
780 |
self.assertFalse(branch.unbind()) |
|
2230.3.6
by Aaron Bentley
work in progress bind stuff |
781 |
self.assertIs(None, branch.get_bound_location()) |
2230.3.31
by Aaron Bentley
Implement re-binding previously-bound branches |
782 |
|
783 |
def test_old_bound_location(self): |
|
784 |
branch = self.make_branch('branch1') |
|
785 |
try: |
|
786 |
self.assertIs(None, branch.get_old_bound_location()) |
|
787 |
except errors.UpgradeRequired: |
|
3099.1.1
by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry |
788 |
raise tests.TestNotApplicable( |
789 |
'Format does not store old bound locations') |
|
2230.3.31
by Aaron Bentley
Implement re-binding previously-bound branches |
790 |
branch2 = self.make_branch('branch2') |
791 |
branch.bind(branch2) |
|
792 |
self.assertIs(None, branch.get_old_bound_location()) |
|
793 |
branch.unbind() |
|
794 |
self.assertContainsRe(branch.get_old_bound_location(), '\/branch2\/$') |
|
2230.3.32
by Aaron Bentley
Implement strict history policy |
795 |
|
3099.1.1
by John Arbash Meinel
Fix bug #175337, bzr bind shouldn't check the ancestry |
796 |
def test_bind_diverged(self): |
797 |
tree_a = self.make_branch_and_tree('tree_a') |
|
798 |
tree_a.commit('rev1a') |
|
799 |
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree() |
|
800 |
tree_a.commit('rev2a') |
|
801 |
tree_b.commit('rev2b') |
|
802 |
try: |
|
803 |
tree_b.branch.bind(tree_a.branch) |
|
804 |
except errors.UpgradeRequired: |
|
805 |
raise tests.TestNotApplicable('Format does not support binding') |
|
806 |
||
5609.25.5
by Andrew Bennetts
Add tests that get_master_branch isn't cached when it shouldn't be, and fix a bug that reveals. |
807 |
def test_unbind_clears_cached_master_branch(self): |
5609.25.6
by Andrew Bennetts
Docstring tweaks. |
808 |
"""b.unbind clears any cached value of b.get_master_branch."""
|
5609.25.5
by Andrew Bennetts
Add tests that get_master_branch isn't cached when it shouldn't be, and fix a bug that reveals. |
809 |
master = self.make_branch('master') |
810 |
branch = self.make_branch('branch') |
|
811 |
try: |
|
812 |
branch.bind(master) |
|
813 |
except errors.UpgradeRequired: |
|
814 |
raise tests.TestNotApplicable('Format does not support binding') |
|
815 |
self.addCleanup(branch.lock_write().unlock) |
|
816 |
self.assertNotEqual(None, branch.get_master_branch()) |
|
817 |
branch.unbind() |
|
818 |
self.assertEqual(None, branch.get_master_branch()) |
|
819 |
||
820 |
def test_unlocked_does_not_cache_master_branch(self): |
|
821 |
"""Unlocked branches do not cache the result of get_master_branch."""
|
|
822 |
master = self.make_branch('master') |
|
823 |
branch1 = self.make_branch('branch') |
|
824 |
try: |
|
825 |
branch1.bind(master) |
|
826 |
except errors.UpgradeRequired: |
|
827 |
raise tests.TestNotApplicable('Format does not support binding') |
|
828 |
# Open branch1 again
|
|
829 |
branch2 = branch1.bzrdir.open_branch() |
|
830 |
self.assertNotEqual(None, branch1.get_master_branch()) |
|
831 |
# Unbind the branch via branch2. branch1 isn't locked so will
|
|
832 |
# immediately return the new value for get_master_branch.
|
|
833 |
branch2.unbind() |
|
834 |
self.assertEqual(None, branch1.get_master_branch()) |
|
835 |
||
836 |
def test_bind_clears_cached_master_branch(self): |
|
5609.25.6
by Andrew Bennetts
Docstring tweaks. |
837 |
"""b.bind clears any cached value of b.get_master_branch."""
|
5609.25.5
by Andrew Bennetts
Add tests that get_master_branch isn't cached when it shouldn't be, and fix a bug that reveals. |
838 |
master1 = self.make_branch('master1') |
839 |
master2 = self.make_branch('master2') |
|
840 |
branch = self.make_branch('branch') |
|
841 |
try: |
|
842 |
branch.bind(master1) |
|
843 |
except errors.UpgradeRequired: |
|
844 |
raise tests.TestNotApplicable('Format does not support binding') |
|
845 |
self.addCleanup(branch.lock_write().unlock) |
|
846 |
self.assertNotEqual(None, branch.get_master_branch()) |
|
847 |
branch.bind(master2) |
|
848 |
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'), |
|
849 |
branch.get_master_branch().base)) |
|
850 |
||
851 |
def test_set_bound_location_clears_cached_master_branch(self): |
|
5609.25.6
by Andrew Bennetts
Docstring tweaks. |
852 |
"""b.set_bound_location clears any cached value of b.get_master_branch.
|
5609.25.5
by Andrew Bennetts
Add tests that get_master_branch isn't cached when it shouldn't be, and fix a bug that reveals. |
853 |
"""
|
854 |
master1 = self.make_branch('master1') |
|
855 |
master2 = self.make_branch('master2') |
|
856 |
branch = self.make_branch('branch') |
|
857 |
try: |
|
858 |
branch.bind(master1) |
|
859 |
except errors.UpgradeRequired: |
|
860 |
raise tests.TestNotApplicable('Format does not support binding') |
|
861 |
self.addCleanup(branch.lock_write().unlock) |
|
862 |
self.assertNotEqual(None, branch.get_master_branch()) |
|
863 |
branch.set_bound_location(self.get_url('master2')) |
|
864 |
self.assertEqual('.', urlutils.relative_url(self.get_url('master2'), |
|
865 |
branch.get_master_branch().base)) |
|
866 |
||
2230.3.32
by Aaron Bentley
Implement strict history policy |
867 |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
868 |
class TestStrict(per_branch.TestCaseWithBranch): |
2230.3.32
by Aaron Bentley
Implement strict history policy |
869 |
|
870 |
def test_strict_history(self): |
|
871 |
tree1 = self.make_branch_and_tree('tree1') |
|
872 |
try: |
|
2230.3.40
by Aaron Bentley
Rename strict_revision_history to append_revisions_only |
873 |
tree1.branch.set_append_revisions_only(True) |
2230.3.32
by Aaron Bentley
Implement strict history policy |
874 |
except errors.UpgradeRequired: |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
875 |
raise tests.TestSkipped('Format does not support strict history') |
2230.3.32
by Aaron Bentley
Implement strict history policy |
876 |
tree1.commit('empty commit') |
877 |
tree2 = tree1.bzrdir.sprout('tree2').open_workingtree() |
|
878 |
tree2.commit('empty commit 2') |
|
879 |
tree1.pull(tree2.branch) |
|
880 |
tree1.commit('empty commit 3') |
|
881 |
tree2.commit('empty commit 4') |
|
882 |
self.assertRaises(errors.DivergedBranches, tree1.pull, tree2.branch) |
|
883 |
tree2.merge_from_branch(tree1.branch) |
|
884 |
tree2.commit('empty commit 5') |
|
2230.3.40
by Aaron Bentley
Rename strict_revision_history to append_revisions_only |
885 |
self.assertRaises(errors.AppendRevisionsOnlyViolation, tree1.pull, |
2230.3.32
by Aaron Bentley
Implement strict history policy |
886 |
tree2.branch) |
887 |
tree3 = tree1.bzrdir.sprout('tree3').open_workingtree() |
|
888 |
tree3.merge_from_branch(tree2.branch) |
|
889 |
tree3.commit('empty commit 6') |
|
890 |
tree2.pull(tree3.branch) |
|
4160.2.13
by Andrew Bennetts
Add some tests for ignore_fallbacks. |
891 |
|
892 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
893 |
class TestIgnoreFallbacksParameter(per_branch.TestCaseWithBranch): |
4160.2.13
by Andrew Bennetts
Add some tests for ignore_fallbacks. |
894 |
|
895 |
def make_branch_with_fallback(self): |
|
896 |
fallback = self.make_branch('fallback') |
|
897 |
if not fallback._format.supports_stacking(): |
|
898 |
raise tests.TestNotApplicable("format does not support stacking") |
|
899 |
stacked = self.make_branch('stacked') |
|
900 |
stacked.set_stacked_on_url(fallback.base) |
|
901 |
return stacked |
|
902 |
||
903 |
def test_fallbacks_not_opened(self): |
|
904 |
stacked = self.make_branch_with_fallback() |
|
905 |
self.get_transport('').rename('fallback', 'moved') |
|
6155.6.14
by Jelmer Vernooij
Fix reopening of remote dirs. |
906 |
reopened_dir = bzrdir.BzrDir.open(stacked.base) |
907 |
reopened = reopened_dir.open_branch(ignore_fallbacks=True) |
|
4160.2.13
by Andrew Bennetts
Add some tests for ignore_fallbacks. |
908 |
self.assertEqual([], reopened.repository._fallback_repositories) |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
909 |
|
4160.2.13
by Andrew Bennetts
Add some tests for ignore_fallbacks. |
910 |
def test_fallbacks_are_opened(self): |
911 |
stacked = self.make_branch_with_fallback() |
|
6155.6.14
by Jelmer Vernooij
Fix reopening of remote dirs. |
912 |
reopened_dir = bzrdir.BzrDir.open(stacked.base) |
913 |
reopened = reopened_dir.open_branch(ignore_fallbacks=False) |
|
4160.2.13
by Andrew Bennetts
Add some tests for ignore_fallbacks. |
914 |
self.assertLength(1, reopened.repository._fallback_repositories) |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
915 |
|
916 |
||
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
917 |
class TestReferenceLocation(per_branch.TestCaseWithBranch): |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
918 |
|
919 |
def test_reference_parent(self): |
|
920 |
tree = self.make_branch_and_tree('tree') |
|
921 |
subtree = self.make_branch_and_tree('tree/subtree') |
|
922 |
subtree.set_root_id('subtree-id') |
|
923 |
try: |
|
924 |
tree.add_reference(subtree) |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
925 |
except errors.UnsupportedOperation: |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
926 |
raise tests.TestNotApplicable('Tree cannot hold references.') |
927 |
reference_parent = tree.branch.reference_parent('subtree-id', |
|
928 |
'subtree') |
|
929 |
self.assertEqual(subtree.branch.base, reference_parent.base) |
|
930 |
||
4273.1.4
by Aaron Bentley
Relative reference locations are branch-relative. |
931 |
def test_reference_parent_accepts_possible_transports(self): |
932 |
tree = self.make_branch_and_tree('tree') |
|
933 |
subtree = self.make_branch_and_tree('tree/subtree') |
|
934 |
subtree.set_root_id('subtree-id') |
|
935 |
try: |
|
936 |
tree.add_reference(subtree) |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
937 |
except errors.UnsupportedOperation: |
4273.1.4
by Aaron Bentley
Relative reference locations are branch-relative. |
938 |
raise tests.TestNotApplicable('Tree cannot hold references.') |
939 |
reference_parent = tree.branch.reference_parent('subtree-id', |
|
940 |
'subtree', possible_transports=[subtree.bzrdir.root_transport]) |
|
941 |
||
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
942 |
def test_get_reference_info(self): |
943 |
branch = self.make_branch('branch') |
|
944 |
try: |
|
945 |
path, loc = branch.get_reference_info('file-id') |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
946 |
except errors.UnsupportedOperation: |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
947 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
948 |
self.assertIs(None, path) |
|
949 |
self.assertIs(None, loc) |
|
950 |
||
951 |
def test_set_reference_info(self): |
|
952 |
branch = self.make_branch('branch') |
|
953 |
try: |
|
954 |
branch.set_reference_info('file-id', 'path/to/location', |
|
955 |
'path/to/file') |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
956 |
except errors.UnsupportedOperation: |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
957 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
958 |
||
959 |
def test_set_get_reference_info(self): |
|
960 |
branch = self.make_branch('branch') |
|
961 |
try: |
|
962 |
branch.set_reference_info('file-id', 'path/to/file', |
|
963 |
'path/to/location') |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
964 |
except errors.UnsupportedOperation: |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
965 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
966 |
# Create a new instance to ensure storage is permanent
|
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
967 |
branch = _mod_branch.Branch.open('branch') |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
968 |
tree_path, branch_location = branch.get_reference_info('file-id') |
969 |
self.assertEqual('path/to/location', branch_location) |
|
970 |
||
971 |
def test_set_null_reference_info(self): |
|
972 |
branch = self.make_branch('branch') |
|
973 |
try: |
|
974 |
branch.set_reference_info('file-id', 'path/to/file', |
|
975 |
'path/to/location') |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
976 |
except errors.UnsupportedOperation: |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
977 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
978 |
branch.set_reference_info('file-id', None, None) |
|
979 |
tree_path, branch_location = branch.get_reference_info('file-id') |
|
980 |
self.assertIs(None, tree_path) |
|
981 |
self.assertIs(None, branch_location) |
|
982 |
||
983 |
def test_set_null_reference_info_when_null(self): |
|
984 |
branch = self.make_branch('branch') |
|
985 |
try: |
|
986 |
tree_path, branch_location = branch.get_reference_info('file-id') |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
987 |
except errors.UnsupportedOperation: |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
988 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
989 |
self.assertIs(None, tree_path) |
|
990 |
self.assertIs(None, branch_location) |
|
991 |
branch.set_reference_info('file-id', None, None) |
|
992 |
||
993 |
def test_set_null_requires_two_nones(self): |
|
994 |
branch = self.make_branch('branch') |
|
995 |
try: |
|
996 |
e = self.assertRaises(ValueError, branch.set_reference_info, |
|
997 |
'file-id', 'path', None) |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
998 |
except errors.UnsupportedOperation: |
4273.1.1
by Aaron Bentley
Implement branch format for tree references. |
999 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
1000 |
self.assertEqual('tree_path must be None when branch_location is' |
|
1001 |
' None.', str(e)) |
|
1002 |
e = self.assertRaises(ValueError, branch.set_reference_info, |
|
1003 |
'file-id', None, 'location') |
|
1004 |
self.assertEqual('branch_location must be None when tree_path is' |
|
1005 |
' None.', str(e)) |
|
4273.1.2
by Aaron Bentley
Use reference_info to get reference_parent. |
1006 |
|
4273.1.7
by Aaron Bentley
Make update_references do a merge. |
1007 |
def make_branch_with_reference(self, location, reference_location, |
1008 |
file_id='file-id'): |
|
1009 |
branch = self.make_branch(location) |
|
4273.1.2
by Aaron Bentley
Use reference_info to get reference_parent. |
1010 |
try: |
4273.1.7
by Aaron Bentley
Make update_references do a merge. |
1011 |
branch.set_reference_info(file_id, 'path/to/file', |
4273.1.5
by Aaron Bentley
Ensure references are propagated by sprout/clone. |
1012 |
reference_location) |
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
1013 |
except errors.UnsupportedOperation: |
4273.1.2
by Aaron Bentley
Use reference_info to get reference_parent. |
1014 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
4273.1.5
by Aaron Bentley
Ensure references are propagated by sprout/clone. |
1015 |
return branch |
1016 |
||
1017 |
def test_reference_parent_from_reference_info_(self): |
|
1018 |
referenced_branch = self.make_branch('reference_branch') |
|
1019 |
branch = self.make_branch_with_reference('branch', |
|
1020 |
referenced_branch.base) |
|
4273.1.2
by Aaron Bentley
Use reference_info to get reference_parent. |
1021 |
parent = branch.reference_parent('file-id', 'path/to/file') |
4273.1.3
by Aaron Bentley
Use branch-relative paths to references. |
1022 |
self.assertEqual(parent.base, referenced_branch.base) |
1023 |
||
1024 |
def test_branch_relative_reference_location(self): |
|
1025 |
branch = self.make_branch('branch') |
|
1026 |
try: |
|
1027 |
branch.set_reference_info('file-id', 'path/to/file', |
|
1028 |
'../reference_branch') |
|
5010.2.4
by Vincent Ladeuil
Fix per_branch/test_branch.py imports. |
1029 |
except errors.UnsupportedOperation: |
4273.1.3
by Aaron Bentley
Use branch-relative paths to references. |
1030 |
raise tests.TestNotApplicable('Branch cannot hold references.') |
1031 |
referenced_branch = self.make_branch('reference_branch') |
|
1032 |
parent = branch.reference_parent('file-id', 'path/to/file') |
|
1033 |
self.assertEqual(parent.base, referenced_branch.base) |
|
4273.1.5
by Aaron Bentley
Ensure references are propagated by sprout/clone. |
1034 |
|
1035 |
def test_sprout_copies_reference_location(self): |
|
4273.1.6
by Aaron Bentley
Ensure references are rebased. |
1036 |
branch = self.make_branch_with_reference('branch', '../reference') |
4273.1.5
by Aaron Bentley
Ensure references are propagated by sprout/clone. |
1037 |
new_branch = branch.bzrdir.sprout('new-branch').open_branch() |
4273.1.6
by Aaron Bentley
Ensure references are rebased. |
1038 |
self.assertEqual('../reference', |
4273.1.5
by Aaron Bentley
Ensure references are propagated by sprout/clone. |
1039 |
new_branch.get_reference_info('file-id')[1]) |
1040 |
||
1041 |
def test_clone_copies_reference_location(self): |
|
4273.1.6
by Aaron Bentley
Ensure references are rebased. |
1042 |
branch = self.make_branch_with_reference('branch', '../reference') |
4273.1.5
by Aaron Bentley
Ensure references are propagated by sprout/clone. |
1043 |
new_branch = branch.bzrdir.clone('new-branch').open_branch() |
4273.1.6
by Aaron Bentley
Ensure references are rebased. |
1044 |
self.assertEqual('../reference', |
1045 |
new_branch.get_reference_info('file-id')[1]) |
|
1046 |
||
1047 |
def test_copied_locations_are_rebased(self): |
|
1048 |
branch = self.make_branch_with_reference('branch', 'reference') |
|
1049 |
new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch() |
|
1050 |
self.assertEqual('../reference', |
|
4273.1.5
by Aaron Bentley
Ensure references are propagated by sprout/clone. |
1051 |
new_branch.get_reference_info('file-id')[1]) |
4273.1.7
by Aaron Bentley
Make update_references do a merge. |
1052 |
|
1053 |
def test_update_references_retains_old_references(self): |
|
1054 |
branch = self.make_branch_with_reference('branch', 'reference') |
|
1055 |
new_branch = self.make_branch_with_reference( |
|
1056 |
'new_branch', 'reference', 'file-id2') |
|
1057 |
new_branch.update_references(branch) |
|
1058 |
self.assertEqual('reference', |
|
1059 |
branch.get_reference_info('file-id')[1]) |
|
1060 |
||
1061 |
def test_update_references_retains_known_references(self): |
|
1062 |
branch = self.make_branch_with_reference('branch', 'reference') |
|
1063 |
new_branch = self.make_branch_with_reference( |
|
1064 |
'new_branch', 'reference2') |
|
1065 |
new_branch.update_references(branch) |
|
1066 |
self.assertEqual('reference', |
|
1067 |
branch.get_reference_info('file-id')[1]) |
|
1068 |
||
4273.1.14
by Aaron Bentley
Restore disabled test |
1069 |
def test_update_references_skips_known_references(self): |
4273.1.7
by Aaron Bentley
Make update_references do a merge. |
1070 |
branch = self.make_branch_with_reference('branch', 'reference') |
1071 |
new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch() |
|
1072 |
new_branch.set_reference_info('file-id', '../foo', '../foo') |
|
1073 |
new_branch.update_references(branch) |
|
4273.1.14
by Aaron Bentley
Restore disabled test |
1074 |
self.assertEqual('reference', |
4273.1.7
by Aaron Bentley
Make update_references do a merge. |
1075 |
branch.get_reference_info('file-id')[1]) |
4273.1.8
by Aaron Bentley
Handle references in push, pull, merge. |
1076 |
|
1077 |
def test_pull_updates_references(self): |
|
1078 |
branch = self.make_branch_with_reference('branch', 'reference') |
|
1079 |
new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch() |
|
1080 |
new_branch.set_reference_info('file-id2', '../foo', '../foo') |
|
1081 |
branch.pull(new_branch) |
|
1082 |
self.assertEqual('foo', |
|
1083 |
branch.get_reference_info('file-id2')[1]) |
|
1084 |
||
1085 |
def test_push_updates_references(self): |
|
1086 |
branch = self.make_branch_with_reference('branch', 'reference') |
|
1087 |
new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch() |
|
1088 |
new_branch.set_reference_info('file-id2', '../foo', '../foo') |
|
1089 |
new_branch.push(branch) |
|
1090 |
self.assertEqual('foo', |
|
1091 |
branch.get_reference_info('file-id2')[1]) |
|
1092 |
||
1093 |
def test_merge_updates_references(self): |
|
1094 |
branch = self.make_branch_with_reference('branch', 'reference') |
|
1095 |
tree = self.make_branch_and_tree('tree') |
|
1096 |
tree.commit('foo') |
|
1097 |
branch.pull(tree.branch) |
|
1098 |
checkout = branch.create_checkout('checkout', lightweight=True) |
|
1099 |
checkout.commit('bar') |
|
1100 |
tree.lock_write() |
|
1101 |
self.addCleanup(tree.unlock) |
|
1102 |
merger = merge.Merger.from_revision_ids(None, tree, |
|
1103 |
branch.last_revision(), |
|
1104 |
other_branch=branch) |
|
1105 |
merger.merge_type = merge.Merge3Merger |
|
1106 |
merger.do_merge() |
|
1107 |
self.assertEqual('../branch/reference', |
|
1108 |
tree.branch.get_reference_info('file-id')[1]) |
|
5158.6.2
by Martin Pool
Branch provides user_url etc |
1109 |
|
1110 |
||
1111 |
class TestBranchControlComponent(per_branch.TestCaseWithBranch): |
|
1112 |
"""Branch implementations adequately implement ControlComponent."""
|
|
6155.2.2
by Vincent Ladeuil
Add a smoke test as suggested in review. |
1113 |
|
5158.6.2
by Martin Pool
Branch provides user_url etc |
1114 |
def test_urls(self): |
1115 |
br = self.make_branch('branch') |
|
1116 |
self.assertIsInstance(br.user_url, str) |
|
1117 |
self.assertEqual(br.user_url, br.user_transport.base) |
|
1118 |
# for all current bzrdir implementations the user dir must be
|
|
1119 |
# above the control dir but we might need to relax that?
|
|
1120 |
self.assertEqual(br.control_url.find(br.user_url), 0) |
|
1121 |
self.assertEqual(br.control_url, br.control_transport.base) |