diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 13:44:01 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-27 13:44:01 +0000 |
commit | b902890cafa8c369e69e0c2c34ad0e68fc9a3fcf (patch) | |
tree | 7ab95959ae9881ad1fa6d81f450e8a80a0917e5e /tools/git | |
parent | 5264cde7cec1460e0c0e540829d1a6456639eed1 (diff) | |
download | chromium_src-b902890cafa8c369e69e0c2c34ad0e68fc9a3fcf.zip chromium_src-b902890cafa8c369e69e0c2c34ad0e68fc9a3fcf.tar.gz chromium_src-b902890cafa8c369e69e0c2c34ad0e68fc9a3fcf.tar.bz2 |
Make move_source_file.py more generous in handling include guard update.
Two changes:
(1) Don't raise an error in the case where the user had already updated the
include guard before running move_source_file.py.
(2) Rather than having a failure to find the include guard stop the script,
print out a warning instead and let the rest of the operation of the script
continue.
Review URL: https://chromiumcodereview.appspot.com/12335126
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/git')
-rwxr-xr-x | tools/git/move_source_file.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/git/move_source_file.py b/tools/git/move_source_file.py index 79048af..c0e6b7a 100755 --- a/tools/git/move_source_file.py +++ b/tools/git/move_source_file.py @@ -121,8 +121,8 @@ def UpdateIncludeGuard(old_path, new_path): """Updates the include guard in a file now residing at |new_path|, previously residing at |old_path|, with an up-to-date include guard. - Errors out if an include guard per Chromium style guide cannot be - found for the old path. + Prints a warning if the update could not be completed successfully (e.g., + because the old include guard was not formatted correctly per Chromium style). """ old_guard = MakeIncludeGuardName(old_path) new_guard = MakeIncludeGuardName(new_path) @@ -131,9 +131,12 @@ def UpdateIncludeGuard(old_path, new_path): contents = f.read() new_contents = contents.replace(old_guard, new_guard) - if new_contents == contents: - raise Exception( - 'Error updating include guard; perhaps old guard is not per style guide?') + # The file should now have three instances of the new guard: two at the top + # of the file plus one at the bottom for the comment on the #endif. + if new_contents.count(new_guard) != 3: + print ('WARNING: Could not not successfully update include guard; perhaps ' + 'old guard is not per style guide? You will have to update the ' + 'include guard manually.') with open(new_path, 'w') as f: f.write(new_contents) |