Index: tools/safely-roll-deps.py |
diff --git a/tools/safely-roll-deps.py b/tools/safely-roll-deps.py |
index 08713484c71c5151455076ec8c25e3375fb0977e..2f1e490764fbae1080fe422315143f7c8b700ad4 100755 |
--- a/tools/safely-roll-deps.py |
+++ b/tools/safely-roll-deps.py |
@@ -45,6 +45,18 @@ 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 |
+ sys.stdout.flush() |
+ 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 +99,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 +111,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 +139,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 +149,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 |