Add a flag not print errors in CaptureSVN()

Review URL: http://codereview.chromium.org/113288

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@15887 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 16 years ago
parent be0d1ca0e4
commit 5c3a2ff6a2

@ -491,7 +491,7 @@ def RunSVN(args, in_directory):
SubprocessCall(c, 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. """Runs svn, capturing output sent to stdout as a string.
Args: Args:
@ -508,10 +508,14 @@ def CaptureSVN(args, in_directory):
# the svn.exe executable, but shell=True makes subprocess on Linux fail # 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 # when it's called with a list because it only tries to execute the
# first string ("svn"). # first string ("svn").
stderr = None
if print_error:
stderr = subprocess.PIPE
return subprocess.Popen(c, return subprocess.Popen(c,
cwd=in_directory, cwd=in_directory,
shell=(sys.platform == 'win32'), shell=(sys.platform == 'win32'),
stdout=subprocess.PIPE).communicate()[0] stdout=subprocess.PIPE,
stderr=stderr).communicate()[0]
def RunSVNAndGetFileList(args, in_directory, file_list): def RunSVNAndGetFileList(args, in_directory, file_list):
@ -560,7 +564,7 @@ def RunSVNAndGetFileList(args, in_directory, file_list):
capture_list=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. """Returns a dictionary from the svn info output for the given file.
Args: Args:
@ -568,7 +572,7 @@ def CaptureSVNInfo(relpath, in_directory=None):
the directory given by in_directory. the directory given by in_directory.
in_directory: The directory where svn is to be run. 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) dom = ParseXML(output)
result = {} result = {}
if dom: if dom:

@ -1273,7 +1273,8 @@ class SCMWrapperTestCase(GClientBaseTestCase):
</entry> </entry>
</info> </info>
""" % self.url """ % self.url
gclient.CaptureSVN(['info', '--xml', self.url], '.').AndReturn(xml_text) gclient.CaptureSVN(['info', '--xml', self.url],
'.', True).AndReturn(xml_text)
expected = { expected = {
'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d', 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d',
'UUID': None, 'UUID': None,
@ -1286,7 +1287,7 @@ class SCMWrapperTestCase(GClientBaseTestCase):
'Node Kind': 'file', 'Node Kind': 'file',
} }
self.mox.ReplayAll() 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.assertEquals(sorted(file_info.items()), sorted(expected.items()))
self.mox.VerifyAll() self.mox.VerifyAll()
@ -1314,9 +1315,10 @@ class SCMWrapperTestCase(GClientBaseTestCase):
</entry> </entry>
</info> </info>
""" % (self.url, self.root_dir) """ % (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() self.mox.ReplayAll()
file_info = self._CaptureSVNInfo(self.url, '.') file_info = self._CaptureSVNInfo(self.url, '.', True)
expected = { expected = {
'URL': self.url, 'URL': self.url,
'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb', 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb',

Loading…
Cancel
Save