Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from webkitpy.common.memoized import memoized | 5 from webkitpy.common.memoized import memoized |
| 6 from webkitpy.common.webkit_finder import WebKitFinder | 6 from webkitpy.common.webkit_finder import WebKitFinder |
| 7 from webkitpy.w3c.deps_updater import DepsUpdater | |
| 8 | |
| 9 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' | |
| 7 | 10 |
| 8 | 11 |
| 9 class ChromiumCommit(object): | 12 class ChromiumCommit(object): |
| 10 | 13 |
| 11 def __init__(self, host, sha=None, position=None): | 14 def __init__(self, host, sha=None, position=None): |
| 12 """ | 15 """ |
| 13 Args: | 16 Args: |
| 14 host: A Host object | 17 host: A Host object |
| 15 sha: A Chromium commit SHA | 18 sha: A Chromium commit SHA |
| 16 position: A string of the form: | 19 position: A string of the form: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 return self.host.executive.run_command([ | 57 return self.host.executive.run_command([ |
| 55 'git', 'show', '--format=%b', '--no-patch', self.sha | 58 'git', 'show', '--format=%b', '--no-patch', self.sha |
| 56 ]) | 59 ]) |
| 57 | 60 |
| 58 def message(self): | 61 def message(self): |
| 59 """Returns a string with a commit's subject and body.""" | 62 """Returns a string with a commit's subject and body.""" |
| 60 return self.host.executive.run_command([ | 63 return self.host.executive.run_command([ |
| 61 'git', 'show', '--format=%B', '--no-patch', self.sha | 64 'git', 'show', '--format=%B', '--no-patch', self.sha |
| 62 ]) | 65 ]) |
| 63 | 66 |
| 67 def filtered_changed_files(self): | |
| 68 """Makes a patch with just changes in files in the WPT dir for a given c ommit.""" | |
| 69 changed_files = self.host.executive.run_command([ | |
| 70 'git', 'diff-tree', '--name-only', '--no-commit-id', '-r', self.sha, | |
| 71 '--', self.absolute_chromium_wpt_dir() | |
| 72 ]).splitlines() | |
| 73 | |
| 74 blacklist = [ | |
| 75 'MANIFEST.json', | |
| 76 self.host.filesystem.join('resources', 'testharnessreport.js'), | |
| 77 ] | |
| 78 qualified_blacklist = [CHROMIUM_WPT_DIR + f for f in blacklist] | |
| 79 return [f for f in changed_files if f not in qualified_blacklist and not DepsUpdater.is_baseline(f)] | |
| 80 | |
| 64 def format_patch(self): | 81 def format_patch(self): |
| 65 """Makes a patch with just changes in files in the WPT for a given commi t.""" | 82 """Makes a patch with only exportable changes.""" |
| 66 # TODO(jeffcarp): exclude expectations files | 83 filtered_files = self.filtered_changed_files() |
| 67 # TODO(jeffcarp): exclude manifest files | 84 |
| 85 if not filtered_files: | |
| 86 return '' | |
| 87 | |
| 68 return self.host.executive.run_command([ | 88 return self.host.executive.run_command([ |
| 69 'git', 'format-patch', '-1', '--stdout', | 89 'git', 'format-patch', '-1', '--stdout', |
| 70 self.sha, self.absolute_chromium_wpt_dir() | 90 self.sha, '--'] + filtered_files, cwd=self.absolute_chromium_dir()) |
|
qyearsley
2016/12/21 00:24:46
[Bike-shedding about format/style]
I wonder if it
jeffcarp
2016/12/21 19:12:52
I'm still learning the intricacies of python forma
| |
| 71 ]) | |
| 72 | 91 |
| 73 @memoized | 92 @memoized |
| 74 def absolute_chromium_wpt_dir(self): | 93 def absolute_chromium_wpt_dir(self): |
| 75 finder = WebKitFinder(self.host.filesystem) | 94 finder = WebKitFinder(self.host.filesystem) |
| 76 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt') | 95 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt') |
| 96 | |
| 97 @memoized | |
| 98 def absolute_chromium_dir(self): | |
| 99 finder = WebKitFinder(self.host.filesystem) | |
| 100 return finder.chromium_base() | |
| OLD | NEW |