This commit contains no tests whatsoever, it would be cooler if it did.
On Tue, Dec 14, 2010 at 8:19 PM, Bitbucket <[email protected]> wrote: > # HG changeset patch -- Bitbucket.org > # Project pypy > # URL http://bitbucket.org/pypy/pypy/overview > # User Dan Villiom Podlaski Christiansen <[email protected]> > # Date 1292349796 -3600 > # Node ID 7b8aa74da1fb06bd5af8b37e086538e4e7d5d0a1 > # Parent 1f81ed99bfbc17bbb3cc0920ac612218b4194f8c > Handle output on standard error when invoking Mercurial. > > Instead of just piped to the process standard error, we use a logger > to warn if 'hg' wrote anything on stderr. > > --- a/pypy/tool/version.py > +++ b/pypy/tool/version.py > @@ -13,24 +13,39 @@ def get_mercurial_info(): > hgexe = py.path.local.sysfind('hg') > > if hgexe and os.path.isdir(os.path.join(pypyroot, '.hg')): > + 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) > + > env = dict(os.environ) > # get Mercurial into scripting mode > env['HGPLAIN'] = '1' > # disable user configuration, extensions, etc. > env['HGRCPATH'] = os.devnull > > - p = Popen([str(hgexe), 'id', '-i', pypyroot], stdout=PIPE, env=env) > + p = Popen([str(hgexe), 'id', '-i', pypyroot], > + stdout=PIPE, stderr=PIPE, env=env) > hgid = p.stdout.read().strip() > + maywarn(p.stderr.read()) > > - p = Popen([str(hgexe), 'id', '-t', pypyroot], stdout=PIPE, env=env) > + p = Popen([str(hgexe), 'id', '-t', pypyroot], > + stdout=PIPE, stderr=PIPE, env=env) > hgtags = [t for t in p.stdout.read().strip().split() if t != 'tip'] > + maywarn(p.stderr.read()) > > if hgtags: > return 'PyPy', hgtags[0], hgid > else: > # use the branch instead > - p = Popen([str(hgexe), 'id', '-b', pypyroot], stdout=PIPE, > env=env) > + p = Popen([str(hgexe), 'id', '-b', pypyroot], > + stdout=PIPE, stderr=PIPE, env=env) > hgbranch = p.stdout.read().strip() > + maywarn(p.stderr.read()) > > return 'PyPy', hgbranch, hgid > else: > _______________________________________________ > pypy-svn mailing list > [email protected] > http://codespeak.net/mailman/listinfo/pypy-svn > _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
