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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/chromium_wpt.py

Issue 2518313003: Refactor WPT Export to ensure only one PR in flight at a time (Closed)
Patch Set: Address CL feedback Created 4 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 unified diff | Download patch
OLDNEW
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 """A utility class for interacting with the Chromium git tree 5 """A utility class for interacting with the Chromium git tree
6 for use cases relating to the Web Platform Tests. 6 for use cases relating to the Web Platform Tests.
7 """ 7 """
8 8
9 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/' 9 CHROMIUM_WPT_DIR = 'third_party/WebKit/LayoutTests/imported/wpt/'
10 10
11 from webkitpy.common.memoized import memoized 11 from webkitpy.common.memoized import memoized
12 from webkitpy.common.webkit_finder import WebKitFinder 12 from webkitpy.common.webkit_finder import WebKitFinder
13 from webkitpy.w3c.deps_updater import DepsUpdater 13 from webkitpy.w3c.deps_updater import DepsUpdater
14 14
15 15
16 class ChromiumWPT(object): 16 class ChromiumWPT(object):
17 17
18 def __init__(self, host): 18 def __init__(self, host):
19 """ 19 """
20 Args: 20 Args:
21 host: A Host object. 21 host: A Host object.
22 """ 22 """
23 self.host = host 23 self.host = host
24 24
25 # TODO(jeffcarp): add tests for this
26 def exportable_commits_since(self, commit): 25 def exportable_commits_since(self, commit):
26 """Returns SHAs of exportable commits since `commit` in chronological or der.
27
28 Args:
29 commit: The SHA of the Chromium commit from which this method will l ook.
30 """
27 toplevel = self.host.executive.run_command([ 31 toplevel = self.host.executive.run_command([
28 'git', 'rev-parse', '--show-toplevel' 32 'git', 'rev-parse', '--show-toplevel'
29 ]).strip() 33 ]).strip()
30 34
31 commits = self.host.executive.run_command([ 35 commits = self.host.executive.run_command([
32 'git', 'rev-list', '{}..HEAD'.format(commit), 36 'git', 'rev-list', '{}..HEAD'.format(commit), '--reverse',
33 '--', toplevel + '/' + CHROMIUM_WPT_DIR 37 '--', toplevel + '/' + CHROMIUM_WPT_DIR
34 ]).splitlines() 38 ]).splitlines()
35 39
36 # TODO(jeffcarp): this is temporary until I solve 40 # TODO(jeffcarp): allow this logic to be shared
37 # the import/export differentiation problem
38 def is_exportable(chromium_commit): 41 def is_exportable(chromium_commit):
42 message = self.message(chromium_commit)
39 return ( 43 return (
40 'export' in self.message(chromium_commit) 44 'NOEXPORT=true' not in message
45 and not message.startswith('Import ')
46 # TODO(jeffcarp): change this to allow any commit with
47 # any non-expectation changes to be exportable
48 and not self._has_expectations(chromium_commit)
41 ) 49 )
42 50
43 return filter(is_exportable, commits) 51 return filter(is_exportable, commits)
44 52
45 def _has_expectations(self, chromium_commit): 53 def _has_expectations(self, chromium_commit):
46 files = self.host.executive.run_command([ 54 files = self.host.executive.run_command([
47 'git', 'diff-tree', '--no-commit-id', 55 'git', 'diff-tree', '--no-commit-id',
48 '--name-only', '-r', chromium_commit 56 '--name-only', '-r', chromium_commit
49 ]).splitlines() 57 ]).splitlines()
50 58
(...skipping 20 matching lines...) Expand all
71 # TODO(jeffcarp): do not include expectations files 79 # TODO(jeffcarp): do not include expectations files
72 return self.host.executive.run_command([ 80 return self.host.executive.run_command([
73 'git', 'format-patch', '-1', '--stdout', 81 'git', 'format-patch', '-1', '--stdout',
74 chromium_commit, self.absolute_chromium_wpt_dir() 82 chromium_commit, self.absolute_chromium_wpt_dir()
75 ]) 83 ])
76 84
77 @memoized 85 @memoized
78 def absolute_chromium_wpt_dir(self): 86 def absolute_chromium_wpt_dir(self):
79 finder = WebKitFinder(self.host.filesystem) 87 finder = WebKitFinder(self.host.filesystem)
80 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt') 88 return finder.path_from_webkit_base('LayoutTests', 'imported', 'wpt')
81
82 # TODO(jeffcarp): this is duplicated in LocalWPT, maybe move into a GitRepo base class?
83 def commits_behind_master(self, commit):
84 return len(self.host.executive.run_command([
85 'git', 'rev-list', '{}..origin/master'.format(commit)
86 ]).splitlines())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698