setup: support building from an ongoing merge stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 22 Feb 2023 18:30:47 +0100
branchstable
changeset 50168 593f5e4076ff
parent 50100 812a9fbf4380
child 50169 34ab5c7b7f98
setup: support building from an ongoing merge Before this change the two parents from the merge would duplicate some command output and modify some others in a way python 3.11 chokes on.
setup.py
--- a/setup.py	Thu Feb 16 11:42:34 2023 +0100
+++ b/setup.py	Wed Feb 22 18:30:47 2023 +0100
@@ -337,6 +337,8 @@
     pieces = sysstr(hg.run(cmd)).split()
     numerictags = [t for t in pieces if t[0:1].isdigit()]
     hgid = sysstr(hg.run(['id', '-i'])).strip()
+    if hgid.count('+') == 2:
+        hgid = hgid.replace("+", ".", 1)
     if not hgid:
         eprint("/!\\")
         eprint(r"/!\ Unable to determine hg version from local repository")
@@ -347,7 +349,7 @@
         if hgid.endswith('+'):  # propagate the dirty status to the tag
             version += '+'
     else:  # no tag found on the checked out revision
-        ltagcmd = ['parents', '--template', '{latesttag}']
+        ltagcmd = ['log', '--rev', 'wdir()', '--template', '{latesttag}']
         ltag = sysstr(hg.run(ltagcmd))
         if not ltag:
             eprint("/!\\")
@@ -356,7 +358,13 @@
                 r"/!\ Failed to retrieve current revision distance to lated tag"
             )
             return ''
-        changessincecmd = ['log', '-T', 'x\n', '-r', "only(.,'%s')" % ltag]
+        changessincecmd = [
+            'log',
+            '-T',
+            'x\n',
+            '-r',
+            "only(parents(),'%s')" % ltag,
+        ]
         changessince = len(hg.run(changessincecmd).splitlines())
         version = '%s+hg%s.%s' % (ltag, changessince, hgid)
     if version.endswith('+'):