Commits

Bryan O'Sullivan committed b7fff47

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.

Comments (0)

Files changed (1)

     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'):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.