[PATCH 5 of 5] setup: append the latesttag to the version string when no tag is found
Gilles Moris
gilles.moris at free.fr
Fri Oct 9 22:02:35 UTC 2009
setup.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
# HG changeset patch
# User Gilles Moris <gilles.moris at free.fr>
# Date 1255125358 -7200
# Node ID af29b8bb57dd2cebef4078a83eac01272259064e
# Parent 0819ee856055ab74c34790402f7af5bbc1e1468f
setup: append the latesttag to the version string when no tag is found
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -141,8 +141,14 @@
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')
+ latesttag = latesttagdistance = None
for line in hgarchival:
if line.startswith('node:'):
version = line.split(':')[1].strip()[:12]
@@ -150,6 +156,14 @@
version = line.split(':')[1].strip()
# stop on the first tag we find
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 latesttag and latesttagdistance:
+ # 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