Properly initialize version string in python-hglib setup.py

Yuya Nishihara yuya at tcha.org
Tue Jul 21 10:39:09 CDT 2015


On Mon, 20 Jul 2015 23:27:02 +0000 (UTC), Peter Elmers wrote:
> # HG changeset patch
> # User Peter Elmers <peter.elmers at yahoo.com>
> # Date 1437434738 25200
> #      Mon Jul 20 16:25:38 2015 -0700
> # Node ID c0f73a10ceb96a60c178f6057ce90309d08d3974
> # Parent  ec935041d1ff0fd2aa8cb666d79e6dcca398ddba
> Issue 3924: default version to 1.6, parse PKG-INFO.

Thanks for the revised patch, but we prefer patch in body, not as an
attachment.

https://mercurial.selenic.com/wiki/ContributingChanges#Submission_checklist

Couple of comments follow...

> -# query Mercurial for version number
> -version = 'unknown'
> +version = '1.6'

Hmm, it must be updated per release? That is what we want to avoid.

>  elif os.path.exists('.hg_archival.txt'):
>      kw = dict([[t.strip() for t in l.split(':', 1)]
>                 for l in open('.hg_archival.txt')])
>      if 'tag' in kw:
> -        version =  kw['tag']
> +        version = kw['tag']

Good catch, but whitespace cleanup should be a separate patch.

>      elif 'latesttag' in kw:
>          version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
>      else:
>          version = kw.get('node', '')[:12]
> +elif os.path.exists('PKG-INFO'):
> +    with open('PKG-INFO') as pkginfo:
> +        kw = dict([[t.strip() for t in l.split(':', 1)]
> +                  for l in pkginfo if ':' in l])
> +        version = kw.get('Version', version)

Perhaps hglib should be compatible with ancient Python, so I think "with"
statement isn't allowed.


More information about the Mercurial-devel mailing list