[pypy-svn] pypy commit 0c24ef1bebbc: Fix generating sys._mercurial with broken 'hg' executables.
Bitbucket
commits-noreply at bitbucket.org
Tue Dec 14 21:19:42 CET 2010
# HG changeset patch -- Bitbucket.org
# Project pypy
# URL http://bitbucket.org/pypy/pypy/overview
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1292357958 -3600
# Node ID 0c24ef1bebbca0d3da1083c4c5672487f8e5e7b1
# Parent 3c8e410b68d989fdbf4fd3b4568d5357bd220c30
Fix generating sys._mercurial with broken 'hg' executables.
Tests included.
--- a/pypy/tool/version.py
+++ b/pypy/tool/version.py
@@ -19,7 +19,7 @@ def get_mercurial_info(hgexe=None):
from pypy.tool.ansi_print import ansi_log
log = py.log.Producer("version")
py.log.setconsumer("version", ansi_log)
- log.WARNING('Errors getting Mercurial information: ' + err)
+ log.WARNING('Errors getting Mercurial information: %s' % err)
if not os.path.isdir(os.path.join(pypyroot, '.hg')):
maywarn('Not running from a Mercurial repository!')
@@ -34,6 +34,17 @@ def get_mercurial_info(hgexe=None):
# disable user configuration, extensions, etc.
env['HGRCPATH'] = os.devnull
+ try:
+ p = Popen([str(hgexe), 'version', '-q'],
+ stdout=PIPE, stderr=PIPE, env=env)
+ except OSError, e:
+ maywarn(e)
+ return 'PyPy', '', ''
+
+ if not p.stdout.read().startswith('Mercurial Distributed SCM'):
+ maywarn('command does not identify itself as Mercurial')
+ return 'PyPy', '', ''
+
p = Popen([str(hgexe), 'id', '-i', pypyroot],
stdout=PIPE, stderr=PIPE, env=env)
hgid = p.stdout.read().strip()
--- a/pypy/tool/test/test_version.py
+++ b/pypy/tool/test/test_version.py
@@ -1,7 +1,9 @@
-
+import os, sys
import py
from pypy.tool.version import get_mercurial_info
def test_get_mercurial_info():
assert get_mercurial_info(py.path.local.sysfind(
'completely broken mercurial'))
+ assert get_mercurial_info(os.devnull)
+ assert get_mercurial_info(sys.executable)
More information about the Pypy-commit
mailing list