Commit ac61023c authored by maruel@chromium.org's avatar maruel@chromium.org

Fix a bug in gclient recurse for git-svn users. Make gclient_utils.CheckCall more versatile.

TEST=none
BUG=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@62400 0039d316-1c4b-4281-b951-d872f2087c98
parent ed8b178c
......@@ -888,9 +888,12 @@ def CMDrecurse(parser, args):
if scm_set and scm not in scm_set:
continue
cwd = os.path.normpath(os.path.join(root, path))
env['GCLIENT_SCM'] = scm
env['GCLIENT_URL'] = url
subprocess.Popen(args, cwd=cwd, env=env).communicate()
if scm:
env['GCLIENT_SCM'] = scm
if url:
env['GCLIENT_URL'] = url
gclient_utils.Popen(args, cwd=cwd, env=env).communicate()
return 0
@attr('usage', '[url] [safesync url]')
......
......@@ -84,7 +84,7 @@ def Popen(args, **kwargs):
raise
def CheckCall(command, cwd=None, print_error=True):
def CheckCall(command, print_error=True, **kwargs):
"""Similar subprocess.check_call() but redirects stdout and
returns (stdout, stderr).
......@@ -94,12 +94,13 @@ def CheckCall(command, cwd=None, print_error=True):
stderr = None
if not print_error:
stderr = subprocess.PIPE
process = Popen(command, cwd=cwd, stdout=subprocess.PIPE, stderr=stderr)
process = Popen(command, stdout=subprocess.PIPE, stderr=stderr, **kwargs)
std_out, std_err = process.communicate()
except OSError, e:
raise CheckCallError(command, cwd, e.errno, None)
raise CheckCallError(command, kwargs.get('cwd', None), e.errno, None)
if process.returncode:
raise CheckCallError(command, cwd, process.returncode, std_out, std_err)
raise CheckCallError(command, kwargs.get('cwd', None), process.returncode,
std_out, std_err)
return std_out, std_err
......
......@@ -43,19 +43,19 @@ class CheckCallTestCase(GclientUtilBase):
process = self.mox.CreateMockAnything()
process.returncode = 0
gclient_utils.Popen(
args, cwd=None,
args, cwd='bar',
stderr=None,
stdout=gclient_utils.subprocess.PIPE).AndReturn(process)
process.communicate().AndReturn(['bleh', 'foo'])
self.mox.ReplayAll()
gclient_utils.CheckCall(args)
gclient_utils.CheckCall(args, cwd='bar')
def testCheckCallFailure(self):
args = ['boo', 'foo', 'bar']
process = self.mox.CreateMockAnything()
process.returncode = 42
gclient_utils.Popen(
args, cwd=None,
args,
stderr=None,
stdout=gclient_utils.subprocess.PIPE).AndReturn(process)
process.communicate().AndReturn(['bleh', 'foo'])
......
......@@ -436,8 +436,8 @@ def GuessVCS(options, path):
# Git has a command to test if you're in a git tree.
# Try running it, but don't die if we don't have git installed.
try:
gclient_utils.CheckCall(["git", "rev-parse", "--is-inside-work-tree"],
real_path)
gclient_utils.CheckCall(['git', 'rev-parse', '--is-inside-work-tree'],
cwd=real_path)
return GIT(options, path)
except gclient_utils.CheckCallError, e:
if e.returncode != errno.ENOENT and e.returncode != 128:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment