[PATCH] Fix for issue 1670, archives downloaded from hgweb report version 'unknown'
Jeremy Whitlock
jcscoobyrs at gmail.com
Tue May 19 17:42:29 CDT 2009
# HG changeset patch
# User Jeremy Whitlock <jcscoobyrs at gmail.com>
# Date 1242772904 21600
# Node ID 99567c804f8474d1730a5aee3e96131f2f341818
# Parent 90f86a5330bbbcd075c792cd14fb6bb47b8ccd2c
Fix for issue 1670, archives downloaded from hgweb report version 'unknown'.
Previously, setup.py was enhanced to identify the Mercurial version from either
.hg/ or mercurial/__version__.py. When archives are created via hgweb, neither
of those options are available but, there is a file in the root of the archive
(.hg_archival.txt) that has the information. This patch enhances setup.py to
identify the Mercurial version from the .hg_archival.txt file when there is no
.hg/ or mercurial/__version__.py available.
diff -r 90f86a5330bb -r 99567c804f84 setup.py
--- a/setup.py Mon May 18 17:36:24 2009 -0500
+++ b/setup.py Tue May 19 16:41:44 2009 -0600
@@ -97,6 +97,8 @@
except ImportError:
pass
+version = None
+
if os.path.exists('.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 = '%s hg id -it' % sys.executable
- version = None
try:
l = os.popen(cmd).read().split()
@@ -120,12 +121,21 @@
version = l[-1] # latest tag or revision number
if version.endswith('+'):
version += time.strftime('%Y%m%d')
+elif os.path.exists('.hg_archival.txt'):
+ archival_file = open('.hg_archival.txt', 'r')
- 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()
+ for line in archival_file.readlines():
+ if line.startswith('node:'):
+ version = line.split(':')[1].strip()[:12]
+ break
+
+ archival_file.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__
More information about the Mercurial-devel
mailing list