[pypy-svn] pypy commit 664c214b9d22: sys._mercurial: warn failing to get any info at all.

Bitbucket commits-noreply at bitbucket.org
Tue Dec 14 19:19:47 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 1292350443 -3600
# Node ID 664c214b9d22ba8f74eac5ba8bcbdb1f756490bf
# Parent  7b8aa74da1fb06bd5af8b37e086538e4e7d5d0a1
sys._mercurial: warn failing to get any info at all.

Also, the result in these cases is changed from None to ('PyPy', '', '').

--- a/pypy/tool/version.py
+++ b/pypy/tool/version.py
@@ -12,16 +12,22 @@ def get_mercurial_info():
     pypyroot = os.path.abspath(os.path.join(pypydir, '..'))
     hgexe = py.path.local.sysfind('hg')
 
-    if hgexe and os.path.isdir(os.path.join(pypyroot, '.hg')):
-        def maywarn(err):
-            if not err:
-                return
+    def maywarn(err):
+        if not err:
+            return
 
-            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)
+        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)
 
+    if not os.path.isdir(os.path.join(pypyroot, '.hg')):
+        maywarn('Not running from a Mercurial repository!')
+        return 'PyPy', '', ''
+    elif not hgexe:
+        maywarn('Cannot find Mercurial command!')
+        return 'PyPy', '', ''
+    else:
         env = dict(os.environ)
         # get Mercurial into scripting mode
         env['HGPLAIN'] = '1'
@@ -48,5 +54,3 @@ def get_mercurial_info():
             maywarn(p.stderr.read())
 
             return 'PyPy', hgbranch, hgid
-    else:
-        return None



More information about the Pypy-commit mailing list