Chromium Code Reviews| Index: tools/safely-roll-deps.py |
| diff --git a/tools/safely-roll-deps.py b/tools/safely-roll-deps.py |
| index 08713484c71c5151455076ec8c25e3375fb0977e..7b32336eb5f5e235b1e653da3c975a60d4895ae4 100755 |
| --- a/tools/safely-roll-deps.py |
| +++ b/tools/safely-roll-deps.py |
| @@ -45,6 +45,17 @@ def process_deps(path, project, new_rev, is_dry_run): |
| return old_rev |
| +class PrintSubprocess(object): |
| + """Wrapper for subprocess2 which prints out every command.""" |
| + def __getattr__(self, attr): |
| + def _run_subprocess2(cmd, *args, **kwargs): |
| + print cmd |
|
M-A Ruel
2014/05/02 16:34:41
you'll want to sys.stdout.flush()
borenet
2014/05/02 19:51:15
Done.
|
| + return getattr(subprocess2, attr)(cmd, *args, **kwargs) |
| + return _run_subprocess2 |
| + |
| +prnt_subprocess = PrintSubprocess() |
| + |
| + |
| def main(): |
| tool_dir = os.path.dirname(os.path.abspath(__file__)) |
| parser = optparse.OptionParser(usage='%prog [options] <project> <new rev>', |
| @@ -87,8 +98,8 @@ def main(): |
| os.environ['EDITOR'] = 'true' |
| if options.force and not options.dry_run: |
| - subprocess2.check_call(['git', 'clean', '-d', '-f']) |
| - subprocess2.call(['git', 'rebase', '--abort']) |
| + prnt_subprocess.check_call(['git', 'clean', '-d', '-f']) |
| + prnt_subprocess.call(['git', 'rebase', '--abort']) |
| old_branch = scm.GIT.GetBranch(root_dir) |
| new_branch = '%s_roll' % project |
| @@ -99,19 +110,19 @@ def main(): |
| if old_branch == new_branch: |
| if options.force: |
| if not options.dry_run: |
| - subprocess2.check_call(['git', 'checkout', options.upstream, '-f']) |
| - subprocess2.call(['git', 'branch', '-D', old_branch]) |
| + prnt_subprocess.check_call(['git', 'checkout', options.upstream, '-f']) |
| + prnt_subprocess.call(['git', 'branch', '-D', old_branch]) |
| else: |
| parser.error('Please delete the branch %s and move to a different branch' |
| % new_branch) |
| if not options.dry_run: |
| - subprocess2.check_call(['git', 'fetch', 'origin']) |
| - subprocess2.call(['git', 'svn', 'fetch']) |
| + prnt_subprocess.check_call(['git', 'fetch', 'origin']) |
| + prnt_subprocess.call(['git', 'svn', 'fetch']) |
| branch_cmd = ['git', 'checkout', '-b', new_branch, options.upstream] |
| if options.force: |
| branch_cmd.append('-f') |
| - subprocess2.check_output(branch_cmd) |
| + prnt_subprocess.check_output(branch_cmd) |
| try: |
| old_rev = int(process_deps(os.path.join(root_dir, 'DEPS'), project, new_rev, |
| @@ -127,8 +138,9 @@ def main(): |
| print 'Commit message: ' + commit_msg |
| return 0 |
| - subprocess2.check_output(['git', 'commit', '-m', commit_msg, 'DEPS']) |
| - subprocess2.check_call(['git', 'diff', '--no-ext-diff', options.upstream]) |
| + prnt_subprocess.check_output(['git', 'commit', '-m', commit_msg, 'DEPS']) |
| + prnt_subprocess.check_call(['git', 'diff', '--no-ext-diff', |
| + options.upstream]) |
| upload_cmd = ['git', 'cl', 'upload'] |
| if options.commit: |
| upload_cmd.append('--use-commit-queue') |
| @@ -136,11 +148,11 @@ def main(): |
| upload_cmd.append('--send-mail') |
| if options.cc: |
| upload_cmd.extend(['--cc', options.cc]) |
| - subprocess2.check_call(upload_cmd) |
| + prnt_subprocess.check_call(upload_cmd) |
| finally: |
| if not options.dry_run: |
| - subprocess2.check_output(['git', 'checkout', old_branch]) |
| - subprocess2.check_output(['git', 'branch', '-D', new_branch]) |
| + prnt_subprocess.check_output(['git', 'checkout', old_branch]) |
| + prnt_subprocess.check_output(['git', 'branch', '-D', new_branch]) |
| return 0 |