def test_iter_switches(self): opt = option.Option('hello', help='fg') self.assertEqual(list(opt.iter_switches()), [('hello', None, None, 'fg')]) opt = option.Option('hello', help='fg', type=int) self.assertEqual(list(opt.iter_switches()), [('hello', None, 'ARG', 'fg')]) opt = option.Option('hello', help='fg', type=int, argname='gar') self.assertEqual(list(opt.iter_switches()), [('hello', None, 'GAR', 'fg')]) registry = controldir.ControlDirFormatRegistry() bzrdir.register_metadir(registry, 'one', 'RepositoryFormat7', 'one help') bzrdir.register_metadir(registry, 'two', 'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', 'two help', ) registry.set_default('one') opt = option.RegistryOption('format', 'format help', registry, value_switches=False) self.assertEqual(list(opt.iter_switches()), [('format', None, 'ARG', 'format help')]) opt = option.RegistryOption('format', 'format help', registry, value_switches=True) self.assertEqual(list(opt.iter_switches()), [('format', None, 'ARG', 'format help'), ('default', None, None, 'one help'), ('one', None, None, 'one help'), ('two', None, None, 'two help'), ])
def test_is_hidden(self): registry = controldir.ControlDirFormatRegistry() bzrdir.register_metadir(registry, 'hidden', 'HiddenFormat', 'hidden help text', hidden=True) bzrdir.register_metadir(registry, 'visible', 'VisibleFormat', 'visible help text', hidden=False) format = option.RegistryOption('format', '', registry, str) self.assertTrue(format.is_hidden('hidden')) self.assertFalse(format.is_hidden('visible'))
def setUp(self): super(TestDeprecationWarning, self).setUp() self.addCleanup(repository.format_registry.remove, TestObsoleteRepoFormat) repository.format_registry.register(TestObsoleteRepoFormat) self.addCleanup(controldir.format_registry.remove, "testobsolete") bzrdir.register_metadir(controldir.format_registry, "testobsolete", "bzrlib.tests.blackbox.test_exceptions.TestObsoleteRepoFormat", branch_format='bzrlib.branch.BzrBranchFormat7', tree_format='bzrlib.workingtree_4.WorkingTreeFormat6', deprecated=True, help='Same as 2a, but with an obsolete repo format.') self.disable_deprecation_warning()
def setUp(self): super(TestDeprecationWarning, self).setUp() self.addCleanup(repository.format_registry.remove, TestObsoleteRepoFormat) repository.format_registry.register(TestObsoleteRepoFormat) self.addCleanup(controldir.format_registry.remove, "testobsolete") bzrdir.register_metadir( controldir.format_registry, "testobsolete", "bzrlib.tests.blackbox.test_exceptions.TestObsoleteRepoFormat", branch_format='bzrlib.branch.BzrBranchFormat7', tree_format='bzrlib.workingtree_4.WorkingTreeFormat6', deprecated=True, help='Same as 2a, but with an obsolete repo format.') self.disable_deprecation_warning()
def test_registry_conversion(self): registry = controldir.ControlDirFormatRegistry() bzrdir.register_metadir(registry, 'one', 'RepositoryFormat7', 'one help') bzrdir.register_metadir(registry, 'two', 'RepositoryFormatKnit1', 'two help') bzrdir.register_metadir(registry, 'hidden', 'RepositoryFormatKnit1', 'two help', hidden=True) registry.set_default('one') options = [option.RegistryOption('format', '', registry, str)] opts, args = self.parse(options, ['--format', 'one']) self.assertEqual({'format':'one'}, opts) opts, args = self.parse(options, ['--format', 'two']) self.assertEqual({'format':'two'}, opts) self.assertRaises(errors.BadOptionValue, self.parse, options, ['--format', 'three']) self.assertRaises(errors.BzrCommandError, self.parse, options, ['--two']) options = [option.RegistryOption('format', '', registry, str, value_switches=True)] opts, args = self.parse(options, ['--two']) self.assertEqual({'format':'two'}, opts) opts, args = self.parse(options, ['--two', '--one']) self.assertEqual({'format':'one'}, opts) opts, args = self.parse(options, ['--two', '--one', '--format', 'two']) self.assertEqual({'format':'two'}, opts) options = [option.RegistryOption('format', '', registry, str, enum_switch=False)] self.assertRaises(errors.BzrCommandError, self.parse, options, ['--format', 'two'])
def test_help(self): registry = controldir.ControlDirFormatRegistry() bzrdir.register_metadir(registry, 'one', 'RepositoryFormat7', 'one help') bzrdir.register_metadir(registry, 'two', 'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', 'two help', ) bzrdir.register_metadir(registry, 'hidden', 'RepositoryFormat7', 'hidden help', hidden=True) registry.set_default('one') options = [option.RegistryOption('format', 'format help', registry, str, value_switches=True, title='Formats')] parser = option.get_optparser(dict((o.name, o) for o in options)) value = parser.format_option_help() self.assertContainsRe(value, 'format.*format help') self.assertContainsRe(value, 'one.*one help') self.assertContainsRe(value, 'Formats:\n *--format') self.assertNotContainsRe(value, 'hidden help')
'RepositoryFormat6') # The pre-0.8 formats have their repository format network name registered in # repository.py. MetaDir formats have their repository format network name # inferred from their disk format string. controldir.format_registry.register_lazy('weave', "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat6", 'Pre-0.8 format. Slower than knit and does not' ' support checkouts or shared repositories.', hidden=True, deprecated=True) register_metadir(controldir.format_registry, 'metaweave', 'bzrlib.plugins.weave_fmt.repository.RepositoryFormat7', 'Transitional format in 0.8. Slower than knit.', branch_format='bzrlib.branchfmt.fullhistory.BzrBranchFormat5', tree_format='bzrlib.workingtree_3.WorkingTreeFormat3', hidden=True, deprecated=True) BzrProber.formats.register_lazy( "Bazaar-NG branch, format 0.0.4\n", "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat4") BzrProber.formats.register_lazy( "Bazaar-NG branch, format 5\n", "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat5") BzrProber.formats.register_lazy( "Bazaar-NG branch, format 6\n", "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat6")
'bzrlib.plugins.weave_fmt.repository', 'RepositoryFormat6') # The pre-0.8 formats have their repository format network name registered in # repository.py. MetaDir formats have their repository format network name # inferred from their disk format string. controldir.format_registry.register_lazy( 'weave', "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat6", 'Pre-0.8 format. Slower than knit and does not' ' support checkouts or shared repositories.', hidden=True, deprecated=True) register_metadir(controldir.format_registry, 'metaweave', 'bzrlib.plugins.weave_fmt.repository.RepositoryFormat7', 'Transitional format in 0.8. Slower than knit.', branch_format='bzrlib.branchfmt.fullhistory.BzrBranchFormat5', tree_format='bzrlib.workingtree_3.WorkingTreeFormat3', hidden=True, deprecated=True) BzrProber.formats.register_lazy("Bazaar-NG branch, format 0.0.4\n", "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat4") BzrProber.formats.register_lazy("Bazaar-NG branch, format 5\n", "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat5") BzrProber.formats.register_lazy("Bazaar-NG branch, format 6\n", "bzrlib.plugins.weave_fmt.bzrdir", "BzrDirFormat6") _mod_branch.format_registry.register_extra_lazy(