| 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..edf39d5b0b6b2a2a9fa39d49dabf6a36eaa8a12b 100755
|
| --- a/scripts/slave/apply_svn_patch.py
|
| +++ b/scripts/slave/apply_svn_patch.py
|
| @@ -14,17 +14,38 @@ 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 '
|
| + '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).'))
|
| + 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],
|
| + stdin=svn_cat.stdout, stdout=subprocess.PIPE)
|
| + patch_input = filtering.stdout
|
| + patch = subprocess.Popen(['patch', '-t', '-p', options.strip_level,
|
| + '-d', options.root_dir],
|
| + stdin=patch_input)
|
|
|
| _, err = patch.communicate()
|
| return err or None
|
|
|