[MERGE] Re: bzr version-info for C/C++
Alexander Belchenko
bialix at ukr.net
Sat Oct 6 15:56:55 BST 2007
Lukáš Lalinský пишет:
> On 10/6/07, Panagiotis Papadakos <papadako at csd.uoc.gr> wrote:
>> Well the bzr version-info with python and rio support is already in
>> bzr.dev. So why we shouldn't add c format support to it?
>
> I agree with this. C/C++ is used by vast majority of open source
> project, I don't see a reason to not have it in bzr core.
bb:comment
I like help for merge command because it shows all possible values
for --merge-type option. IMO, 3 variants for output format of
version-info command are big enough to implement similar logic
here. Hence here is the patch for your patch.
=== modified file 'bzrlib/cmd_version_info.py'
--- bzrlib/cmd_version_info.py 2007-07-10 10:20:27 +0000
+++ bzrlib/cmd_version_info.py 2007-10-06 14:49:50 +0000
@@ -26,29 +26,37 @@
)
""")
from bzrlib.commands import Command
-from bzrlib.option import Option
-
-
-def _parse_version_info_format(format):
- """Convert a string passed by the user into a VersionInfoFormat.
-
- This looks in the version info format registry, and if the format
- cannot be found, generates a useful error exception.
- """
- try:
- return version_info_formats.get_builder(format)
- except KeyError:
- formats = version_info_formats.get_builder_formats()
- raise errors.BzrCommandError('No known version info format %s.'
- ' Supported types are: %s'
- % (format, formats))
+from bzrlib.option import (
+ Option,
+ RegistryOption,
+ )
+from bzrlib import registry
+
+
+_version_format_registry = registry.Registry()
+_version_format_registry.register_lazy('rio',
+ 'bzrlib.version_info_formats.format_rio',
+ 'RioVersionInfoBuilder',
+ 'Version info in RIO format')
+_version_format_registry.register_lazy('python',
+ 'bzrlib.version_info_formats.format_python',
+ 'PythonVersionInfoBuilder',
+ 'Version info in Python format')
+_version_format_registry.register_lazy('c',
+ 'bzrlib.version_info_formats.format_c',
+ 'CVersionInfoBuilder',
+ 'Version info in C format')
class cmd_version_info(Command):
"""Show version information about this tree."""
- takes_options = [Option('format', type=_parse_version_info_format,
- help='Select the output format.'),
+ takes_options = [RegistryOption('format',
+ 'Select the output format.',
+ _version_format_registry,
+ value_switches=True,
+ title='Output format',
+ ),
Option('all', help='Include all possible information.'),
Option('check-clean', help='Check if tree is clean.'),
Option('include-history',
More information about the bazaar
mailing list