Add black/whitelisting to apply_issue
BUG=370503
TESTS=
apply_issue.py --issue 243483007 --patchset 210001 --whitelst chrome/browser/chromeos/login/screen_locker.cc
apply_issue.py --issue 243483007 --patchset 210001 --blacklist chrome/browser/chromeos/login/screen_locker.cc
Review URL: https://codereview.chromium.org/264823003
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@268589 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/apply_issue.py b/apply_issue.py
index 75ea609..91fe2f7 100755
--- a/apply_issue.py
+++ b/apply_issue.py
@@ -87,10 +87,17 @@
'is detected.')
parser.add_option('-b', '--base_ref', help='Base git ref to patch on top of, '
'used for verification.')
+ parser.add_option('--whitelist', action='append', default=[],
+ help='Patch only specified file(s).')
+ parser.add_option('--blacklist', action='append', default=[],
+ help='Don\'t patch specified file(s).')
parser.add_option('-d', '--ignore_deps', action='store_true',
help='Don\'t run gclient sync on DEPS changes.')
options, args = parser.parse_args()
+ if options.whitelist and options.blacklist:
+ parser.error('Cannot specify both --whitelist and --blacklist')
+
if options.password and options.private_key_file:
parser.error('-k and -w options are incompatible')
if options.email and options.email_file:
@@ -185,6 +192,12 @@
options.issue, options.patchset,
options.server, options.issue)
return 1
+ if options.whitelist:
+ patchset.patches = [patch for patch in patchset.patches
+ if patch.filename in options.whitelist]
+ if options.blacklist:
+ patchset.patches = [patch for patch in patchset.patches
+ if patch.filename not in options.blacklist]
for patch in patchset.patches:
print(patch)
full_dir = os.path.abspath(options.root_dir)
diff --git a/checkout.py b/checkout.py
index 022076c..06b2d3b 100644
--- a/checkout.py
+++ b/checkout.py
@@ -726,7 +726,9 @@
['diff', base_ref, '--ignore-submodules',
'--name-only']).splitlines(False)
assert sorted(patches.filenames) == sorted(found_files), (
- sorted(patches.filenames), sorted(found_files))
+ 'Found extra %s locally, %s not patched' % (
+ sorted(set(found_files) - set(patches.filenames)),
+ sorted(set(patches.filenames) - set(found_files))))
def commit(self, commit_message, user):
"""Commits, updates the commit message and pushes."""