Chromium Code Reviews| 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 |