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

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: Addressed comments Created 7 years 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') | no next file with comments »
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..c23cb4b24c947a865adfeb966142ae5774acc030 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('', '--filter-script',
+ help=('Path to a Python script to be used to manipulate '
+ 'the contents of the patch. One example could be to '
+ 'remove parts of the patch matching certain file '
+ 'paths. The script must use stdin for input and '
+ 'stdout for output. The script will get the '
+ '--root-dir flag passed on to it. To pass additional '
+ 'flags; use: -- --flag1 --flag2'))
+ parser.add_option('', '--strip-level', type='int', default=0,
+ help=('The number of path components to be stripped from '
+ 'the filenames in the patch. Default: %default.'))
options, args = parser.parse_args()
- if args:
+ if args and not options.filter_script:
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.')
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.filter_script:
+ extra_args = args or []
+ filtering = subprocess.Popen([sys.executable, options.filter_script,
+ '--root-dir', options.root_dir] + extra_args,
+ stdin=svn_cat.stdout, stdout=subprocess.PIPE,
+ stderr=sys.stdout)
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698