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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 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 | « tools/git/graph.sh ('k') | tools/git/mass-rename.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """
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.
9
10 To use:
11 1) git mv foo1 bar1; git mv foo2 bar2; etc.
12 2) *without committing*, ./tools/git/mass-rename.py
13 3) look at git diff (without --cached) to see what the damage is
14 """
15
16
17 import os
18 import subprocess
19 import sys
20
21
22 BASE_DIR = os.path.abspath(os.path.dirname(__file__))
23
24
25 def main():
26 popen = subprocess.Popen('git diff --cached --raw -M',
27 shell=True, stdout=subprocess.PIPE)
28 out, _ = popen.communicate()
29 if popen.returncode != 0:
30 return 1
31 for line in out.splitlines():
32 parts = line.split('\t')
33 if len(parts) != 3:
34 print 'Skipping: %s -- not a rename?' % parts
35 continue
36 attrs, fro, to = parts
37 if attrs.split()[4].startswith('R'):
38 subprocess.check_call([
39 sys.executable,
40 os.path.join(BASE_DIR, 'move_source_file.py'),
41 '--already_moved',
42 '--no_error_for_non_source_file',
43 fro, to])
44 else:
45 print 'Skipping: %s -- not a rename?' % fro
46 return 0
47
48
49 if __name__ == '__main__':
50 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/git/graph.sh ('k') | tools/git/mass-rename.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698