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

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

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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/valgrind/chrome_tests.py » ('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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 def MakeDestinationPath(from_path, to_path): 43 def MakeDestinationPath(from_path, to_path):
44 """Given the from and to paths, return a correct destination path. 44 """Given the from and to paths, return a correct destination path.
45 45
46 The initial destination path may either a full path or a directory. 46 The initial destination path may either a full path or a directory.
47 Also does basic sanity checks. 47 Also does basic sanity checks.
48 """ 48 """
49 if not IsHandledFile(from_path): 49 if not IsHandledFile(from_path):
50 raise Exception('Only intended to move individual source files ' 50 raise Exception('Only intended to move individual source files '
51 '(%s does not have a recognized extension).' % 51 '(%s does not have a recognized extension).' %
52 from_path) 52 from_path)
53
54 # Remove '.', '..', etc.
55 to_path = os.path.normpath(to_path)
56
53 if os.path.isdir(to_path): 57 if os.path.isdir(to_path):
54 to_path = os.path.join(to_path, os.path.basename(from_path)) 58 to_path = os.path.join(to_path, os.path.basename(from_path))
55 else: 59 else:
56 dest_extension = os.path.splitext(to_path)[1] 60 dest_extension = os.path.splitext(to_path)[1]
57 if dest_extension not in HANDLED_EXTENSIONS: 61 if dest_extension not in HANDLED_EXTENSIONS:
58 raise Exception('Destination must be either a full path with ' 62 raise Exception('Destination must be either a full path with '
59 'a recognized extension or a directory.') 63 'a recognized extension or a directory.')
60 return to_path 64 return to_path
61 65
62 66
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 continue 189 continue
186 to_path = MakeDestinationPath(from_path, orig_to_path) 190 to_path = MakeDestinationPath(from_path, orig_to_path)
187 if not opts.already_moved: 191 if not opts.already_moved:
188 MoveFile(from_path, to_path) 192 MoveFile(from_path, to_path)
189 UpdatePostMove(from_path, to_path) 193 UpdatePostMove(from_path, to_path)
190 return 0 194 return 0
191 195
192 196
193 if __name__ == '__main__': 197 if __name__ == '__main__':
194 sys.exit(main()) 198 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/clang/scripts/update.py ('k') | tools/valgrind/chrome_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698