def test_clone_stacking_policy_upgrades(self): """Cloning an unstackable branch format to somewhere with a default stack-on branch upgrades branch and repo to match the target and honour the policy. """ try: repo = self.make_repository('repo', shared=True) except errors.IncompatibleFormat: raise tests.TestNotApplicable('Cannot make a shared repository') if repo.bzrdir._format.fixed_components: self.knownFailure("pre metadir branches do not upgrade on push " "with stacking policy") if isinstance(repo._format, knitpack_repo.RepositoryFormatKnitPack5RichRootBroken): raise tests.TestNotApplicable("unsupported format") # Make a source branch in 'repo' in an unstackable branch format bzrdir_format = self.repository_format._matchingbzrdir transport = self.get_transport('repo/branch') transport.mkdir('.') target_bzrdir = bzrdir_format.initialize_on_transport(transport) branch = _mod_branch.BzrBranchFormat6().initialize(target_bzrdir) # Ensure that stack_on will be stackable and match the serializer of # repo. if isinstance(repo, remote.RemoteRepository): repo._ensure_real() info_repo = repo._real_repository else: info_repo = repo format_description = info.describe_format(info_repo.bzrdir, info_repo, None, None) formats = format_description.split(' or ') stack_on_format = formats[0] if stack_on_format in ["pack-0.92", "dirstate", "metaweave"]: stack_on_format = "1.9" elif stack_on_format in [ "dirstate-with-subtree", "rich-root", "rich-root-pack", "pack-0.92-subtree" ]: stack_on_format = "1.9-rich-root" # formats not tested for above are already stackable, so we can use the # format as-is. stack_on = self.make_branch('stack-on-me', format=stack_on_format) self.make_bzrdir('.').get_config().set_default_stack_on('stack-on-me') target = branch.bzrdir.clone(self.get_url('target')) # The target branch supports stacking. self.assertTrue(target.open_branch()._format.supports_stacking()) if isinstance(repo, remote.RemoteRepository): repo._ensure_real() repo = repo._real_repository target_repo = target.open_repository() if isinstance(target_repo, remote.RemoteRepository): target_repo._ensure_real() target_repo = target_repo._real_repository # The repository format is unchanged if it could already stack, or the # same as the stack on. if repo._format.supports_external_lookups: self.assertEqual(repo._format, target_repo._format) else: self.assertEqual(stack_on.repository._format, target_repo._format)
def test_clone_stacking_policy_upgrades(self): """Cloning an unstackable branch format to somewhere with a default stack-on branch upgrades branch and repo to match the target and honour the policy. """ try: repo = self.make_repository('repo', shared=True) except errors.IncompatibleFormat: raise tests.TestNotApplicable('Cannot make a shared repository') if repo.bzrdir._format.fixed_components: self.knownFailure( "pre metadir branches do not upgrade on push " "with stacking policy") if isinstance(repo._format, knitpack_repo.RepositoryFormatKnitPack5RichRootBroken): raise tests.TestNotApplicable("unsupported format") # Make a source branch in 'repo' in an unstackable branch format bzrdir_format = self.repository_format._matchingbzrdir transport = self.get_transport('repo/branch') transport.mkdir('.') target_bzrdir = bzrdir_format.initialize_on_transport(transport) branch = _mod_branch.BzrBranchFormat6().initialize(target_bzrdir) # Ensure that stack_on will be stackable and match the serializer of # repo. if isinstance(repo, remote.RemoteRepository): repo._ensure_real() info_repo = repo._real_repository else: info_repo = repo format_description = info.describe_format(info_repo.bzrdir, info_repo, None, None) formats = format_description.split(' or ') stack_on_format = formats[0] if stack_on_format in ["pack-0.92", "dirstate", "metaweave"]: stack_on_format = "1.9" elif stack_on_format in ["dirstate-with-subtree", "rich-root", "rich-root-pack", "pack-0.92-subtree"]: stack_on_format = "1.9-rich-root" # formats not tested for above are already stackable, so we can use the # format as-is. stack_on = self.make_branch('stack-on-me', format=stack_on_format) self.make_bzrdir('.').get_config().set_default_stack_on('stack-on-me') target = branch.bzrdir.clone(self.get_url('target')) # The target branch supports stacking. self.assertTrue(target.open_branch()._format.supports_stacking()) if isinstance(repo, remote.RemoteRepository): repo._ensure_real() repo = repo._real_repository target_repo = target.open_repository() if isinstance(target_repo, remote.RemoteRepository): target_repo._ensure_real() target_repo = target_repo._real_repository # The repository format is unchanged if it could already stack, or the # same as the stack on. if repo._format.supports_external_lookups: self.assertEqual(repo._format, target_repo._format) else: self.assertEqual(stack_on.repository._format, target_repo._format)
def test_bzr_serve_inet_readwrite(self): # Make a branch self.make_branch('.') process, transport = self.start_server_inet(['--allow-writes']) # We get a working branch, and can create a directory branch = ControlDir.open_from_transport(transport).open_branch() self.make_read_requests(branch) transport.mkdir('adir') self.assertInetServerShutsdownCleanly(process)
def test_find_format_string(self): # is the right format object found for a working tree? branch = self.make_branch('branch') self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTreeFormatMetaDir.find_format_string, branch.bzrdir) transport = branch.bzrdir.get_workingtree_transport(None) transport.mkdir('.') transport.put_bytes("format", "some format name") # The format does not have to be known by Bazaar, # find_format_string just retrieves the name self.assertEquals("some format name", workingtree.WorkingTreeFormatMetaDir.find_format_string(branch.bzrdir))
def make_directory(transport): transport.mkdir('.') return transport