56
from bzrlib.tests.bzrdir_implementations import TestCaseWithBzrDir
56
from bzrlib.tests.per_bzrdir import TestCaseWithBzrDir
57
57
from bzrlib.trace import mutter
58
58
from bzrlib.transport import get_transport
59
59
from bzrlib.transport.local import LocalTransport
60
from bzrlib.ui import (
60
63
from bzrlib.upgrade import upgrade
61
64
from bzrlib.remote import RemoteBzrDir, RemoteRepository
62
65
from bzrlib.repofmt import weaverepo
1246
1249
self.assertTrue(repo.is_write_locked())
1252
def test_format_initialize_on_transport_ex_default_stack_on(self):
1253
# When initialize_on_transport_ex uses a stacked-on branch because of
1254
# a stacking policy on the target, the location of the fallback
1255
# repository is the same as the external location of the stacked-on
1257
balloon = self.make_bzrdir('balloon')
1258
if isinstance(balloon, bzrdir.BzrDirMetaFormat1):
1259
stack_on = self.make_branch('stack-on', format='1.9')
1261
stack_on = self.make_branch('stack-on')
1262
config = self.make_bzrdir('.').get_config()
1264
config.set_default_stack_on('stack-on')
1265
except errors.BzrError:
1266
raise TestNotApplicable('Only relevant for stackable formats.')
1267
# Initialize a bzrdir subject to the policy.
1268
t = self.get_transport('stacked')
1269
repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
1270
repo_name = repo_fmt.repository_format.network_name()
1271
repo, control = self.assertInitializeEx(
1272
t, need_meta=True, repo_format_name=repo_name, stacked_on=None)
1274
# uninitialisable format
1276
# There's one fallback repo, with a public location.
1277
self.assertLength(1, repo._fallback_repositories)
1278
fallback_repo = repo._fallback_repositories[0]
1280
stack_on.base, fallback_repo.bzrdir.root_transport.base)
1281
# The bzrdir creates a branch in stacking-capable format.
1282
new_branch = control.create_branch()
1283
self.assertTrue(new_branch._format.supports_stacking())
1249
1285
def test_format_initialize_on_transport_ex_repo_fmt_name_None(self):
1250
1286
t = self.get_transport('dir')
1251
1287
repo, control = self.assertInitializeEx(t)
1742
1778
self.old_factory = bzrlib.ui.ui_factory
1743
1779
self.addCleanup(self.restoreFactory)
1744
bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
1746
1781
def restoreFactory(self):
1747
1782
bzrlib.ui.ui_factory = self.old_factory
1798
1833
# two yes's : branch and repository. If the repo in this
1799
1834
# dir is inappropriately accessed, 3 will be needed, and
1800
1835
# we'll see that because the stream will be fully consumed
1801
bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\n")
1836
bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True])
1802
1837
# determine if the repository will have been locked;
1803
1838
this_repo_locked = \
1804
1839
thisdir.open_repository().get_physical_lock_status()
1805
1840
master.bzrdir.break_lock()
1806
1841
if this_repo_locked:
1807
1842
# only two ys should have been read
1808
self.assertEqual("y\n", bzrlib.ui.ui_factory.stdin.read())
1843
self.assertEqual([True],
1844
bzrlib.ui.ui_factory.responses)
1810
1846
# only one y should have been read
1811
self.assertEqual("y\ny\n", bzrlib.ui.ui_factory.stdin.read())
1847
self.assertEqual([True, True],
1848
bzrlib.ui.ui_factory.responses)
1812
1849
# we should be able to lock a newly opened branch now
1813
1850
branch = master.bzrdir.open_branch()
1814
1851
branch.lock_write()
1832
1869
tree = self.make_branch_and_tree('.')
1833
1870
tree.lock_write()
1834
1871
# three yes's : tree, branch and repository.
1835
bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\ny\n")
1872
bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True])
1837
1874
tree.bzrdir.break_lock()
1838
1875
except (NotImplementedError, errors.LockActive):