[PATCH 2 of 2] version: add extensions version info (issue4209)
Greg Ward
greg at gerg.ca
Tue Jun 10 08:38:17 CDT 2014
On 10 June 2014, anatoly techtonik said:
> +def moduleversion(module):
> + """gets version information from the module
> +
> + This code was inspired by Django Debug Toolbar's VersionDebugPanel.
> + """
> + extension = module
> + if hasattr(extension, 'get_version'):
> + get_version = extension.get_version
> + if callable(get_version):
> + version = get_version()
> + else:
> + version = get_version
> + elif hasattr(extension, 'VERSION'):
> + version = extension.VERSION
> + elif hasattr(extension, '__version__'):
> + version = extension.__version__
> + else:
> + version = ''
> + if isinstance(version, (list, tuple)):
> + version = '.'.join(str(o) for o in version)
> + return version
1) If this code needs to exist, IMHO it belongs in mercurial.extensions
2) Too complex! IMHO we should just support __version__, and we should
document that in http://mercurial.selenic.com/wiki/PublishingExtensions.
"There should one, and preferably only one, way to do it."
Greg
--
Greg Ward http://www.gerg.ca
<greg at gerg.ca> @gergdotca
More information about the Mercurial-devel
mailing list