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

Side by Side Diff: tools/git/move_source_file.py

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/clang/scripts/update.py ('k') | tools/relocation_packer/BUILD.gn » ('j') | 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 (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Moves C++ files to a new location, updating any include paths that point 6 """Moves C++ files to a new location, updating any include paths that point
7 to them, and re-ordering headers as needed. If multiple source files are 7 to them, and re-ordering headers as needed. If multiple source files are
8 specified, the destination must be a directory. Updates include guards in 8 specified, the destination must be a directory. Updates include guards in
9 moved header files. Assumes Chromium coding style. 9 moved header files. Assumes Chromium coding style.
10 10
(...skipping 13 matching lines...) Expand all
24 import subprocess 24 import subprocess
25 import sys 25 import sys
26 26
27 import mffr 27 import mffr
28 28
29 if __name__ == '__main__': 29 if __name__ == '__main__':
30 # Need to add the directory containing sort-headers.py to the Python 30 # Need to add the directory containing sort-headers.py to the Python
31 # classpath. 31 # classpath.
32 sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..'))) 32 sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..')))
33 sort_headers = __import__('sort-headers') 33 sort_headers = __import__('sort-headers')
34 import sort_sources
35 34
36 35
37 HANDLED_EXTENSIONS = ['.cc', '.mm', '.h', '.hh', '.cpp'] 36 HANDLED_EXTENSIONS = ['.cc', '.mm', '.h', '.hh', '.cpp']
38 37
39 38
40 def IsHandledFile(path): 39 def IsHandledFile(path):
41 return os.path.splitext(path)[1] in HANDLED_EXTENSIONS 40 return os.path.splitext(path)[1] in HANDLED_EXTENSIONS
42 41
43 42
44 def MakeDestinationPath(from_path, to_path): 43 def MakeDestinationPath(from_path, to_path):
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 parts = re.split(r"[/\\]", path, 1) 135 parts = re.split(r"[/\\]", path, 1)
137 if len(parts) == 2: 136 if len(parts) == 2:
138 return (parts[0], parts[1]) 137 return (parts[0], parts[1])
139 else: 138 else:
140 return (parts[0], '') 139 return (parts[0], '')
141 140
142 visiting_directory = '' 141 visiting_directory = ''
143 from_rest = from_path 142 from_rest = from_path
144 to_rest = to_path 143 to_rest = to_path
145 while True: 144 while True:
146 files_with_changed_sources = mffr.MultiFileFindReplace( 145 mffr.MultiFileFindReplace(
147 r'([\'"])%s([\'"])' % from_rest, 146 r'([\'"])%s([\'"])' % from_rest,
148 r'\1%s\2' % to_rest, 147 r'\1%s\2' % to_rest,
149 [os.path.join(visiting_directory, 'BUILD.gn'), 148 [os.path.join(visiting_directory, 'BUILD.gn'),
150 os.path.join(visiting_directory, '*.gyp*')]) 149 os.path.join(visiting_directory, '*.gyp*')])
151 for changed_file in files_with_changed_sources:
152 sort_sources.ProcessFile(changed_file, should_confirm=False)
153 from_first, from_rest = SplitByFirstComponent(from_rest) 150 from_first, from_rest = SplitByFirstComponent(from_rest)
154 to_first, to_rest = SplitByFirstComponent(to_rest) 151 to_first, to_rest = SplitByFirstComponent(to_rest)
155 visiting_directory = os.path.join(visiting_directory, from_first) 152 visiting_directory = os.path.join(visiting_directory, from_first)
156 if not from_rest or not to_rest: 153 if not from_rest or not to_rest:
157 break 154 break
158 155
159 156
160 def MakeIncludeGuardName(path_from_root): 157 def MakeIncludeGuardName(path_from_root):
161 """Returns an include guard name given a path from root.""" 158 """Returns an include guard name given a path from root."""
162 guard = path_from_root.replace('/', '_') 159 guard = path_from_root.replace('/', '_')
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 continue 223 continue
227 to_path = MakeDestinationPath(from_path, orig_to_path) 224 to_path = MakeDestinationPath(from_path, orig_to_path)
228 if not opts.already_moved: 225 if not opts.already_moved:
229 MoveFile(from_path, to_path) 226 MoveFile(from_path, to_path)
230 UpdatePostMove(from_path, to_path) 227 UpdatePostMove(from_path, to_path)
231 return 0 228 return 0
232 229
233 230
234 if __name__ == '__main__': 231 if __name__ == '__main__':
235 sys.exit(main()) 232 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/clang/scripts/update.py ('k') | tools/relocation_packer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698