Re: [pypy-dev] [pypy-svn] pypy commit 7b8aa74da1fb: Handle output on standard error when invoking Mercurial.

2010-12-14 Thread Maciej Fijalkowski
This commit contains no tests whatsoever, it would be cooler if it did.

On Tue, Dec 14, 2010 at 8:19 PM, Bitbucket
commits-nore...@bitbucket.org wrote:
 # HG changeset patch -- Bitbucket.org
 # Project pypy
 # URL http://bitbucket.org/pypy/pypy/overview
 # User Dan Villiom Podlaski Christiansen dan...@gmail.com
 # 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
 pypy-...@codespeak.net
 http://codespeak.net/mailman/listinfo/pypy-svn

___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev

Re: [pypy-dev] [pypy-svn] pypy commit 7b8aa74da1fb: Handle output on standard error when invoking Mercurial.

2010-12-14 Thread Dan Villiom Podlaski Christiansen

On 14 Dec 2010, at 20:01, Maciej Fijalkowski wrote:

This commit contains no tests whatsoever, it would be cooler if it  
did.


Antonio kindly wrote a test for the functionality in an earlier  
changeset. Ironically, I broke it that change, but that's fixed now :)


--

Dan Villiom Podlaski Christiansen
dan...@gmail.com



smime.p7s
Description: S/MIME cryptographic signature
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev

Re: [pypy-dev] [pypy-svn] pypy commit 7b8aa74da1fb: Handle output on standard error when invoking Mercurial.

2010-12-14 Thread Antonio Cuni
On 14/12/10 20:28, Dan Villiom Podlaski Christiansen wrote:
 On 14 Dec 2010, at 20:01, Maciej Fijalkowski wrote:
 
 This commit contains no tests whatsoever, it would be cooler if it did.
 
 Antonio kindly wrote a test for the functionality in an earlier changeset.
 Ironically, I broke it that change, but that's fixed now :)

anyway, maciek on the channel mentioned a way to test it without messing with
the hg repo: you can provide a custom hgexe script which returns whatever you
want.

Or even, restructure the code in a way that the running of the hg command is
decoupled by the parsing of its results, so that you can at least test the 
latter.

Sorry, I should have pointed this out when you asked me to review the patches,
but today I was fried and had thousands of things to look at :-/

ciao,
Anto
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev