Merge with crew-stable
authorMatt Mackall <mpm@selenic.com>
Sat, 23 May 2009 12:31:28 -0500
changeset 8560 107af208ed0b
parent 8493 4c030ada58d2 (diff)
parent 8536 6796d41be421 (current diff)
child 8561 accb1cf85c31
child 8754 31c90d12f86c
Merge with crew-stable
--- a/setup.py	Thu May 21 20:32:45 2009 +0200
+++ b/setup.py	Sat May 23 12:31:28 2009 -0500
@@ -97,10 +97,7 @@
 except ImportError:
     pass
 
-def getversion():
-    if not os.path.exists('.hg'):
-        return None # not in a repository
-
+if os.path.exists('.hg'):
     # execute hg out of this directory with a custom environment which
     # includes the pure Python modules in mercurial/pure
     pypath = os.environ.get('PYTHONPATH', '')
@@ -108,6 +105,7 @@
     os.environ['PYTHONPATH'] = os.pathsep.join(['mercurial', purepath, pypath])
     os.environ['HGRCPATH'] = '' # do not read any config file
     cmd = '%s hg id -it' % sys.executable
+    version = None
 
     try:
         l = os.popen(cmd).read().split()
@@ -122,16 +120,18 @@
         version = l[-1] # latest tag or revision number
         if version.endswith('+'):
             version += time.strftime('%Y%m%d')
-        return version
 
-version = getversion()
-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()
-else:
-    version = "unknown"
+    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__
+    version = __version__.version
+except ImportError:
+    version = 'unknown'
 
 class install_package_data(install_data):
     def finalize_options(self):