setup.py
changeset 8548 3ccbe42ff72f
parent 8547 548fd7a05373
child 8549 9f85da260508
--- a/setup.py	Fri May 22 14:26:58 2009 +0200
+++ b/setup.py	Fri May 22 21:03:06 2009 +0200
@@ -97,6 +97,8 @@
 except ImportError:
     pass
 
+version = None
+
 if os.path.isdir('.hg'):
     # execute hg out of this directory with a custom environment which
     # includes the pure Python modules in mercurial/pure
@@ -105,7 +107,6 @@
     os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath])
     os.environ['HGRCPATH'] = '' # do not read any config file
     cmd = [sys.executable, 'hg', 'id', '-i', '-t']
-    version = None
 
     l, e = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE).communicate()
@@ -122,12 +123,19 @@
             version = l[-1] # latest tag or revision number
             if version.endswith('+'):
                 version += time.strftime('%Y%m%d')
+elif os.path.exists('.hg_archival.txt'):
+    hgarchival = open('.hg_archival.txt')
+    for line in hgarchival:
+        if line.startswith('node:'):
+            version = line.split(':')[1].strip()[:12]
+            break
 
-    if version:
-        f = file("mercurial/__version__.py", "w")
-        f.write('# this file is autogenerated by setup.py\n')
-        f.write('version = "%s"\n' % version)
-        f.close()
+if version:
+    f = file("mercurial/__version__.py", "w")
+    f.write('# this file is autogenerated by setup.py\n')
+    f.write('version = "%s"\n' % version)
+    f.close()
+
 
 try:
     from mercurial import __version__