Mercurial > hg
diff contrib/packaging/hgpackaging/util.py @ 43518:7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
The code in the Inno file was a holdover from before we had
Python driving execution.
With Python in the driver's seat, we can now have it resolve
the version string and pass it into Inno, making the code
easier to understand for people who aren't packaging gurus.
Differential Revision: https://phab.mercurial-scm.org/D7161
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 22 Oct 2019 18:34:03 -0700 |
parents | d053d3f10b6a |
children | a70108a3d7cc |
line wrap: on
line diff
--- a/contrib/packaging/hgpackaging/util.py Thu Oct 24 21:22:08 2019 -0700 +++ b/contrib/packaging/hgpackaging/util.py Tue Oct 22 18:34:03 2019 -0700 @@ -12,6 +12,7 @@ import glob import os import pathlib +import re import shutil import subprocess import tarfile @@ -210,3 +211,16 @@ full_dest_path.parent.mkdir(parents=True, exist_ok=True) shutil.copy(full_source_path, full_dest_path) print('copying %s to %s' % (full_source_path, full_dest_path)) + + +def read_version_py(source_dir): + """Read the mercurial/__version__.py file to resolve the version string.""" + p = source_dir / 'mercurial' / '__version__.py' + + with p.open('r', encoding='utf-8') as fh: + m = re.search('version = b"([^"]+)"', fh.read(), re.MULTILINE) + + if not m: + raise Exception('could not parse %s' % p) + + return m.group(1)