summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-12 06:32:25 +0000
committerscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-12 06:32:25 +0000
commit2da6c51c5f699f97b901c115bb83d81a0df7acf1 (patch)
treec80e985c7736a90af0a4607517cf7dd2641eea3c
parentfd66c1a93562e6102e1e370d16f1e94c9176cb6d (diff)
downloadchromium_src-2da6c51c5f699f97b901c115bb83d81a0df7acf1.zip
chromium_src-2da6c51c5f699f97b901c115bb83d81a0df7acf1.tar.gz
chromium_src-2da6c51c5f699f97b901c115bb83d81a0df7acf1.tar.bz2
mass-rename.py for windows and fix mffr.py on windows
R=jamesr@chromium.org BUG= Review URL: https://chromiumcodereview.appspot.com/16787006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205731 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--tools/git/mass-rename.py45
-rwxr-xr-xtools/git/mass-rename.sh13
-rwxr-xr-xtools/git/mffr.py2
3 files changed, 48 insertions, 12 deletions
diff --git a/tools/git/mass-rename.py b/tools/git/mass-rename.py
new file mode 100644
index 0000000..b499654
--- /dev/null
+++ b/tools/git/mass-rename.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+mass-rename: update source files (gyp lists, #includes) to reflect
+a rename. Expects "git diff --cached -M" to list a bunch of renames.
+
+To use:
+ 1) git mv foo1 bar1; git mv foo2 bar2; etc.
+ 2) *without committing*, ./tools/git/mass-rename.py
+ 3) look at git diff (without --cached) to see what the damage is
+"""
+
+
+import os
+import subprocess
+import sys
+
+
+BASE_DIR = os.path.abspath(os.path.dirname(__file__))
+
+
+def main():
+ popen = subprocess.Popen(['git', 'diff', '--cached', '--raw', '-M'],
+ shell=True, stdout=subprocess.PIPE)
+ out, _ = popen.communicate()
+ if popen.returncode != 0:
+ return 1
+ for line in out.splitlines():
+ attrs, fro, to = line.split('\t')
+ if attrs.split()[4].startswith('R'):
+ subprocess.check_call([
+ sys.executable,
+ os.path.join(BASE_DIR, 'move_source_file.py'),
+ '--already-moved',
+ fro, to])
+ else:
+ print "Skipping: %s -- not a rename?" % fro
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/tools/git/mass-rename.sh b/tools/git/mass-rename.sh
index 8e9b378..f92814e 100755
--- a/tools/git/mass-rename.sh
+++ b/tools/git/mass-rename.sh
@@ -14,15 +14,4 @@
# for f in $(git diff --name-only origin); do ./tools/sort-headers.py $f; done
DIR="$( cd "$( dirname "$0" )" && pwd )"
-
-# Make the 'read' used in the while loop split only on tabs/newlines.
-IFS=$'\t\n'
-
-git diff --cached --raw -M | while read attrs from to; do
- type=$(echo "$attrs" | cut -d' ' -f5)
- if echo "$type" | grep -q "^R"; then
- python $DIR/move_source_file.py --already-moved "$from" "$to"
- else
- echo "Skipping: $from -- not a rename?"
- fi
-done
+python $DIR/mass-rename.py "$*"
diff --git a/tools/git/mffr.py b/tools/git/mffr.py
index 5effc15..7f791d0 100755
--- a/tools/git/mffr.py
+++ b/tools/git/mffr.py
@@ -50,6 +50,8 @@ def MultiFileFindReplace(original, replacement, file_globs):
# Posix extended regular expressions do not reliably support the "\s"
# shorthand.
posix_ere_original = re.sub(r"\\s", "[[:space:]]", original)
+ if sys.platform == 'win32':
+ posix_ere_original = posix_ere_original.replace('"', '""')
out, err = subprocess.Popen(
['git', 'grep', '-E', '--name-only', posix_ere_original,
'--'] + file_globs,