changeset 13111:560b8001f765

subrepo: silence git output when ui.quiet is set
author Eric Eisner <ede@mit.edu>
date Thu, 09 Dec 2010 16:52:14 -0500
parents cad35f06c031
children 039a964dbbb3
files mercurial/subrepo.py tests/test-subrepo-git.t
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Thu Dec 09 16:52:14 2010 -0500
+++ b/mercurial/subrepo.py	Thu Dec 09 16:52:14 2010 -0500
@@ -623,10 +623,14 @@
         are not supported and very probably fail.
         """
         self._ui.debug('%s: git %s\n' % (self._relpath, ' '.join(commands)))
-        # print git's stderr, which is mostly progress and useful info
+        # unless ui.quiet is set, print git's stderr,
+        # which is mostly progress and useful info
+        errpipe = None
+        if self._ui.quiet:
+            errpipe = open(os.devnull, 'w')
         p = subprocess.Popen(['git'] + commands, bufsize=-1, cwd=cwd, env=env,
                              close_fds=util.closefds,
-                             stdout=subprocess.PIPE)
+                             stdout=subprocess.PIPE, stderr=errpipe)
         if stream:
             return p.stdout, None
 
--- a/tests/test-subrepo-git.t	Thu Dec 09 16:52:14 2010 -0500
+++ b/tests/test-subrepo-git.t	Thu Dec 09 16:52:14 2010 -0500
@@ -81,8 +81,7 @@
 
 update to previous substate
 
-  $ hg update 1 2>/dev/null
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg update 1 -q
   $ cat s/g
   g
   $ hg debugsub