def test_sprout_branch_from_hpss_preserves_shared_repo_format(self): """branch.sprout from a smart server preserves the repository format of a branch from a shared repository. """ if not self.repository_format.supports_leaving_lock: raise tests.TestNotApplicable("Format can not be used over HPSS") # Make a shared repo remote_repo = self.make_remote_repository('remote', shared=True) remote_backing_repo = controldir.ControlDir.open( self.get_vfs_only_url('remote')).open_repository() # Make a branch in that repo in an old format that isn't the default # branch format for the repo. from bzrlib.branchfmt.fullhistory import BzrBranchFormat5 format = remote_backing_repo.bzrdir.cloning_metadir() format._branch_format = BzrBranchFormat5() remote_transport = remote_repo.bzrdir.root_transport.clone('branch') controldir.ControlDir.create_branch_convenience(remote_transport.base, force_new_repo=False, format=format) remote_branch = controldir.ControlDir.open_from_transport( remote_transport).open_branch() try: local_bzrdir = remote_branch.bzrdir.sprout('local') except errors.TransportNotPossible: raise tests.TestNotApplicable( "Cannot lock_read old formats like AllInOne over HPSS.") local_repo = local_bzrdir.open_repository() self.assertEqual(remote_backing_repo._format, local_repo._format)
def test_upgrade_preserves_signatures(self): if not self.repository_format.supports_revision_signatures: raise tests.TestNotApplicable( "repository does not support signing revisions") wt = self.make_branch_and_tree('source') wt.commit('A', allow_pointless=True, rev_id='A') repo = wt.branch.repository repo.lock_write() repo.start_write_group() try: repo.sign_revision('A', gpg.LoopbackGPGStrategy(None)) except errors.UnsupportedOperation: self.assertFalse(repo._format.supports_revision_signatures) raise tests.TestNotApplicable( "signatures not supported by repository format") repo.commit_write_group() repo.unlock() old_signature = repo.get_signature_text('A') try: old_format = controldir.ControlDirFormat.get_default_format() # This gives metadir branches something they can convert to. # it would be nice to have a 'latest' vs 'default' concept. format = controldir.format_registry.make_bzrdir( 'development-subtree') upgrade.upgrade(repo.bzrdir.root_transport.base, format=format) except errors.UpToDateFormat: # this is in the most current format already. return except errors.BadConversionTarget, e: raise tests.TestSkipped(str(e))
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_set_get_make_working_trees_false(self): repo = self.make_repository('repo') try: repo.set_make_working_trees(False) except (errors.RepositoryUpgradeRequired, errors.UnsupportedOperation), e: raise tests.TestNotApplicable('Format does not support this flag.')
def test_sprout_branch_from_hpss_preserves_repo_format(self): """branch.sprout from a smart server preserves the repository format. """ if not self.repository_format.supports_leaving_lock: raise tests.TestNotApplicable("Format can not be used over HPSS") remote_repo = self.make_remote_repository('remote') remote_branch = remote_repo.bzrdir.create_branch() try: local_bzrdir = remote_branch.bzrdir.sprout('local') except errors.TransportNotPossible: raise tests.TestNotApplicable( "Cannot lock_read old formats like AllInOne over HPSS.") local_repo = local_bzrdir.open_repository() remote_backing_repo = controldir.ControlDir.open( self.get_vfs_only_url('remote')).open_repository() self.assertEqual(remote_backing_repo._format, local_repo._format)
def setUp(self): super(TestCommitWithStacking, self).setUp() format = self.repository_format if (not (isinstance(format, remote.RemoteRepositoryFormat) or format.supports_chks)): raise tests.TestNotApplicable('stacked commit only supported' ' for chk repositories')
def not_applicable_if_missing_in(self, relpath, tree): if not tree.path2id(relpath): # The locked test trees conversion could not preserve the missing # file status. This is normal (e.g. InterDirstateTree falls back # to InterTree if the basis is not a DirstateRevisionTree, and # revision trees cannot have missing files. raise tests.TestNotApplicable('cannot represent missing files')