[PATCH] setup: calculate version more correctly
Augie Fackler
raf at durin42.com
Fri Oct 5 18:55:31 UTC 2012
LGTM
On Oct 5, 2012, at 1:52 PM, Bryan O'Sullivan <bos at serpentine.com> wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1349462692 18000
> # Node ID 8f9e44e8b59fb9ec0a7ea43f8924493c2a9535f3
> # Parent 57fe5aca86af8d82b9c932bf68ae536a99365c86
> 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 --git a/setup.py b/setup.py
> --- a/setup.py
> +++ b/setup.py
> @@ -172,18 +172,17 @@ if 'SystemRoot' in os.environ:
> 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'):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list