139
141
def test_help_topic(self):
140
142
topics = help_topics.HelpTopicRegistry()
141
topics.register('formats', self.make_format_registry().help_topic,
143
topic = topics.get_detail('formats')
144
new, rest = topic.split('Experimental formats')
143
registry = self.make_format_registry()
144
topics.register('current-formats', registry.help_topic,
146
topics.register('other-formats', registry.help_topic,
148
new = topics.get_detail('current-formats')
149
rest = topics.get_detail('other-formats')
145
150
experimental, deprecated = rest.split('Deprecated formats')
146
self.assertContainsRe(new, 'These formats can be used')
151
self.assertContainsRe(new, 'bzr help formats')
147
152
self.assertContainsRe(new,
148
153
':knit:\n \(native\) \(default\) Format using knits\n')
149
154
self.assertContainsRe(experimental,
460
465
self.assertEqual(child_branch.base,
461
466
new_child.open_branch().get_stacked_on_url())
468
def test_clone_ignores_policy_for_unsupported_formats(self):
469
child_branch, new_child_transport = self.prepare_default_stacking(
470
child_format='pack-0.92')
471
new_child = child_branch.bzrdir.clone_on_transport(new_child_transport)
472
self.assertRaises(errors.UnstackableBranchFormat,
473
new_child.open_branch().get_stacked_on_url)
475
def test_sprout_ignores_policy_for_unsupported_formats(self):
476
child_branch, new_child_transport = self.prepare_default_stacking(
477
child_format='pack-0.92')
478
new_child = child_branch.bzrdir.sprout(new_child_transport.base)
479
self.assertRaises(errors.UnstackableBranchFormat,
480
new_child.open_branch().get_stacked_on_url)
482
def test_sprout_upgrades_format_if_stacked_specified(self):
483
child_branch, new_child_transport = self.prepare_default_stacking(
484
child_format='pack-0.92')
485
new_child = child_branch.bzrdir.sprout(new_child_transport.base,
487
self.assertEqual(child_branch.bzrdir.root_transport.base,
488
new_child.open_branch().get_stacked_on_url())
489
repo = new_child.open_repository()
490
self.assertTrue(repo._format.supports_external_lookups)
491
self.assertFalse(repo.supports_rich_root())
493
def test_clone_on_transport_upgrades_format_if_stacked_on_specified(self):
494
child_branch, new_child_transport = self.prepare_default_stacking(
495
child_format='pack-0.92')
496
new_child = child_branch.bzrdir.clone_on_transport(new_child_transport,
497
stacked_on=child_branch.bzrdir.root_transport.base)
498
self.assertEqual(child_branch.bzrdir.root_transport.base,
499
new_child.open_branch().get_stacked_on_url())
500
repo = new_child.open_repository()
501
self.assertTrue(repo._format.supports_external_lookups)
502
self.assertFalse(repo.supports_rich_root())
504
def test_sprout_upgrades_to_rich_root_format_if_needed(self):
505
child_branch, new_child_transport = self.prepare_default_stacking(
506
child_format='rich-root-pack')
507
new_child = child_branch.bzrdir.sprout(new_child_transport.base,
509
repo = new_child.open_repository()
510
self.assertTrue(repo._format.supports_external_lookups)
511
self.assertTrue(repo.supports_rich_root())
463
513
def test_add_fallback_repo_handles_absolute_urls(self):
464
stack_on = self.make_branch('stack_on', format='development1')
465
repo = self.make_repository('repo', format='development1')
514
stack_on = self.make_branch('stack_on', format='1.6')
515
repo = self.make_repository('repo', format='1.6')
466
516
policy = bzrdir.UseExistingRepository(repo, stack_on.base)
467
517
policy._add_fallback(repo)
469
519
def test_add_fallback_repo_handles_relative_urls(self):
470
stack_on = self.make_branch('stack_on', format='development1')
471
repo = self.make_repository('repo', format='development1')
520
stack_on = self.make_branch('stack_on', format='1.6')
521
repo = self.make_repository('repo', format='1.6')
472
522
policy = bzrdir.UseExistingRepository(repo, '.', stack_on.base)
473
523
policy._add_fallback(repo)
475
525
def test_configure_relative_branch_stacking_url(self):
476
stack_on = self.make_branch('stack_on', format='development1')
477
stacked = self.make_branch('stack_on/stacked', format='development1')
526
stack_on = self.make_branch('stack_on', format='1.6')
527
stacked = self.make_branch('stack_on/stacked', format='1.6')
478
528
policy = bzrdir.UseExistingRepository(stacked.repository,
479
529
'.', stack_on.base)
480
530
policy.configure_branch(stacked)
481
531
self.assertEqual('..', stacked.get_stacked_on_url())
483
533
def test_relative_branch_stacking_to_absolute(self):
484
stack_on = self.make_branch('stack_on', format='development1')
485
stacked = self.make_branch('stack_on/stacked', format='development1')
534
stack_on = self.make_branch('stack_on', format='1.6')
535
stacked = self.make_branch('stack_on/stacked', format='1.6')
486
536
policy = bzrdir.UseExistingRepository(stacked.repository,
487
537
'.', self.get_readonly_url('stack_on'))
488
538
policy.configure_branch(stacked)
1029
1079
run, its implementation being incomplete.
1032
# Should be defined by daughter classes to ensure redirection
1033
# still use the same transport implementation (not currently
1034
# enforced as it's a bit tricky to get right (see the FIXME
1035
# in BzrDir.open_from_transport for the unique use case so
1039
1082
def create_transport_readonly_server(self):
1040
return HTTPServerRedirecting()
1083
return http_utils.HTTPServerRedirecting()
1042
1085
def create_transport_secondary_server(self):
1043
return HTTPServerRedirecting()
1086
return http_utils.HTTPServerRedirecting()
1045
1088
def setUp(self):
1046
# Both servers redirect to each server creating a loop
1047
super(TestHTTPRedirectionLoop, self).setUp()
1089
super(TestHTTPRedirections, self).setUp()
1048
1090
# The redirections will point to the new server
1049
1091
self.new_server = self.get_readonly_server()
1050
1092
# The requests to the old server will be redirected
1051
1093
self.old_server = self.get_secondary_server()
1052
1094
# Configure the redirections
1053
1095
self.old_server.redirect_to(self.new_server.host, self.new_server.port)
1097
def test_loop(self):
1098
# Both servers redirect to each other creating a loop
1054
1099
self.new_server.redirect_to(self.old_server.host, self.old_server.port)
1056
def _qualified_url(self, host, port):
1057
return 'http+%s://%s:%s' % (self._qualifier, host, port)
1059
def test_loop(self):
1060
1100
# Starting from either server should loop
1061
old_url = self._qualified_url(self.old_server.host,
1101
old_url = self._qualified_url(self.old_server.host,
1062
1102
self.old_server.port)
1063
1103
oldt = self._transport(old_url)
1064
1104
self.assertRaises(errors.NotBranchError,
1065
1105
bzrdir.BzrDir.open_from_transport, oldt)
1066
new_url = self._qualified_url(self.new_server.host,
1106
new_url = self._qualified_url(self.new_server.host,
1067
1107
self.new_server.port)
1068
1108
newt = self._transport(new_url)
1069
1109
self.assertRaises(errors.NotBranchError,
1070
1110
bzrdir.BzrDir.open_from_transport, newt)
1073
class TestHTTPRedirections_urllib(TestHTTPRedirectionLoop,
1074
TestCaseWithTwoWebservers):
1112
def test_qualifier_preserved(self):
1113
wt = self.make_branch_and_tree('branch')
1114
old_url = self._qualified_url(self.old_server.host,
1115
self.old_server.port)
1116
start = self._transport(old_url).clone('branch')
1117
bdir = bzrdir.BzrDir.open_from_transport(start)
1118
# Redirection should preserve the qualifier, hence the transport class
1120
self.assertIsInstance(bdir.root_transport, type(start))
1123
class TestHTTPRedirections_urllib(TestHTTPRedirections,
1124
http_utils.TestCaseWithTwoWebservers):
1075
1125
"""Tests redirections for urllib implementation"""
1077
_qualifier = 'urllib'
1078
1127
_transport = HttpTransport_urllib
1129
def _qualified_url(self, host, port):
1130
return 'http+urllib://%s:%s' % (host, port)
1082
1134
class TestHTTPRedirections_pycurl(TestWithTransport_pycurl,
1083
TestHTTPRedirectionLoop,
1084
TestCaseWithTwoWebservers):
1135
TestHTTPRedirections,
1136
http_utils.TestCaseWithTwoWebservers):
1085
1137
"""Tests redirections for pycurl implementation"""
1087
_qualifier = 'pycurl'
1139
def _qualified_url(self, host, port):
1140
return 'http+pycurl://%s:%s' % (host, port)
1143
class TestHTTPRedirections_nosmart(TestHTTPRedirections,
1144
http_utils.TestCaseWithTwoWebservers):
1145
"""Tests redirections for the nosmart decorator"""
1147
_transport = NoSmartTransportDecorator
1149
def _qualified_url(self, host, port):
1150
return 'nosmart+http://%s:%s' % (host, port)
1153
class TestHTTPRedirections_readonly(TestHTTPRedirections,
1154
http_utils.TestCaseWithTwoWebservers):
1155
"""Tests redirections for readonly decoratror"""
1157
_transport = ReadonlyTransportDecorator
1159
def _qualified_url(self, host, port):
1160
return 'readonly+http://%s:%s' % (host, port)
1090
1163
class TestDotBzrHidden(TestCaseWithTransport):