mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-02 20:26:59 +01:00
tools: Add --patch
argument to patch_updater.py
This commit is contained in:
parent
f207a555a3
commit
535c4fbc30
@ -2,7 +2,7 @@
|
|||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file.
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import Option, OptionParser, OptionValueError
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -42,13 +42,30 @@ disc = """
|
|||||||
This utility updates existing patch files.
|
This utility updates existing patch files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parser = OptionParser(description=disc)
|
# Support options with multiple arguments.
|
||||||
|
class MultipleOption(Option):
|
||||||
|
ACTIONS = Option.ACTIONS + ("extend",)
|
||||||
|
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
||||||
|
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
||||||
|
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
||||||
|
|
||||||
|
def take_action(self, action, dest, opt, value, values, parser):
|
||||||
|
if action == "extend":
|
||||||
|
values.ensure_value(dest, []).append(value)
|
||||||
|
else:
|
||||||
|
Option.take_action(self, action, dest, opt, value, values, parser)
|
||||||
|
|
||||||
|
parser = OptionParser(option_class=MultipleOption,
|
||||||
|
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',
|
parser.add_option('--revert',
|
||||||
action='store_true', dest='revert', default=False,
|
action='store_true', dest='revert', default=False,
|
||||||
help='revert all changes from existing patch files')
|
help='revert all changes from existing patch files')
|
||||||
|
parser.add_option('--patch',
|
||||||
|
action='extend', dest='patch', type='string', default=[],
|
||||||
|
help='optional patch name to process (multiples allowed)')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if options.resave and options.revert:
|
if options.resave and options.revert:
|
||||||
@ -78,6 +95,10 @@ patches = scope["patches"]
|
|||||||
# Read each individual patch file.
|
# Read each individual patch file.
|
||||||
patches_dir = os.path.join(patch_dir, 'patches')
|
patches_dir = os.path.join(patch_dir, 'patches')
|
||||||
for patch in patches:
|
for patch in patches:
|
||||||
|
# If specific patch names are specified only process those patches.
|
||||||
|
if options.patch and not patch['name'] in options.patch:
|
||||||
|
continue
|
||||||
|
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
patch_file = os.path.join(patches_dir, patch['name']+'.patch')
|
patch_file = os.path.join(patches_dir, patch['name']+'.patch')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user