Add the hg revision ID to __version__ when running a non-released version.

This commit is contained in:
Georg Brandl 2009-08-04 23:29:05 +02:00
parent ee9221d52d
commit 8e9682819a
2 changed files with 17 additions and 2 deletions

View File

@ -13,10 +13,25 @@ import sys
from os import path
__version__ = '0.6.2+'
__released__ = '0.6.2'
__released__ = '0.6.2' # used when Sphinx builds its own docs
package_dir = path.abspath(path.dirname(__file__))
if '+' in __version__ or 'pre' in __version__:
# try to find out the changeset hash if checked out from hg, and append
# it to __version__ (since we use this value from setup.py, it gets
# automatically propagated to an installed copy as well)
try:
import subprocess
p = subprocess.Popen(['hg', 'id', '-i', '-R',
path.join(package_dir, '..')],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if out:
__version__ += '/' + out.strip()
except Exception:
pass
def main(argv=sys.argv):
if sys.version_info[:3] < (2, 4, 0):

View File

@ -84,7 +84,7 @@ class Sphinx(object):
self._events = events.copy()
# say hello to the world
self.info(bold('Running Sphinx v%s' % sphinx.__released__))
self.info(bold('Running Sphinx v%s' % sphinx.__version__))
# status code for command-line application
self.statuscode = 0