[PATCH] packaging: ensure the proper version is generated for tagged Windows builds

5 views
Skip to first unread message

Matt Harbison

unread,
Jul 1, 2022, 2:26:57 PM7/1/22
to thg...@googlegroups.com
# 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,

Matt Harbison

unread,
Jul 1, 2022, 11:45:47 PM7/1/22
to TortoiseHg Developers
On Friday, July 1, 2022 at 2:26:57 PM UTC-4 Matt Harbison wrote:
# 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

I accidentally pushed this myself, thinking I was in another terminal window, and it published because it didn't have a topic.
 

Yuya Nishihara

unread,
Jul 2, 2022, 1:28:55 AM7/2/22
to 'Matt Harbison' via TortoiseHg Developers
LGTM.

> + "heads(. or wdir() & file('relglob:**'))",

Adding empty() revset might be useful since there are other ways to make
wdir dirty. This query could be expressed as last(::wdir() and not empty()).

Matt Harbison

unread,
Jul 2, 2022, 5:48:30 PM7/2/22
to TortoiseHg Developers
What would empty() test?  Is that just a `status --rev $rev^ --rev $rev`, and return an empty set if there's no status, otherwise {$rev}?

I've seen empty commits in the past, but not sure how they were created.  Not sure if either of these would work in that situation, but I don't expect anything like that in the thg repo.

Yuya Nishihara

unread,
Jul 3, 2022, 12:49:15 AM7/3/22
to 'Matt Harbison' via TortoiseHg Developers
On Sat, 2 Jul 2022 14:48:30 -0700 (PDT), 'Matt Harbison' via TortoiseHg Developers wrote:
> On Saturday, July 2, 2022 at 1:28:55 AM UTC-4 Yuya Nishihara wrote:
> > Adding empty() revset might be useful since there are other ways to make
> > wdir dirty. This query could be expressed as last(::wdir() and not
> > empty()).
> >
>
> What would empty() test? Is that just a `status --rev $rev^ --rev $rev`,
> and return an empty set if there's no status, otherwise {$rev}?

ctx.isempty()

> I've seen empty commits in the past, but not sure how they were created.
> Not sure if either of these would work in that situation, but I don't
> expect anything like that in the thg repo.

IIRC, amend/rebase may (optionally) leave empty commit.
Reply all
Reply to author
Forward
0 new messages