Commit ffcdf35a authored by jamescook's avatar jamescook Committed by Commit bot

tools: Make mass-rename.py print progress as it works

It takes a couple seconds per file, so when you're renaming hundreds of
files it can look broken.

Format is:
[1/234] Moving: my_file.cc

BUG=none
TEST=manual, run it after a git mv

Review-Url: https://codereview.chromium.org/2807813002
Cr-Commit-Position: refs/heads/master@{#463035}
parent fd898973
...@@ -28,13 +28,18 @@ def main(): ...@@ -28,13 +28,18 @@ def main():
out, _ = popen.communicate() out, _ = popen.communicate()
if popen.returncode != 0: if popen.returncode != 0:
return 1 return 1
for line in out.splitlines(): lines = out.splitlines()
for item, line in enumerate(lines, 1):
# Print progress
print '[%d/%d]' % (item, len(lines)),
parts = line.split('\t') parts = line.split('\t')
if len(parts) != 3: if len(parts) != 3:
print 'Skipping: %s -- not a rename?' % parts print 'Skipping: %s -- not a rename?' % parts
continue continue
attrs, fro, to = parts attrs, fro, to = parts
if attrs.split()[4].startswith('R'): if attrs.split()[4].startswith('R'):
print 'Moving: %s' % fro
subprocess.check_call([ subprocess.check_call([
sys.executable, sys.executable,
os.path.join(BASE_DIR, 'move_source_file.py'), os.path.join(BASE_DIR, 'move_source_file.py'),
......
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