[PATCH 2 of 2] version: add extensions version info (issue4209)

anatoly techtonik techtonik at gmail.com
Tue Jun 10 16:40:50 CDT 2014


On Tue, Jun 10, 2014 at 4:38 PM, Greg Ward <greg at gerg.ca> wrote:

> 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
> .
>

I find it useful to support at least get_version(). get_version() may
return human
readable string in free format that can also contain critical libraries
that extension
uses. For example, see the output of hg-git patched with:

https://bitbucket.org/durin42/hg-git/pull-request/32/add-version-info-to-hggit-itself-to-query/diff

D:\>hg version -v
...
Enabled extensions:

  churn
  color
  convert
  hggit      0.6.0 (Dulwich 0.9.6)
  strip
  ...
-- 
anatoly t.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140611/5172575b/attachment.html>


More information about the Mercurial-devel mailing list