diff --git a/gclient.py b/gclient.py index c39f40fc1..f190b4e1f 100755 --- a/gclient.py +++ b/gclient.py @@ -491,7 +491,7 @@ def RunSVN(args, in_directory): SubprocessCall(c, in_directory) -def CaptureSVN(args, in_directory): +def CaptureSVN(args, in_directory=None, print_error=True): """Runs svn, capturing output sent to stdout as a string. Args: @@ -508,10 +508,14 @@ def CaptureSVN(args, in_directory): # the svn.exe executable, but shell=True makes subprocess on Linux fail # when it's called with a list because it only tries to execute the # first string ("svn"). + stderr = None + if print_error: + stderr = subprocess.PIPE return subprocess.Popen(c, cwd=in_directory, shell=(sys.platform == 'win32'), - stdout=subprocess.PIPE).communicate()[0] + stdout=subprocess.PIPE, + stderr=stderr).communicate()[0] def RunSVNAndGetFileList(args, in_directory, file_list): @@ -560,7 +564,7 @@ def RunSVNAndGetFileList(args, in_directory, file_list): capture_list=file_list) -def CaptureSVNInfo(relpath, in_directory=None): +def CaptureSVNInfo(relpath, in_directory=None, print_error=True): """Returns a dictionary from the svn info output for the given file. Args: @@ -568,7 +572,7 @@ def CaptureSVNInfo(relpath, in_directory=None): the directory given by in_directory. in_directory: The directory where svn is to be run. """ - output = CaptureSVN(["info", "--xml", relpath], in_directory) + output = CaptureSVN(["info", "--xml", relpath], in_directory, print_error) dom = ParseXML(output) result = {} if dom: diff --git a/tests/gclient_test.py b/tests/gclient_test.py index 18498ab63..b31d9e3e0 100644 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -1273,7 +1273,8 @@ class SCMWrapperTestCase(GClientBaseTestCase): """ % self.url - gclient.CaptureSVN(['info', '--xml', self.url], '.').AndReturn(xml_text) + gclient.CaptureSVN(['info', '--xml', self.url], + '.', True).AndReturn(xml_text) expected = { 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', 'UUID': None, @@ -1286,7 +1287,7 @@ class SCMWrapperTestCase(GClientBaseTestCase): 'Node Kind': 'file', } self.mox.ReplayAll() - file_info = self._CaptureSVNInfo(self.url, '.') + file_info = self._CaptureSVNInfo(self.url, '.', True) self.assertEquals(sorted(file_info.items()), sorted(expected.items())) self.mox.VerifyAll() @@ -1314,9 +1315,10 @@ class SCMWrapperTestCase(GClientBaseTestCase): """ % (self.url, self.root_dir) - gclient.CaptureSVN(['info', '--xml', self.url], '.').AndReturn(xml_text) + gclient.CaptureSVN(['info', '--xml', self.url], + '.', True).AndReturn(xml_text) self.mox.ReplayAll() - file_info = self._CaptureSVNInfo(self.url, '.') + file_info = self._CaptureSVNInfo(self.url, '.', True) expected = { 'URL': self.url, 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb',