diff setup.py @ 52240:2b7e3177f99c stable

setup: use the same code to compute tag from archive Let us make sure we use a consistent version across the board.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 13 Nov 2024 14:34:40 +0100
parents 35a9b6d3b484
children 124c944b71b2
line wrap: on
line diff
--- a/setup.py	Wed Nov 13 14:28:25 2024 +0100
+++ b/setup.py	Wed Nov 13 14:34:40 2024 +0100
@@ -457,16 +457,23 @@
         [[t.strip() for t in l.split(':', 1)] for l in open('.hg_archival.txt')]
     )
     if 'tag' in kw:
-        version = kw['tag']
+        version = _version(tag=kw['tag'])
     elif 'latesttag' in kw:
-        if 'changessincelatesttag' in kw:
-            version = (
-                '%(latesttag)s+hg%(changessincelatesttag)s.%(node).12s' % kw
-            )
-        else:
-            version = '%(latesttag)s+hg%(latesttagdistance)s.%(node).12s' % kw
+        distance = int(kw.get('changessincelatesttag', kw['latesttagdistance']))
+        version = _version(
+            tag=kw['latesttag'],
+            branch=kw['branch'],
+            changes_since=distance,
+            hgid=kw['node'][:12],
+        )
     else:
-        version = '0+hg' + kw.get('node', '')[:12]
+        version = _version(
+            tag='0',
+            branch='unknown-source',
+            changes_since=1,
+            hgid=kw.get('node', 'unknownid')[:12],
+            dirty=True,
+        )
 elif os.path.exists('mercurial/__version__.py'):
     with open('mercurial/__version__.py') as f:
         data = f.read()