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

Side by Side Diff: tools/git/mass-rename.py

Issue 2807813002: tools: Make mass-rename.py print progress as it works (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 mass-rename: update source files (gyp lists, #includes) to reflect 7 mass-rename: update source files (gyp lists, #includes) to reflect
8 a rename. Expects "git diff --cached -M" to list a bunch of renames. 8 a rename. Expects "git diff --cached -M" to list a bunch of renames.
9 9
10 To use: 10 To use:
(...skipping 10 matching lines...) Expand all
21 21
22 BASE_DIR = os.path.abspath(os.path.dirname(__file__)) 22 BASE_DIR = os.path.abspath(os.path.dirname(__file__))
23 23
24 24
25 def main(): 25 def main():
26 popen = subprocess.Popen('git diff --cached --raw -M', 26 popen = subprocess.Popen('git diff --cached --raw -M',
27 shell=True, stdout=subprocess.PIPE) 27 shell=True, stdout=subprocess.PIPE)
28 out, _ = popen.communicate() 28 out, _ = popen.communicate()
29 if popen.returncode != 0: 29 if popen.returncode != 0:
30 return 1 30 return 1
31 for line in out.splitlines(): 31 item = 1
32 lines = out.splitlines()
33 for line in lines:
Dirk Pranke 2017/04/07 22:06:52 Nit: can use: for item, line in enumerate(lines
34 # Print progress
35 print '[%d/%d]' % (item, len(lines)),
36 item = item + 1
37
32 parts = line.split('\t') 38 parts = line.split('\t')
33 if len(parts) != 3: 39 if len(parts) != 3:
34 print 'Skipping: %s -- not a rename?' % parts 40 print 'Skipping: %s -- not a rename?' % parts
35 continue 41 continue
36 attrs, fro, to = parts 42 attrs, fro, to = parts
37 if attrs.split()[4].startswith('R'): 43 if attrs.split()[4].startswith('R'):
44 print 'Moving: %s' % fro
38 subprocess.check_call([ 45 subprocess.check_call([
39 sys.executable, 46 sys.executable,
40 os.path.join(BASE_DIR, 'move_source_file.py'), 47 os.path.join(BASE_DIR, 'move_source_file.py'),
41 '--already_moved', 48 '--already_moved',
42 '--no_error_for_non_source_file', 49 '--no_error_for_non_source_file',
43 fro, to]) 50 fro, to])
44 else: 51 else:
45 print 'Skipping: %s -- not a rename?' % fro 52 print 'Skipping: %s -- not a rename?' % fro
46 return 0 53 return 0
47 54
48 55
49 if __name__ == '__main__': 56 if __name__ == '__main__':
50 sys.exit(main()) 57 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698