Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Issue 3737001: Fix a bug in gclient recurse for git-svn users. Make gclient_utils.CheckCall more versatile. (Closed)

Created:
10 years, 2 months ago by M-A Ruel
Modified:
9 years, 7 months ago
Reviewers:
Nicolas Sylvain
CC:
chromium-reviews, M-A Ruel
Visibility:
Public.

Description

Fix a bug in gclient recurse for git-svn users. Make gclient_utils.CheckCall more versatile. TEST=none BUG=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=62400

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+16 lines, -12 lines) Patch
M gclient.py View 1 chunk +6 lines, -3 lines 0 comments Download
M gclient_utils.py View 2 chunks +5 lines, -4 lines 0 comments Download
M tests/gclient_utils_test.py View 1 chunk +3 lines, -3 lines 0 comments Download
M trychange.py View 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
M-A Ruel
10 years, 2 months ago (2010-10-12 14:26:04 UTC) #1
Nicolas Sylvain
10 years, 2 months ago (2010-10-13 03:50:33 UTC) #2
lgtm

On Tue, Oct 12, 2010 at 7:26 AM, <maruel@chromium.org> wrote:

> Reviewers: Nicolas Sylvain,
>
> Description:
> Fix a bug in gclient recurse for git-svn users. Make
> gclient_utils.CheckCall
> more versatile.
>
> TEST=none
> BUG=none
>
> Please review this at http://codereview.chromium.org/3737001/show
>
> Affected files:
>  M gclient.py
>  M gclient_utils.py
>  M tests/gclient_utils_test.py
>  M trychange.py
>
>
> Index: gclient.py
> diff --git a/gclient.py b/gclient.py
> index
>
9cf30c76cb6fb4bb659f71f153549452bca6433e..989a1c418d5ec309204a778131ed68ebe8ed0dcc
> 100644
> --- a/gclient.py
> +++ b/gclient.py
> @@ -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]')
> Index: gclient_utils.py
> diff --git a/gclient_utils.py b/gclient_utils.py
> index
>
3c374d5a3d5726c0dca6c0cba2af3b2801f6c5fb..743e57bc163ed7dfb751686e5687d8f64ebbfc29
> 100644
> --- a/gclient_utils.py
> +++ b/gclient_utils.py
> @@ -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
>
>
> Index: tests/gclient_utils_test.py
> diff --git a/tests/gclient_utils_test.py b/tests/gclient_utils_test.py
> index
>
b81775dcec548a0cf9e0db80d2f4ed4e071cbace..ee05aae20357292c247cd61b49327f34f887344c
> 100755
> --- a/tests/gclient_utils_test.py
> +++ b/tests/gclient_utils_test.py
> @@ -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'])
> Index: trychange.py
> diff --git a/trychange.py b/trychange.py
> index
>
1cc6ac957357dabac07b55f6ce69cefa76658254..54161b97073e2eaf71c6bed1c229ae0499244455
> 100755
> --- a/trychange.py
> +++ b/trychange.py
> @@ -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:
>
>
>

Powered by Google App Engine
This is Rietveld 408576698