Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Unified Diff: scripts/slave/apply_svn_patch.py

Issue 27575002: Patch path filtering script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Now using patch.py and its test data Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/patch_path_filter.py » ('j') | scripts/slave/patch_path_filter.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/apply_svn_patch.py
diff --git a/scripts/slave/apply_svn_patch.py b/scripts/slave/apply_svn_patch.py
index 8567c442642d82906da2fb1f0234b43e13b78ab5..76bb168a90ca0231f47ac855f11aba6563cdcd4f 100755
--- a/scripts/slave/apply_svn_patch.py
+++ b/scripts/slave/apply_svn_patch.py
@@ -14,17 +14,39 @@ def main():
help='The SVN URL to download the patch from.')
parser.add_option('-r', '--root-dir',
help='The root dir in which to apply patch.')
+ parser.add_option('', '--path-filter-script',
+ help=('A script that filter out contents of a patch. The '
iannucci 2013/12/05 21:40:57 s/filter/filters/ Should also mention that the sc
kjellander_chromium 2013/12/10 20:46:02 I rephrased so it shouldn't be needed now. I also
+ 'script must use stdin for input and stdout for '
+ 'output.'))
+ parser.add_option('', '--path-filter',
+ help=('The paths that shall be allowed (must specify the '
+ 'path filter script to use this).'))
iannucci 2013/12/05 21:40:57 What about: apply_svn_patch.py ... --path-filter-
kjellander_chromium 2013/12/10 20:46:02 I guess this makes perfect sense for --path-filter
+ parser.add_option('', '--strip-level', type='int', default=0,
+ help=('The number of components to be stripped from the '
+ 'filenames in the patch. Default: %default.'))
options, args = parser.parse_args()
if args:
parser.error('Unused args: %s' % args)
if not (options.patch_url and options.root_dir):
parser.error('A patch URL and root directory should be specified.')
+ if ((options.path_filter_script and not options.path_filter) or
+ (options.path_filter and not options.path_filter_script)):
+ parser.error('You must specify both path filter and a path filter script '
+ 'in order to use path filtering for patches.')
svn_cat = subprocess.Popen(['svn', 'cat', options.patch_url],
stdout=subprocess.PIPE)
- patch = subprocess.Popen(['patch', '-t', '-p', '0', '-d', options.root_dir],
- stdin=svn_cat.stdout)
+ patch_input = svn_cat.stdout
+ if options.path_filter_script:
+ filtering = subprocess.Popen([sys.executable, options.path_filter_script,
+ '-f', options.path_filter,
+ '-r', options.root_dir],
+ stdin=svn_cat.stdout, stdout=subprocess.PIPE)
+ patch_input = filtering.stdout
+ patch = subprocess.Popen(['patch', '-t', '-p', str(options.strip_level),
+ '-d', options.root_dir],
+ stdin=patch_input)
_, err = patch.communicate()
return err or None
« no previous file with comments | « no previous file | scripts/slave/patch_path_filter.py » ('j') | scripts/slave/patch_path_filter.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698