Add `--revert` option to patch_updater.py.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1811 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2014-08-25 14:01:13 +00:00
parent c06d0cd2d8
commit cba2e8ac3a
1 changed files with 33 additions and 23 deletions

View File

@ -47,8 +47,16 @@ parser = OptionParser(description=disc)
parser.add_option('--resave', parser.add_option('--resave',
action='store_true', dest='resave', default=False, action='store_true', dest='resave', default=False,
help='re-save existing patch files to pick up manual changes') help='re-save existing patch files to pick up manual changes')
parser.add_option('--revert',
action='store_true', dest='revert', default=False,
help='revert all changes from existing patch files')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if options.resave and options.revert:
print 'Invalid combination of options.'
parser.print_help(sys.stderr)
sys.exit()
# The CEF root directory is the parent directory of _this_ script. # The CEF root directory is the parent directory of _this_ script.
cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
src_dir = os.path.join(cef_dir, os.pardir) src_dir = os.path.join(cef_dir, os.pardir)
@ -102,6 +110,7 @@ for patch in patches:
if result['out'] != '': if result['out'] != '':
sys.stdout.write(result['out']) sys.stdout.write(result['out'])
if not options.revert:
# Apply the patch file. # Apply the patch file.
msg('Applying patch to %s' % patch_root_abs) msg('Applying patch to %s' % patch_root_abs)
result = exec_cmd('patch -p0', patch_root_abs, patch_file) result = exec_cmd('patch -p0', patch_root_abs, patch_file)
@ -113,6 +122,7 @@ for patch in patches:
patch['name']) patch['name'])
continue continue
if not options.revert:
# Re-create the patch file. # Re-create the patch file.
msg('Saving changes to %s' % patch_file) msg('Saving changes to %s' % patch_file)
patch_paths_str = ' '.join(patch_paths) patch_paths_str = ' '.join(patch_paths)