[MERGE] Custom templates in version-info (was: Re: [MERGE] Re: bzr version-info for C/C++)

Alexander Belchenko bialix at ukr.net
Mon Oct 29 19:01:43 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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.

- --
[µ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHJi4XzYr338mxwCURAoH/AJ0VIjZBObxU0i2H5VMRrcJMiZJSCQCdHeTF
jWNZMbADTEMssT2ABgpfsg4=
=4mwK
-----END PGP SIGNATURE-----



More information about the bazaar mailing list