[MERGE] Custom templates in version-info
Lukáš Lalinský
lalinsky at gmail.com
Sat Nov 10 12:02:18 GMT 2007
Here is an updated version that fixes all mentioned problems. This
doesn't include built-in C format and the -o option, because I really
think those aren't necessary.
Lukas
On Po, 2007-10-29 at 21:01 +0200, Alexander Belchenko wrote:
> Luk???? Lalinsk?? ??????????:
> > (Sorry for the double post, this time with [MERGE] ...)
> >
> > Here is a new version, with support for custom template-based formats,
> > so people can use version-info with any language they want and with
> > any style they prefer. Also I've added some documentation and updated
> > version_info_formats to use a Registry.
>
> bb:comment
>
> === 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-29 11:01:45 +0000
> @@ -45,16 +47,40 @@
>
>
> 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.'),
> + """Show version information about this tree.
> +
> + You can use this command to add information about version into
> + source code of an application. The output can be in one of the
> + supported formats or in a custom format based on a template.
> +
> + For example::
> +
> + bzr version-info --custom \\
> + --template="#define VERSION \\"Foo 1.2.3 (r{revno})\\"\\n"
>
> Template mechanism is great, but IMO we need to have simple default
> C-generator too (for lazy users). Defaults matter.
>
> +
> + will produce a C header file with formatted string containing the
> + current revision number. Other supported variables in templates are:
> +
> + * {date} - date of the last revision
> + * {build_date} - current date
> + * {revno} - revision number
> + * {revision_id} - revision id
> + * {branch_nick} - branch nickname
> + * {clean} - 1 if the source tree contains uncommitted changes,
> + otherwise 0
> + """
>
> ^-- option clear is counter-intuitive for me.
> clean == 1 for me is True condition, therefore 'clean' means 'no changes in working tree'.
> Am I wrong?
>
>
> +
> + takes_options = [RegistryOption('format',
> + 'Select the output format.',
> + version_info_formats.format_registry,
> + value_switches=True),
> Option('all', help='Include all possible information.'),
> Option('check-clean', help='Check if tree is clean.'),
> Option('include-history',
> help='Include the revision-history.'),
> Option('include-file-revisions',
> - - help='Include the last revision for each file.')
> + help='Include the last revision for each file.'),
> + Option('template', type=str, help='Template for the output.'),
> ]
> takes_args = ['location?']
>
> @@ -62,13 +88,14 @@
>
> def run(self, location=None, format=None,
> all=False, check_clean=False, include_history=False,
> - - include_file_revisions=False):
> + include_file_revisions=False, template=None,
> + template_file=None):
>
> ^-- you probably planning to introduce template_file option,
> but don't use it actually, and don't add corresponding Option above.
> It should either go away, or used as expected.
> I see it as potentially useful option.
>
> Also it will be nice to have -o/--output option.
>
>
> Otherwise looks good for me.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: version-info-templates.diff
Type: text/x-patch
Size: 21246 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20071110/97f54cbb/attachment-0001.bin
More information about the bazaar
mailing list