summaryrefslogtreecommitdiffstats
path: root/tools/git
diff options
context:
space:
mode:
authorsamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 22:28:30 +0000
committersamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 22:28:30 +0000
commitc1eb412c36dfde221b8a7f50b965b59b5194efe1 (patch)
tree4860b5f05ea22616811f2061cf238a339e3fade4 /tools/git
parent77fd82e5311e511c1a9dea91a062386ecd7dcc85 (diff)
downloadchromium_src-c1eb412c36dfde221b8a7f50b965b59b5194efe1.zip
chromium_src-c1eb412c36dfde221b8a7f50b965b59b5194efe1.tar.gz
chromium_src-c1eb412c36dfde221b8a7f50b965b59b5194efe1.tar.bz2
Allow move_source_file to take multiple files.
For example, you can do: $ tools/git/move_source_file.py chrome/browser/instant/instant_[bcelnoptu]* chrome/browser/ui/search/ R=joi@chromium.org Review URL: https://chromiumcodereview.appspot.com/12543024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/git')
-rwxr-xr-xtools/git/move_source_file.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/tools/git/move_source_file.py b/tools/git/move_source_file.py
index c0e6b7a..69cb862 100755
--- a/tools/git/move_source_file.py
+++ b/tools/git/move_source_file.py
@@ -3,9 +3,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Moves a C++ file to a new location, updating any include paths that
-point to it, and re-ordering headers as needed. Updates include
-guards in moved header files. Assumes Chromium coding style.
+"""Moves C++ files to a new location, updating any include paths that
+point to them, and re-ordering headers as needed. If multiple source
+files are specified, the destination must be a directory (and must end
+in a slash). Updates include guards in moved header files. Assumes
+Chromium coding style.
Attempts to update paths used in .gyp(i) files, but does not reorder
or restructure .gyp(i) files in any way.
@@ -147,23 +149,26 @@ def main():
print 'Fatal: You must run from the root of a git checkout.'
return 1
args = sys.argv[1:]
- if not len(args) in [2, 3]:
- print ('Usage: move_source_file.py [--already-moved] FROM_PATH TO_PATH'
- '\n\n%s' % __doc__)
- return 1
already_moved = False
- if args[0] == '--already-moved':
+ if len(args) > 0 and args[0] == '--already-moved':
args = args[1:]
already_moved = True
- from_path = args[0]
- to_path = args[1]
+ if len(args) < 2:
+ print ('Usage: move_source_file.py [--already-moved] FROM_PATH... TO_PATH'
+ '\n\n%s' % __doc__)
+ return 1
+
+ if len(args) > 2 and not args[-1].endswith('/'):
+ print 'Target %s is not a directory.' % args[-1]
+ return 1
- to_path = MakeDestinationPath(from_path, to_path)
- if not already_moved:
- MoveFile(from_path, to_path)
- UpdatePostMove(from_path, to_path)
+ for from_path in args[:len(args)-1]:
+ to_path = MakeDestinationPath(from_path, args[-1])
+ if not already_moved:
+ MoveFile(from_path, to_path)
+ UpdatePostMove(from_path, to_path)
return 0