subrepo: silence git output when ui.quiet is set
authorEric Eisner <ede@mit.edu>
Thu, 09 Dec 2010 16:52:14 -0500
changeset 13111 560b8001f765
parent 13110 cad35f06c031
child 13112 039a964dbbb3
subrepo: silence git output when ui.quiet is set
mercurial/subrepo.py
tests/test-subrepo-git.t
--- 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