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) 2008-2012, 2016 Canonical Ltd
|
|
3221.11.3
by Robert Collins
Add missing test script. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
3221.11.3
by Robert Collins
Add missing test script. |
16 |
|
|
3537.3.3
by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url |
17 |
"""Tests for Branch.get_stacked_on_url and set_stacked_on_url."""
|
|
3221.11.3
by Robert Collins
Add missing test script. |
18 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
19 |
from breezy import ( |
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
20 |
branch as _mod_branch, |
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
21 |
controldir, |
|
4332.3.35
by Robert Collins
Fix failing tests. |
22 |
check, |
|
3517.4.12
by Martin Pool
Clearer per-branch-format tests for stacking |
23 |
errors, |
24 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
25 |
from breezy.revision import NULL_REVISION |
26 |
from breezy.tests import fixtures, TestNotApplicable, transport_util |
|
27 |
from breezy.tests.per_branch import TestCaseWithBranch |
|
|
3221.11.3
by Robert Collins
Add missing test script. |
28 |
|
29 |
||
|
3928.3.3
by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors' |
30 |
unstackable_format_errors = ( |
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
31 |
_mod_branch.UnstackableBranchFormat, |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
32 |
errors.UnstackableRepositoryFormat, |
33 |
)
|
|
34 |
||
35 |
||
|
3221.11.3
by Robert Collins
Add missing test script. |
36 |
class TestStacking(TestCaseWithBranch): |
37 |
||
|
3830.3.16
by Martin Pool
Add passing tests for iter_lines_added_or_present in stacked repos |
38 |
def check_lines_added_or_present(self, stacked_branch, revid): |
39 |
# similar to a failure seen in bug 288751 by mbp 20081120
|
|
40 |
stacked_repo = stacked_branch.repository |
|
41 |
stacked_repo.lock_read() |
|
42 |
try: |
|
43 |
list(stacked_repo.inventories.iter_lines_added_or_present_in_keys( |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
44 |
[(revid,)])) |
|
3830.3.16
by Martin Pool
Add passing tests for iter_lines_added_or_present in stacked repos |
45 |
finally: |
46 |
stacked_repo.unlock() |
|
47 |
||
|
3537.3.3
by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url |
48 |
def test_get_set_stacked_on_url(self): |
|
3221.11.3
by Robert Collins
Add missing test script. |
49 |
# branches must either:
|
50 |
# raise UnstackableBranchFormat or
|
|
51 |
# raise UnstackableRepositoryFormat or
|
|
52 |
# permit stacking to be done and then return the stacked location.
|
|
53 |
branch = self.make_branch('branch') |
|
54 |
target = self.make_branch('target') |
|
55 |
try: |
|
|
3537.3.3
by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url |
56 |
branch.set_stacked_on_url(target.base) |
|
3928.3.3
by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors' |
57 |
except unstackable_format_errors: |
|
3221.11.3
by Robert Collins
Add missing test script. |
58 |
# if the set failed, so must the get
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
59 |
self.assertRaises(unstackable_format_errors, |
60 |
branch.get_stacked_on_url) |
|
|
4103.2.3
by Andrew Bennetts
Other tests for good luck. |
61 |
self.assertFalse(branch._format.supports_stacking()) |
|
3221.11.3
by Robert Collins
Add missing test script. |
62 |
return
|
|
4103.2.3
by Andrew Bennetts
Other tests for good luck. |
63 |
self.assertTrue(branch._format.supports_stacking()) |
|
3221.11.3
by Robert Collins
Add missing test script. |
64 |
# now we have a stacked branch:
|
|
3537.3.1
by Martin Pool
Rename branch.get_stacked_on to get_stacked_on_url |
65 |
self.assertEqual(target.base, branch.get_stacked_on_url()) |
|
3537.3.3
by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url |
66 |
branch.set_stacked_on_url(None) |
|
3537.3.1
by Martin Pool
Rename branch.get_stacked_on to get_stacked_on_url |
67 |
self.assertRaises(errors.NotStacked, branch.get_stacked_on_url) |
|
3221.13.2
by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery. |
68 |
|
|
3242.5.1
by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs. |
69 |
def test_get_set_stacked_on_relative(self): |
70 |
# Branches can be stacked on other branches using relative paths.
|
|
71 |
branch = self.make_branch('branch') |
|
72 |
target = self.make_branch('target') |
|
73 |
try: |
|
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
74 |
branch.set_stacked_on_url('../target') |
|
3928.3.3
by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors' |
75 |
except unstackable_format_errors: |
|
3242.5.1
by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs. |
76 |
# if the set failed, so must the get
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
77 |
self.assertRaises(unstackable_format_errors, |
78 |
branch.get_stacked_on_url) |
|
|
3242.5.1
by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs. |
79 |
return
|
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
80 |
self.assertEqual('../target', branch.get_stacked_on_url()) |
|
3242.5.1
by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs. |
81 |
|
|
4462.3.2
by Robert Collins
Do not stack on the same branch/repository anymore. This was never supported and would generally result in infinite recursion. Fixes bug 376243. |
82 |
def test_set_stacked_on_same_branch_raises(self): |
83 |
# Stacking on the same branch silently raises and doesn't execute the
|
|
84 |
# change. Reported in bug 376243.
|
|
85 |
branch = self.make_branch('branch') |
|
86 |
try: |
|
87 |
self.assertRaises(errors.UnstackableLocationError, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
88 |
branch.set_stacked_on_url, '../branch') |
|
4462.3.2
by Robert Collins
Do not stack on the same branch/repository anymore. This was never supported and would generally result in infinite recursion. Fixes bug 376243. |
89 |
except unstackable_format_errors: |
90 |
# if the set failed, so must the get
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
91 |
self.assertRaises(unstackable_format_errors, |
92 |
branch.get_stacked_on_url) |
|
|
4462.3.2
by Robert Collins
Do not stack on the same branch/repository anymore. This was never supported and would generally result in infinite recursion. Fixes bug 376243. |
93 |
return
|
94 |
self.assertRaises(errors.NotStacked, branch.get_stacked_on_url) |
|
95 |
||
96 |
def test_set_stacked_on_same_branch_after_being_stacked_raises(self): |
|
97 |
# Stacking on the same branch silently raises and doesn't execute the
|
|
98 |
# change.
|
|
99 |
branch = self.make_branch('branch') |
|
100 |
target = self.make_branch('target') |
|
101 |
try: |
|
102 |
branch.set_stacked_on_url('../target') |
|
103 |
except unstackable_format_errors: |
|
104 |
# if the set failed, so must the get
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
105 |
self.assertRaises(unstackable_format_errors, |
106 |
branch.get_stacked_on_url) |
|
|
4462.3.2
by Robert Collins
Do not stack on the same branch/repository anymore. This was never supported and would generally result in infinite recursion. Fixes bug 376243. |
107 |
return
|
108 |
self.assertRaises(errors.UnstackableLocationError, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
109 |
branch.set_stacked_on_url, '../branch') |
|
4462.3.2
by Robert Collins
Do not stack on the same branch/repository anymore. This was never supported and would generally result in infinite recursion. Fixes bug 376243. |
110 |
self.assertEqual('../target', branch.get_stacked_on_url()) |
111 |
||
|
3517.4.12
by Martin Pool
Clearer per-branch-format tests for stacking |
112 |
def assertRevisionInRepository(self, repo_path, revid): |
113 |
"""Check that a revision is in a repository, disregarding stacking.""" |
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
114 |
repo = controldir.ControlDir.open(repo_path).open_repository() |
|
3517.4.12
by Martin Pool
Clearer per-branch-format tests for stacking |
115 |
self.assertTrue(repo.has_revision(revid)) |
116 |
||
117 |
def assertRevisionNotInRepository(self, repo_path, revid): |
|
118 |
"""Check that a revision is not in a repository, disregarding stacking.""" |
|
|
6472.2.2
by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places. |
119 |
repo = controldir.ControlDir.open(repo_path).open_repository() |
|
3517.4.12
by Martin Pool
Clearer per-branch-format tests for stacking |
120 |
self.assertFalse(repo.has_revision(revid)) |
121 |
||
122 |
def test_get_graph_stacked(self): |
|
123 |
"""A stacked repository shows the graph of its parent.""" |
|
124 |
trunk_tree = self.make_branch_and_tree('mainline') |
|
125 |
trunk_revid = trunk_tree.commit('mainline') |
|
126 |
# make a new branch, and stack on the existing one. we don't use
|
|
127 |
# sprout(stacked=True) here because if that is buggy and copies data
|
|
128 |
# it would cause a false pass of this test.
|
|
129 |
new_branch = self.make_branch('new_branch') |
|
130 |
try: |
|
|
3537.3.3
by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url |
131 |
new_branch.set_stacked_on_url(trunk_tree.branch.base) |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
132 |
except unstackable_format_errors as e: |
|
3517.4.12
by Martin Pool
Clearer per-branch-format tests for stacking |
133 |
raise TestNotApplicable(e) |
134 |
# reading the graph from the stacked branch's repository should see
|
|
135 |
# data from the stacked-on branch
|
|
136 |
new_repo = new_branch.repository |
|
137 |
new_repo.lock_read() |
|
138 |
try: |
|
139 |
self.assertEqual(new_repo.get_parent_map([trunk_revid]), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
140 |
{trunk_revid: (NULL_REVISION, )}) |
|
3517.4.12
by Martin Pool
Clearer per-branch-format tests for stacking |
141 |
finally: |
142 |
new_repo.unlock() |
|
143 |
||
144 |
def test_sprout_stacked(self): |
|
|
3221.13.2
by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery. |
145 |
# We have a mainline
|
146 |
trunk_tree = self.make_branch_and_tree('mainline') |
|
147 |
trunk_revid = trunk_tree.commit('mainline') |
|
|
3221.18.4
by Ian Clatworthy
shallow -> stacked |
148 |
# and make branch from it which is stacked
|
|
3221.13.2
by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery. |
149 |
try: |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
150 |
new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True) |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
151 |
except unstackable_format_errors as e: |
|
3517.4.12
by Martin Pool
Clearer per-branch-format tests for stacking |
152 |
raise TestNotApplicable(e) |
153 |
# stacked repository
|
|
154 |
self.assertRevisionNotInRepository('newbranch', trunk_revid) |
|
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
155 |
tree = new_dir.open_branch().create_checkout('local') |
156 |
new_branch_revid = tree.commit('something local') |
|
|
6182.1.5
by Jelmer Vernooij
Fix more tests. |
157 |
self.assertRevisionNotInRepository( |
158 |
trunk_tree.branch.base, new_branch_revid) |
|
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
159 |
self.assertRevisionInRepository('newbranch', new_branch_revid) |
160 |
||
|
3793.1.2
by Andrew Bennetts
Add test showing that stacking from the smart server works. |
161 |
def test_sprout_stacked_from_smart_server(self): |
162 |
# We have a mainline
|
|
163 |
trunk_tree = self.make_branch_and_tree('mainline') |
|
164 |
trunk_revid = trunk_tree.commit('mainline') |
|
165 |
# Make sure that we can make a stacked branch from it
|
|
166 |
try: |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
167 |
trunk_tree.controldir.sprout('testbranch', stacked=True) |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
168 |
except unstackable_format_errors as e: |
|
3793.1.2
by Andrew Bennetts
Add test showing that stacking from the smart server works. |
169 |
raise TestNotApplicable(e) |
170 |
# Now serve the original mainline from a smart server
|
|
171 |
remote_transport = self.make_smart_server('mainline') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
172 |
remote_bzrdir = controldir.ControlDir.open_from_transport( |
173 |
remote_transport) |
|
|
3793.1.2
by Andrew Bennetts
Add test showing that stacking from the smart server works. |
174 |
# and make branch from the smart server which is stacked
|
175 |
new_dir = remote_bzrdir.sprout('newbranch', stacked=True) |
|
176 |
# stacked repository
|
|
177 |
self.assertRevisionNotInRepository('newbranch', trunk_revid) |
|
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
178 |
tree = new_dir.open_branch().create_checkout('local') |
179 |
new_branch_revid = tree.commit('something local') |
|
|
6182.1.9
by Jelmer Vernooij
More test fixes. |
180 |
self.assertRevisionNotInRepository(trunk_tree.branch.user_url, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
181 |
new_branch_revid) |
|
3793.1.2
by Andrew Bennetts
Add test showing that stacking from the smart server works. |
182 |
self.assertRevisionInRepository('newbranch', new_branch_revid) |
183 |
||
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
184 |
def test_unstack_fetches(self): |
185 |
"""Removing the stacked-on branch pulls across all data""" |
|
|
5651.5.1
by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646) |
186 |
try: |
187 |
builder = self.make_branch_builder('trunk') |
|
188 |
except errors.UninitializableFormat: |
|
189 |
raise TestNotApplicable('uninitializeable format') |
|
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
190 |
# We have a mainline
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
191 |
trunk, mainline_revid, rev2 = fixtures.build_branch_with_non_ancestral_rev( |
192 |
builder) |
|
|
5651.5.1
by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646) |
193 |
# and make branch from it which is stacked (with no tags)
|
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
194 |
try: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
195 |
new_dir = trunk.controldir.sprout( |
196 |
self.get_url('newbranch'), stacked=True) |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
197 |
except unstackable_format_errors as e: |
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
198 |
raise TestNotApplicable(e) |
199 |
# stacked repository
|
|
|
5651.5.1
by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646) |
200 |
self.assertRevisionNotInRepository('newbranch', mainline_revid) |
|
4509.3.17
by Martin Pool
test_unstack_fetches must put the stacked branch on the right transport to test remote formats |
201 |
# TODO: we'd like to commit in the stacked repository; that requires
|
202 |
# some care (maybe a BranchBuilder) if it's remote and has no
|
|
203 |
# workingtree
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
204 |
# newbranch_revid = new_dir.open_workingtree().commit('revision in '
|
205 |
# 'newbranch')
|
|
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
206 |
# now when we unstack that should implicitly fetch, to make sure that
|
207 |
# the branch will still work
|
|
208 |
new_branch = new_dir.open_branch() |
|
|
5651.5.2
by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks. |
209 |
try: |
|
6747.4.1
by Jelmer Vernooij
Fix remaining tests. |
210 |
new_branch.tags.set_tag('tag-a', rev2) |
|
5651.5.2
by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks. |
211 |
except errors.TagsNotSupported: |
212 |
tags_supported = False |
|
213 |
else: |
|
214 |
tags_supported = True |
|
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
215 |
new_branch.set_stacked_on_url(None) |
|
5651.5.1
by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646) |
216 |
self.assertRevisionInRepository('newbranch', mainline_revid) |
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
217 |
# of course it's still in the mainline
|
|
5651.5.1
by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646) |
218 |
self.assertRevisionInRepository('trunk', mainline_revid) |
|
5651.5.2
by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks. |
219 |
if tags_supported: |
220 |
# the tagged revision in trunk is now in newbranch too
|
|
|
6747.4.1
by Jelmer Vernooij
Fix remaining tests. |
221 |
self.assertRevisionInRepository('newbranch', rev2) |
|
3537.3.4
by Martin Pool
Improved branch stacking tests |
222 |
# and now we're no longer stacked
|
|
5651.5.2
by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks. |
223 |
self.assertRaises(errors.NotStacked, new_branch.get_stacked_on_url) |
|
3221.13.2
by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery. |
224 |
|
|
5325.1.4
by Andrew Bennetts
Improve comments. |
225 |
def test_unstack_already_locked(self): |
|
5325.1.1
by Andrew Bennetts
Add failing test. |
226 |
"""Removing the stacked-on branch with an already write-locked branch |
227 |
works.
|
|
228 |
||
229 |
This was bug 551525.
|
|
230 |
"""
|
|
231 |
try: |
|
232 |
stacked_bzrdir = self.make_stacked_bzrdir() |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
233 |
except unstackable_format_errors as e: |
|
5325.1.1
by Andrew Bennetts
Add failing test. |
234 |
raise TestNotApplicable(e) |
235 |
stacked_branch = stacked_bzrdir.open_branch() |
|
236 |
stacked_branch.lock_write() |
|
237 |
stacked_branch.set_stacked_on_url(None) |
|
238 |
stacked_branch.unlock() |
|
239 |
||
|
5325.1.4
by Andrew Bennetts
Improve comments. |
240 |
def test_unstack_already_multiple_locked(self): |
241 |
"""Unstacking a branch preserves the lock count (even though it |
|
242 |
replaces the br.repository object).
|
|
243 |
||
244 |
This is a more extreme variation of test_unstack_already_locked.
|
|
245 |
"""
|
|
|
5325.1.2
by Andrew Bennetts
Add another failing test. |
246 |
try: |
247 |
stacked_bzrdir = self.make_stacked_bzrdir() |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
248 |
except unstackable_format_errors as e: |
|
5325.1.2
by Andrew Bennetts
Add another failing test. |
249 |
raise TestNotApplicable(e) |
250 |
stacked_branch = stacked_bzrdir.open_branch() |
|
251 |
stacked_branch.lock_write() |
|
252 |
stacked_branch.lock_write() |
|
253 |
stacked_branch.lock_write() |
|
254 |
stacked_branch.set_stacked_on_url(None) |
|
255 |
stacked_branch.unlock() |
|
256 |
stacked_branch.unlock() |
|
257 |
stacked_branch.unlock() |
|
258 |
||
|
3567.3.4
by Michael Hudson
make test a lot better |
259 |
def make_stacked_bzrdir(self, in_directory=None): |
|
3567.3.7
by Michael Hudson
better docstring |
260 |
"""Create a stacked branch and return its bzrdir. |
|
3567.3.4
by Michael Hudson
make test a lot better |
261 |
|
262 |
:param in_directory: If not None, create a directory of this
|
|
263 |
name and create the stacking and stacked-on bzrdirs in
|
|
264 |
this directory.
|
|
265 |
"""
|
|
266 |
if in_directory is not None: |
|
267 |
self.get_transport().mkdir(in_directory) |
|
268 |
prefix = in_directory + '/' |
|
269 |
else: |
|
270 |
prefix = '' |
|
271 |
tree = self.make_branch_and_tree(prefix + 'stacked-on') |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
272 |
tree.commit('Added foo') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
273 |
stacked_bzrdir = tree.branch.controldir.sprout( |
|
5325.1.1
by Andrew Bennetts
Add failing test. |
274 |
self.get_url(prefix + 'stacked'), tree.branch.last_revision(), |
275 |
stacked=True) |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
276 |
return stacked_bzrdir |
277 |
||
278 |
def test_clone_from_stacked_branch_preserve_stacking(self): |
|
|
3242.3.24
by Aaron Bentley
Fix test failures |
279 |
# We can clone from the bzrdir of a stacked branch. If
|
280 |
# preserve_stacking is True, the cloned branch is stacked on the
|
|
281 |
# same branch as the original.
|
|
|
3242.3.21
by Jonathan Lange
Preserve stacking in clone |
282 |
try: |
|
3567.3.4
by Michael Hudson
make test a lot better |
283 |
stacked_bzrdir = self.make_stacked_bzrdir() |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
284 |
except unstackable_format_errors as e: |
|
3567.3.5
by Michael Hudson
use TestNotApplicable in all the stacking clone() tests. |
285 |
raise TestNotApplicable(e) |
|
3242.3.24
by Aaron Bentley
Fix test failures |
286 |
cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True) |
|
3242.3.21
by Jonathan Lange
Preserve stacking in clone |
287 |
try: |
288 |
self.assertEqual( |
|
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
289 |
stacked_bzrdir.open_branch().get_stacked_on_url(), |
290 |
cloned_bzrdir.open_branch().get_stacked_on_url()) |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
291 |
except unstackable_format_errors as e: |
|
3242.3.21
by Jonathan Lange
Preserve stacking in clone |
292 |
pass
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
293 |
|
|
3567.3.4
by Michael Hudson
make test a lot better |
294 |
def test_clone_from_branch_stacked_on_relative_url_preserve_stacking(self): |
295 |
# If a branch's stacked-on url is relative, we can still clone
|
|
296 |
# from it with preserve_stacking True and get a branch stacked
|
|
297 |
# on an appropriately adjusted relative url.
|
|
|
3567.3.3
by Michael Hudson
very hackish test |
298 |
try: |
|
3567.3.4
by Michael Hudson
make test a lot better |
299 |
stacked_bzrdir = self.make_stacked_bzrdir(in_directory='dir') |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
300 |
except unstackable_format_errors as e: |
|
3567.3.5
by Michael Hudson
use TestNotApplicable in all the stacking clone() tests. |
301 |
raise TestNotApplicable(e) |
|
3567.3.4
by Michael Hudson
make test a lot better |
302 |
stacked_bzrdir.open_branch().set_stacked_on_url('../stacked-on') |
|
5325.1.6
by Andrew Bennetts
Fix test_clone_from_branch_stacked_on_relative_url_preserve_stacking failure by making it use get_url so that it tests RemoteBranch* cases the same as others. Also remove some unused imports. |
303 |
cloned_bzrdir = stacked_bzrdir.clone( |
304 |
self.get_url('cloned'), preserve_stacking=True) |
|
|
3567.3.4
by Michael Hudson
make test a lot better |
305 |
self.assertEqual( |
306 |
'../dir/stacked-on', |
|
307 |
cloned_bzrdir.open_branch().get_stacked_on_url()) |
|
|
3567.3.3
by Michael Hudson
very hackish test |
308 |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
309 |
def test_clone_from_stacked_branch_no_preserve_stacking(self): |
310 |
try: |
|
|
3567.3.4
by Michael Hudson
make test a lot better |
311 |
stacked_bzrdir = self.make_stacked_bzrdir() |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
312 |
except unstackable_format_errors as e: |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
313 |
# not a testable combination.
|
|
3567.3.5
by Michael Hudson
use TestNotApplicable in all the stacking clone() tests. |
314 |
raise TestNotApplicable(e) |
|
1551.19.46
by Aaron Bentley
Fix fetch from stacked respositories (#248506) |
315 |
cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
316 |
preserve_stacking=False) |
|
3242.3.24
by Aaron Bentley
Fix test failures |
317 |
unstacked_branch = cloned_unstacked_bzrdir.open_branch() |
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
318 |
self.assertRaises((errors.NotStacked, _mod_branch.UnstackableBranchFormat), |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
319 |
unstacked_branch.get_stacked_on_url) |
|
3242.3.37
by Aaron Bentley
Updates from reviews |
320 |
|
321 |
def test_no_op_preserve_stacking(self): |
|
322 |
"""With no stacking, preserve_stacking should be a no-op.""" |
|
323 |
branch = self.make_branch('source') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
324 |
cloned_bzrdir = branch.controldir.clone( |
325 |
'cloned', preserve_stacking=True) |
|
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
326 |
self.assertRaises((errors.NotStacked, _mod_branch.UnstackableBranchFormat), |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
327 |
cloned_bzrdir.open_branch().get_stacked_on_url) |
|
3242.3.37
by Aaron Bentley
Updates from reviews |
328 |
|
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
329 |
def make_stacked_on_matching(self, source): |
330 |
if source.repository.supports_rich_root(): |
|
331 |
if source.repository._format.supports_chks: |
|
332 |
format = "2a" |
|
333 |
else: |
|
334 |
format = "1.9-rich-root" |
|
335 |
else: |
|
336 |
format = "1.9" |
|
337 |
return self.make_branch('stack-on', format) |
|
338 |
||
|
3242.3.37
by Aaron Bentley
Updates from reviews |
339 |
def test_sprout_stacking_policy_handling(self): |
340 |
"""Obey policy where possible, ignore otherwise.""" |
|
|
5673.1.3
by Jelmer Vernooij
Change flexible_components to fixed_components. |
341 |
if self.bzrdir_format.fixed_components: |
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
342 |
raise TestNotApplicable('Branch format 4 does not autoupgrade.') |
343 |
source = self.make_branch('source') |
|
344 |
stack_on = self.make_stacked_on_matching(source) |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
345 |
parent_bzrdir = self.make_controldir('.', format='default') |
|
3242.3.37
by Aaron Bentley
Updates from reviews |
346 |
parent_bzrdir.get_config().set_default_stack_on('stack-on') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
347 |
target = source.controldir.sprout('target').open_branch() |
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
348 |
# When we sprout we upgrade the branch when there is a default stack_on
|
349 |
# set by a config *and* the targeted branch supports stacking.
|
|
350 |
if stack_on._format.supports_stacking(): |
|
|
3641.1.1
by John Arbash Meinel
Merge in 1.6rc5 and revert disabling default stack on policy |
351 |
self.assertEqual('../stack-on', target.get_stacked_on_url()) |
|
4103.2.1
by Andrew Bennetts
Make clone/sprout stacking policy tests a little more precise. |
352 |
else: |
353 |
self.assertRaises( |
|
|
6734.1.11
by Jelmer Vernooij
Move UnstackableBranchFormat. |
354 |
branch.UnstackableBranchFormat, target.get_stacked_on_url) |
|
3242.3.38
by Aaron Bentley
Enhance tests |
355 |
|
356 |
def test_clone_stacking_policy_handling(self): |
|
357 |
"""Obey policy where possible, ignore otherwise.""" |
|
|
5673.1.3
by Jelmer Vernooij
Change flexible_components to fixed_components. |
358 |
if self.bzrdir_format.fixed_components: |
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
359 |
raise TestNotApplicable('Branch format 4 does not autoupgrade.') |
360 |
source = self.make_branch('source') |
|
361 |
stack_on = self.make_stacked_on_matching(source) |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
362 |
parent_bzrdir = self.make_controldir('.', format='default') |
|
3242.3.38
by Aaron Bentley
Enhance tests |
363 |
parent_bzrdir.get_config().set_default_stack_on('stack-on') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
364 |
target = source.controldir.clone('target').open_branch() |
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
365 |
# When we clone we upgrade the branch when there is a default stack_on
|
366 |
# set by a config *and* the targeted branch supports stacking.
|
|
367 |
if stack_on._format.supports_stacking(): |
|
|
3641.1.1
by John Arbash Meinel
Merge in 1.6rc5 and revert disabling default stack on policy |
368 |
self.assertEqual('../stack-on', target.get_stacked_on_url()) |
|
4103.2.1
by Andrew Bennetts
Make clone/sprout stacking policy tests a little more precise. |
369 |
else: |
370 |
self.assertRaises( |
|
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
371 |
_mod_branch.UnstackableBranchFormat, target.get_stacked_on_url) |
|
1551.19.46
by Aaron Bentley
Fix fetch from stacked respositories (#248506) |
372 |
|
|
4103.2.3
by Andrew Bennetts
Other tests for good luck. |
373 |
def test_sprout_to_smart_server_stacking_policy_handling(self): |
374 |
"""Obey policy where possible, ignore otherwise.""" |
|
|
5674.1.1
by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat. |
375 |
if not self.branch_format.supports_leaving_lock(): |
376 |
raise TestNotApplicable('Branch format is not usable via HPSS.') |
|
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
377 |
source = self.make_branch('source') |
378 |
stack_on = self.make_stacked_on_matching(source) |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
379 |
parent_bzrdir = self.make_controldir('.', format='default') |
|
4103.2.3
by Andrew Bennetts
Other tests for good luck. |
380 |
parent_bzrdir.get_config().set_default_stack_on('stack-on') |
381 |
url = self.make_smart_server('target').base |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
382 |
target = source.controldir.sprout(url).open_branch() |
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
383 |
# When we sprout we upgrade the branch when there is a default stack_on
|
384 |
# set by a config *and* the targeted branch supports stacking.
|
|
385 |
if stack_on._format.supports_stacking(): |
|
|
4103.2.3
by Andrew Bennetts
Other tests for good luck. |
386 |
self.assertEqual('../stack-on', target.get_stacked_on_url()) |
387 |
else: |
|
388 |
self.assertRaises( |
|
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
389 |
_mod_branch.UnstackableBranchFormat, target.get_stacked_on_url) |
|
4103.2.3
by Andrew Bennetts
Other tests for good luck. |
390 |
|
|
1551.19.47
by Aaron Bentley
Add test per JAM |
391 |
def prepare_stacked_on_fetch(self): |
|
1551.19.46
by Aaron Bentley
Fix fetch from stacked respositories (#248506) |
392 |
stack_on = self.make_branch_and_tree('stack-on') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
393 |
rev1 = stack_on.commit('first commit') |
|
1551.19.46
by Aaron Bentley
Fix fetch from stacked respositories (#248506) |
394 |
try: |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
395 |
stacked_dir = stack_on.controldir.sprout('stacked', stacked=True) |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
396 |
except unstackable_format_errors as e: |
|
1551.19.46
by Aaron Bentley
Fix fetch from stacked respositories (#248506) |
397 |
raise TestNotApplicable('Format does not support stacking.') |
398 |
unstacked = self.make_repository('unstacked') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
399 |
return stacked_dir.open_workingtree(), unstacked, rev1 |
|
1551.19.47
by Aaron Bentley
Add test per JAM |
400 |
|
401 |
def test_fetch_copies_from_stacked_on(self): |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
402 |
stacked, unstacked, rev1 = self.prepare_stacked_on_fetch() |
403 |
unstacked.fetch(stacked.branch.repository, rev1) |
|
404 |
unstacked.get_revision(rev1) |
|
|
1551.19.47
by Aaron Bentley
Add test per JAM |
405 |
|
406 |
def test_fetch_copies_from_stacked_on_and_stacked(self): |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
407 |
stacked, unstacked, rev1 = self.prepare_stacked_on_fetch() |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
408 |
tree = stacked.branch.create_checkout('local') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
409 |
rev2 = tree.commit('second commit') |
410 |
unstacked.fetch(stacked.branch.repository, rev2) |
|
411 |
unstacked.get_revision(rev1) |
|
412 |
unstacked.get_revision(rev2) |
|
413 |
self.check_lines_added_or_present(stacked.branch, rev1) |
|
414 |
self.check_lines_added_or_present(stacked.branch, rev2) |
|
|
3582.2.1
by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work. |
415 |
|
|
3582.1.8
by Martin Pool
Add test for repeated commits into packed repository |
416 |
def test_autopack_when_stacked(self): |
417 |
# in bzr.dev as of 20080730, autopack was reported to fail in stacked
|
|
418 |
# repositories because of problems with text deltas spanning physical
|
|
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
419 |
# repository boundaries. however, i didn't actually get this test to
|
420 |
# fail on that code. -- mbp
|
|
|
3582.1.11
by Martin Pool
doc |
421 |
# see https://bugs.launchpad.net/bzr/+bug/252821
|
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
422 |
stack_on = self.make_branch_and_tree('stack-on') |
423 |
if not stack_on.branch._format.supports_stacking(): |
|
|
3582.1.8
by Martin Pool
Add test for repeated commits into packed repository |
424 |
raise TestNotApplicable("%r does not support stacking" |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
425 |
% self.branch_format) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
426 |
text_lines = [b'line %d blah blah blah\n' % i for i in range(20)] |
427 |
self.build_tree_contents([('stack-on/a', b''.join(text_lines))]) |
|
|
3582.1.8
by Martin Pool
Add test for repeated commits into packed repository |
428 |
stack_on.add('a') |
429 |
stack_on.commit('base commit') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
430 |
stacked_dir = stack_on.controldir.sprout('stacked', stacked=True) |
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
431 |
stacked_branch = stacked_dir.open_branch() |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
432 |
local_tree = stack_on.controldir.sprout('local').open_workingtree() |
|
3582.1.8
by Martin Pool
Add test for repeated commits into packed repository |
433 |
for i in range(20): |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
434 |
text_lines[0] = b'changed in %d\n' % i |
435 |
self.build_tree_contents([('local/a', b''.join(text_lines))]) |
|
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
436 |
local_tree.commit('commit %d' % i) |
437 |
local_tree.branch.push(stacked_branch) |
|
438 |
stacked_branch.repository.pack() |
|
439 |
check.check_dwim(stacked_branch.base, False, True, True) |
|
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
440 |
|
441 |
def test_pull_delta_when_stacked(self): |
|
442 |
if not self.branch_format.supports_stacking(): |
|
443 |
raise TestNotApplicable("%r does not support stacking" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
444 |
% self.branch_format) |
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
445 |
stack_on = self.make_branch_and_tree('stack-on') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
446 |
text_lines = [b'line %d blah blah blah\n' % i for i in range(20)] |
447 |
self.build_tree_contents([('stack-on/a', b''.join(text_lines))]) |
|
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
448 |
stack_on.add('a') |
449 |
stack_on.commit('base commit') |
|
450 |
# make a stacked branch from the mainline
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
451 |
stacked_dir = stack_on.controldir.sprout('stacked', stacked=True) |
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
452 |
stacked_tree = stacked_dir.open_workingtree() |
453 |
# make a second non-stacked branch from the mainline
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
454 |
other_dir = stack_on.controldir.sprout('other') |
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
455 |
other_tree = other_dir.open_workingtree() |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
456 |
text_lines[9] = b'changed in other\n' |
457 |
self.build_tree_contents([('other/a', b''.join(text_lines))]) |
|
|
3830.3.16
by Martin Pool
Add passing tests for iter_lines_added_or_present in stacked repos |
458 |
stacked_revid = other_tree.commit('commit in other') |
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
459 |
# this should have generated a delta; try to pull that across
|
|
3582.1.15
by Martin Pool
Comments and tests for repository stacking |
460 |
# bug 252821 caused a RevisionNotPresent here...
|
461 |
stacked_tree.pull(other_tree.branch) |
|
|
3582.1.10
by Martin Pool
Add failing tets for pull into stacked repository |
462 |
stacked_tree.branch.repository.pack() |
|
4332.3.35
by Robert Collins
Fix failing tests. |
463 |
check.check_dwim(stacked_tree.branch.base, False, True, True) |
|
3830.3.16
by Martin Pool
Add passing tests for iter_lines_added_or_present in stacked repos |
464 |
self.check_lines_added_or_present(stacked_tree.branch, stacked_revid) |
|
3582.1.12
by Martin Pool
merge from trunk |
465 |
|
|
3582.2.1
by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work. |
466 |
def test_fetch_revisions_with_file_changes(self): |
467 |
# Fetching revisions including file changes into a stacked branch
|
|
468 |
# works without error.
|
|
469 |
# Make the source tree.
|
|
470 |
src_tree = self.make_branch_and_tree('src') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
471 |
self.build_tree_contents([('src/a', b'content')]) |
|
3582.2.1
by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work. |
472 |
src_tree.add('a') |
473 |
src_tree.commit('first commit') |
|
474 |
||
475 |
# Make the stacked-on branch.
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
476 |
src_tree.controldir.sprout('stacked-on') |
|
3582.2.1
by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work. |
477 |
|
478 |
# Make a branch stacked on it.
|
|
479 |
target = self.make_branch('target') |
|
480 |
try: |
|
481 |
target.set_stacked_on_url('../stacked-on') |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
482 |
except unstackable_format_errors as e: |
|
3582.2.1
by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work. |
483 |
raise TestNotApplicable('Format does not support stacking.') |
484 |
||
485 |
# Change the source branch.
|
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
486 |
self.build_tree_contents([('src/a', b'new content')]) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
487 |
rev2 = src_tree.commit('second commit') |
|
3582.2.1
by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work. |
488 |
|
489 |
# Fetch changes to the target.
|
|
490 |
target.fetch(src_tree.branch) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
491 |
rtree = target.repository.revision_tree(rev2) |
|
3582.2.1
by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work. |
492 |
rtree.lock_read() |
493 |
self.addCleanup(rtree.unlock) |
|
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
494 |
self.assertEqual(b'new content', rtree.get_file_text('a')) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
495 |
self.check_lines_added_or_present(target, rev2) |
|
3770.2.1
by Michael Hudson
test and feature |
496 |
|
497 |
def test_transform_fallback_location_hook(self): |
|
498 |
# The 'transform_fallback_location' branch hook allows us to inspect
|
|
499 |
# and transform the URL of the fallback location for the branch.
|
|
500 |
stack_on = self.make_branch('stack-on') |
|
501 |
stacked = self.make_branch('stacked') |
|
502 |
try: |
|
503 |
stacked.set_stacked_on_url('../stack-on') |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
504 |
except unstackable_format_errors as e: |
|
3770.2.1
by Michael Hudson
test and feature |
505 |
raise TestNotApplicable('Format does not support stacking.') |
506 |
self.get_transport().rename('stack-on', 'new-stack-on') |
|
507 |
hook_calls = [] |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
508 |
|
|
3770.2.1
by Michael Hudson
test and feature |
509 |
def hook(stacked_branch, url): |
510 |
hook_calls.append(url) |
|
511 |
return '../new-stack-on' |
|
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
512 |
_mod_branch.Branch.hooks.install_named_hook( |
|
3770.2.1
by Michael Hudson
test and feature |
513 |
'transform_fallback_location', hook, None) |
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
514 |
_mod_branch.Branch.open('stacked') |
|
3770.2.1
by Michael Hudson
test and feature |
515 |
self.assertEqual(['../stack-on'], hook_calls) |
|
3830.2.1
by Aaron Bentley
Fix HPSS with branch stacked on repository branch |
516 |
|
517 |
def test_stack_on_repository_branch(self): |
|
518 |
# Stacking should work when the repo isn't co-located with the
|
|
519 |
# stack-on branch.
|
|
520 |
try: |
|
521 |
repo = self.make_repository('repo', shared=True) |
|
522 |
except errors.IncompatibleFormat: |
|
523 |
raise TestNotApplicable() |
|
|
6145.2.1
by Jelmer Vernooij
Add RepositoryFormat.supports_nesting_repositories. |
524 |
if not repo._format.supports_nesting_repositories: |
525 |
raise TestNotApplicable() |
|
|
3830.2.1
by Aaron Bentley
Fix HPSS with branch stacked on repository branch |
526 |
# Avoid make_branch, which produces standalone branches.
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
527 |
bzrdir = self.make_controldir('repo/stack-on') |
|
3834.5.4
by John Arbash Meinel
Skip the stack_on_repository test for BranchReference branches. |
528 |
try: |
529 |
b = bzrdir.create_branch() |
|
530 |
except errors.UninitializableFormat: |
|
531 |
raise TestNotApplicable() |
|
|
3830.2.1
by Aaron Bentley
Fix HPSS with branch stacked on repository branch |
532 |
transport = self.get_transport('stacked') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
533 |
b.controldir.clone_on_transport(transport, stacked_on=b.base) |
|
3830.2.2
by Aaron Bentley
Add explanatory comment. |
534 |
# Ensure that opening the branch doesn't raise.
|
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
535 |
_mod_branch.Branch.open(transport.base) |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
536 |
|
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
537 |
def test_revision_history_of_stacked(self): |
|
4419.1.6
by Andrew Bennetts
Add comments requested by Martin's review. |
538 |
# See <https://launchpad.net/bugs/380314>.
|
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
539 |
stack_on = self.make_branch_and_tree('stack-on') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
540 |
rev1 = stack_on.commit('first commit') |
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
541 |
try: |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
542 |
stacked_dir = stack_on.controldir.sprout( |
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
543 |
self.get_url('stacked'), stacked=True) |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
544 |
except unstackable_format_errors as e: |
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
545 |
raise TestNotApplicable('Format does not support stacking.') |
546 |
try: |
|
547 |
stacked = stacked_dir.open_workingtree() |
|
548 |
except errors.NoWorkingTree: |
|
549 |
stacked = stacked_dir.open_branch().create_checkout( |
|
550 |
'stacked-checkout', lightweight=True) |
|
|
4595.4.4
by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts. |
551 |
tree = stacked.branch.create_checkout('local') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
552 |
rev2 = tree.commit('second commit') |
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
553 |
# Sanity check: stacked's repo should not contain rev1, otherwise this
|
554 |
# test isn't testing what it's supposed to.
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
555 |
repo = stacked.branch.repository.controldir.open_repository() |
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
556 |
repo.lock_read() |
557 |
self.addCleanup(repo.unlock) |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
558 |
self.assertEqual({}, repo.get_parent_map([rev1])) |
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
559 |
# revision_history should work, even though the history is spread over
|
560 |
# multiple repositories.
|
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
561 |
self.assertEqual((2, rev2), stacked.branch.last_revision_info()) |
|
4419.1.2
by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch. |
562 |
|
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
563 |
|
564 |
class TestStackingConnections( |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
565 |
transport_util.TestCaseWithConnectionHookedTransport): |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
566 |
|
567 |
def setUp(self): |
|
568 |
super(TestStackingConnections, self).setUp() |
|
569 |
try: |
|
570 |
base_tree = self.make_branch_and_tree('base', |
|
571 |
format=self.bzrdir_format) |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
572 |
except errors.UninitializableFormat as e: |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
573 |
raise TestNotApplicable(e) |
574 |
stacked = self.make_branch('stacked', format=self.bzrdir_format) |
|
575 |
try: |
|
576 |
stacked.set_stacked_on_url(base_tree.branch.base) |
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
577 |
except unstackable_format_errors as e: |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
578 |
raise TestNotApplicable(e) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
579 |
self.rev_base = base_tree.commit('first') |
580 |
stacked.set_last_revision_info(1, self.rev_base) |
|
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
581 |
stacked_relative = self.make_branch('stacked_relative', |
582 |
format=self.bzrdir_format) |
|
|
6182.1.12
by Jelmer Vernooij
Fix two more tests. |
583 |
stacked_relative.set_stacked_on_url(base_tree.branch.user_url) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
584 |
stacked.set_last_revision_info(1, self.rev_base) |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
585 |
self.start_logging_connections() |
586 |
||
587 |
def test_open_stacked(self): |
|
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
588 |
b = _mod_branch.Branch.open(self.get_url('stacked')) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
589 |
rev = b.repository.get_revision(self.rev_base) |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
590 |
self.assertEqual(1, len(self.connections)) |
591 |
||
592 |
def test_open_stacked_relative(self): |
|
|
6743
by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more. |
593 |
b = _mod_branch.Branch.open(self.get_url('stacked_relative')) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
594 |
rev = b.repository.get_revision(self.rev_base) |
|
3928.3.1
by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections. |
595 |
self.assertEqual(1, len(self.connections)) |