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