# HG changeset patch # User Bryan O'Sullivan # Date 1349462692 18000 # Node ID b7fff47bb1288c99af34205fe667b698226194ec # Parent 4f2f0f367ef64a979c68002e8689e28f579c7d07 setup: calculate version more correctly The old calculation code failed to properly identify revs that weren't tagged, leaving us with a version of "unknown" most of the time during development. diff -r 4f2f0f367ef6 -r b7fff47bb128 setup.py --- a/setup.py Thu Oct 04 17:00:32 2012 -0500 +++ b/setup.py Fri Oct 05 13:44:52 2012 -0500 @@ -172,18 +172,17 @@ env['SystemRoot'] = os.environ['SystemRoot'] if os.path.isdir('.hg'): - cmd = [sys.executable, 'hg', 'id', '-i', '-t'] - l = runhg(cmd, env).split() - while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags - l.pop() - if len(l) > 1: # tag found - version = l[-1] - if l[0].endswith('+'): # propagate the dirty status to the tag + cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n'] + numerictags = [t for t in runhg(cmd, env).split() if t[0].isdigit()] + hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip() + if numerictags: # tag(s) found + version = numerictags[-1] + if hgid.endswith('+'): # propagate the dirty status to the tag version += '+' - elif len(l) == 1: # no tag found + else: # no tag found cmd = [sys.executable, 'hg', 'parents', '--template', '{latesttag}+{latesttagdistance}-'] - version = runhg(cmd, env) + l[0] + version = runhg(cmd, env) + hgid if version.endswith('+'): version += time.strftime('%Y%m%d') elif os.path.exists('.hg_archival.txt'):