[PATCH 5 of 5] setup: append the latesttag to the version string for untagged versions
Gilles Moris
gilles.moris at free.fr
Fri Oct 16 09:16:29 UTC 2009
setup.py | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
# HG changeset patch
# User Gilles Moris <gilles.moris at free.fr>
# Date 1255684437 -7200
# Node ID 3cfa2b1bd29f119e6cc1d592e3f1f4ac4a1dc797
# Parent 85521e9406339fe34ba928414cb2deb55dccafff
setup: append the latesttag to the version string for untagged versions
Here is an array summarizing the mercurial version string:
[A] [B] [C] [D]
[1] archive tag clean => tag
[2] archive hash clean => sha1hash [latesttag+latesttagdistance]
[3] archive tag dirty => N/A
[4] archive hash dirty => N/A
[5] clone tag clean => tag
[6] clone hash clean => sha1hash [latesttag+latesttagdistance]
[7] clone tag dirty => tag+date
[8] clone hash dirty => sha1hash+date
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -141,15 +141,31 @@
version += '+'
if version.endswith('+'):
version += time.strftime('%Y%m%d')
+ elif len(l) == 1: # no tag found for that rev
+ # then search for latest tag
+ cmd = [sys.executable, 'hg', 'parents', '--template',
+ ' [{latesttag}+{latesttagdistance}]']
+ version += runcmd(cmd)
elif os.path.exists('.hg_archival.txt'):
hgarchival = open('.hg_archival.txt')
+ tag = latesttag = latesttagdistance = None
for line in hgarchival:
if line.startswith('node:'):
version = line.split(':')[1].strip()[:12]
if line.startswith('tag:'):
- version = line.split(':')[1].strip()
+ tag = line.split(':')[1].strip()
# if there are multiple tags then we only use the first
break
+ # otherwise, try to fallback to the latest tag
+ if line.startswith('latesttag:'):
+ latesttag = line.split(':', 1)[1].strip()
+ if line.startswith('latesttagdistance:'):
+ latesttagdistance = line.split(':')[1].strip()
+ if tag:
+ version = tag
+ elif latesttag and latesttagdistance and latesttagdistance != '0':
+ # note that if distance is 0, it will not enter, which is expected
+ version += ' [%s+%s]' % (latesttag, latesttagdistance)
if version:
f = open("mercurial/__version__.py", "w")
More information about the Mercurial-devel
mailing list