Mercurial > hg
changeset 46512:866eb4d6bd9f
build: fake PEP440 versions
If the current version is not exactly a tag, use a local version
specifier to fix it up. PEP 440 uses the "+" separator and only allows
alphanumeric and dot, so use dot for further separations.
Old devel build: 5.7+155-a163cc36d06b
New devel build: 5.7+hg155.a163cc36d06b
Differential Revision: https://phab.mercurial-scm.org/D9955
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Thu, 04 Feb 2021 23:11:42 +0100 |
parents | 02d91167cfc3 |
children | c3c7a86e9c24 |
files | setup.py |
diffstat | 1 files changed, 9 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Thu Feb 04 11:32:08 2021 -0800 +++ b/setup.py Thu Feb 04 23:11:42 2021 +0100 @@ -419,9 +419,9 @@ ltag = sysstr(hg.run(ltagcmd)) changessincecmd = ['log', '-T', 'x\n', '-r', "only(.,'%s')" % ltag] changessince = len(hg.run(changessincecmd).splitlines()) - version = '%s+%s-%s' % (ltag, changessince, hgid) + version = '%s+hg%s.%s' % (ltag, changessince, hgid) if version.endswith('+'): - version += time.strftime('%Y%m%d') + version = version[:-1] + 'local' + time.strftime('%Y%m%d') elif os.path.exists('.hg_archival.txt'): kw = dict( [[t.strip() for t in l.split(':', 1)] for l in open('.hg_archival.txt')] @@ -430,11 +430,13 @@ version = kw['tag'] elif 'latesttag' in kw: if 'changessincelatesttag' in kw: - version = '%(latesttag)s+%(changessincelatesttag)s-%(node).12s' % kw + version = ( + '%(latesttag)s+.%(changessincelatesttag)s.%(node).12s' % kw + ) else: - version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw + version = '%(latesttag)s+.%(latesttagdistance)s.%(node).12s' % kw else: - version = kw.get('node', '')[:12] + version = '0+' + kw.get('node', '')[:12] if version: versionb = version @@ -451,20 +453,6 @@ ), ) -try: - oldpolicy = os.environ.get('HGMODULEPOLICY', None) - os.environ['HGMODULEPOLICY'] = 'py' - from mercurial import __version__ - - version = __version__.version -except ImportError: - version = b'unknown' -finally: - if oldpolicy is None: - del os.environ['HGMODULEPOLICY'] - else: - os.environ['HGMODULEPOLICY'] = oldpolicy - class hgbuild(build): # Insert hgbuildmo first so that files in mercurial/locale/ are found @@ -1683,8 +1671,8 @@ # unicode on Python 2 still works because it won't contain any # non-ascii bytes and will be implicitly converted back to bytes # when operated on. -assert isinstance(version, bytes) -setupversion = version.decode('ascii') +assert isinstance(version, str) +setupversion = version extra = {}