[PATCH 6 of 6] subrepo: silence git output when ui.quiet is set

Eric Eisner ede at MIT.EDU
Thu Dec 9 15:53:29 CST 2010


# HG changeset patch
# User Eric Eisner <ede at mit.edu>
# Date 1291931534 18000
# Node ID 560b8001f76595474d5afe321107c432a185b900
# Parent  cad35f06c031f0e653ade1003fd9fb6939e3ee66
subrepo: silence git output when ui.quiet is set

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -623,10 +623,14 @@ class gitsubrepo(abstractsubrepo):
         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
 
diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -81,8 +81,7 @@ clone root
 
 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


More information about the Mercurial-devel mailing list