# HG changeset patch
# User Matt Harbison <
matt_h...@yahoo.com>
# Date 1656703525 14400
# Fri Jul 01 15:25:25 2022 -0400
# Branch stable
# Node ID 04fa0699e5dc0b050963a26923c5975eda90af86
# Parent 3a528d8353d3b7f637f2c734eb9ac28bf8953712
packaging: ensure the proper version is generated for tagged Windows builds
The 6.2rc0 build included "+1-ee6f08d2fbca" because the `wdir` archive is built.
It's a little weird that the `.hg_archival.txt` generated when archiving `wdir`
references the parent node but includes `wdir` for the purpose of the trailing
change count (especially if `wdir` is clean), but there's not much we can do
about it now. So dynamically select `.` or `wdir`, as needed.
There's another subtly wrong thing here in that generating a version string with
a dirty `wdir` doesn't add the trailing '+'. But that probably needs to be
fixed in `hg archive` (to add a dirty indicator), and the version generation
needs to be synched with Mercurial's new format anyway. This is good enough for
release builds though.
diff --git a/contrib/packaging/thgpackaging/py2exe.py b/contrib/packaging/thgpackaging/py2exe.py
--- a/contrib/packaging/thgpackaging/py2exe.py
+++ b/contrib/packaging/thgpackaging/py2exe.py
@@ -271,8 +271,16 @@
shutil.rmtree(thg_dir)
thg_dir.mkdir()
+ # Select wdir if dirty, otherwise . to get the change count correct for
+ # tagged builds, while still copying uncommitted changes to the build tree.
subprocess.run(
- ['hg.exe', 'archive', '-r', 'wdir()', str(thg_dir)],
+ [
+ 'hg.exe',
+ 'archive',
+ '-r',
+ "heads(. or wdir() & file('relglob:**'))",
+ str(thg_dir)
+ ],
cwd=str(source_dirs.original),
env=env,
check=True,