13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Tests for Branch.get_stacked_on_url and set_stacked_on_url."""
58
58
except unstackable_format_errors:
59
59
# if the set failed, so must the get
60
60
self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
61
self.assertFalse(branch._format.supports_stacking())
63
self.assertTrue(branch._format.supports_stacking())
62
64
# now we have a stacked branch:
63
65
self.assertEqual(target.base, branch.get_stacked_on_url())
64
66
branch.set_stacked_on_url(None)
124
126
self.assertRevisionNotInRepository('mainline', new_branch_revid)
125
127
self.assertRevisionInRepository('newbranch', new_branch_revid)
127
# XXX: this helper probably belongs on TestCaseWithTransport
128
def make_smart_server(self, path):
129
smart_server = server.SmartTCPServer_for_testing()
130
smart_server.setUp(self.get_server())
131
remote_transport = get_transport(smart_server.get_url()).clone(path)
132
self.addCleanup(smart_server.tearDown)
133
return remote_transport
135
129
def test_sprout_stacked_from_smart_server(self):
136
130
if isinstance(self.branch_format, branch.BzrBranchFormat4):
137
131
raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
252
246
parent_bzrdir.get_config().set_default_stack_on('stack-on')
253
247
source = self.make_branch('source')
254
248
target = source.bzrdir.sprout('target').open_branch()
249
if self.branch_format.supports_stacking():
256
250
self.assertEqual('../stack-on', target.get_stacked_on_url())
257
except errors.UnstackableBranchFormat:
253
errors.UnstackableBranchFormat, target.get_stacked_on_url)
260
255
def test_clone_stacking_policy_handling(self):
261
256
"""Obey policy where possible, ignore otherwise."""
264
259
parent_bzrdir.get_config().set_default_stack_on('stack-on')
265
260
source = self.make_branch('source')
266
261
target = source.bzrdir.clone('target').open_branch()
268
self.assertEqual('../stack-on', target.get_stacked_on_url())
269
except errors.UnstackableBranchFormat:
262
if self.branch_format.supports_stacking():
263
self.assertEqual('../stack-on', target.get_stacked_on_url())
266
errors.UnstackableBranchFormat, target.get_stacked_on_url)
268
def test_sprout_to_smart_server_stacking_policy_handling(self):
269
"""Obey policy where possible, ignore otherwise."""
270
if isinstance(self.branch_format, branch.BzrBranchFormat4):
271
raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
272
stack_on = self.make_branch('stack-on')
273
parent_bzrdir = self.make_bzrdir('.', format='default')
274
parent_bzrdir.get_config().set_default_stack_on('stack-on')
275
source = self.make_branch('source')
276
url = self.make_smart_server('target').base
277
target = source.bzrdir.sprout(url).open_branch()
278
if self.branch_format.supports_stacking():
279
self.assertEqual('../stack-on', target.get_stacked_on_url())
282
errors.UnstackableBranchFormat, target.get_stacked_on_url)
272
284
def prepare_stacked_on_fetch(self):
273
285
stack_on = self.make_branch_and_tree('stack-on')