From 5cc6c57bf5f0444413785cdba8541a05f69ca711 Mon Sep 17 00:00:00 2001 From: "dpranke@google.com" Date: Fri, 6 Nov 2009 20:04:56 +0000 Subject: [PATCH] Fix output reordering when you get a conflict on an update. If you're not running gclient sync with --verbose and you get a conflict on a file, the conflict message prints *before* the message that you're running update in the appropriate directory. This is happening because we intercept stdout but not stderr, and the conflict prompt goes to stderr. redirecting stderr in the popen() to the pipe fixes this. R=maruel@chromium.org BUG=none TEST=none Review URL: http://codereview.chromium.org/373003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@31276 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_utils.py | 3 ++- tests/gclient_test.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gclient_utils.py b/gclient_utils.py index 913e8b13a..d21467fd7 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -209,7 +209,8 @@ def SubprocessCallAndFilter(command, # executable, but shell=True makes subprocess on Linux fail when it's called # with a list because it only tries to execute the first item in the list. kid = subprocess.Popen(command, bufsize=0, cwd=in_directory, - shell=(sys.platform == 'win32'), stdout=subprocess.PIPE) + shell=(sys.platform == 'win32'), stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) # Also, we need to forward stdout to prevent weird re-ordering of output. # This has to be done on a per byte basis to make sure it is not buffered: diff --git a/tests/gclient_test.py b/tests/gclient_test.py index 6638de4e9..c04bd6302 100644 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -1071,7 +1071,8 @@ class SubprocessCallAndFilterTestCase(BaseTestCase): gclient.sys.stdout.write(i) gclient_utils.subprocess.Popen(command, bufsize=0, cwd=in_directory, shell=(gclient.sys.platform == 'win32'), - stdout=gclient_utils.subprocess.PIPE).AndReturn(kid) + stdout=gclient_utils.subprocess.PIPE, + stderr=gclient_utils.subprocess.STDOUT).AndReturn(kid) self.mox.ReplayAll() compiled_pattern = re.compile(pattern) line_list = []