Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Pull latest revisions of the W3C test repos and update our DEPS entries.""" | |
| 7 import optparse | |
| 8 import subprocess | |
| 9 import sys | |
| 10 | |
| 11 from webkitpy.common import version_check | |
| 12 | |
| 13 from webkitpy.common.host import Host | |
| 14 from webkitpy.common.webkit_finder import WebKitFinder | |
| 15 | |
| 16 def main(): | |
| 17 parser = optparse.OptionParser() | |
| 18 parser.description = __doc__ | |
| 19 parser.add_option('-n', '--dryrun', action='store_true') | |
| 20 parser.add_option('-v', '--verbose', action='store_true') | |
| 21 | |
| 22 options, args = parser.parse_args() | |
| 23 if args: | |
| 24 parser.error('%prog does not take any arguments') | |
| 25 sys.exit(1) | |
| 26 | |
| 27 cmd = CommandRunner(Host(), options) | |
| 28 | |
| 29 update_repo(cmd, 'web-platform-tests') | |
| 30 update_repo(cmd, 'csswg-test') | |
| 31 | |
| 32 | |
| 33 def update_repo(cmd, repo): | |
| 34 blink_commitish = cmd.run(['git', 'show-ref', 'HEAD']).split()[0] | |
|
ojan
2014/02/08 00:36:28
Should this assert you're in a clean checkout? FIX
Dirk Pranke
2014/02/08 01:04:31
I'm not actually sure you want to assert, but I ha
| |
| 35 | |
| 36 cmd.cd('LayoutTests', 'w3c', repo) | |
| 37 cmd.run(['git', 'fetch', 'origin']) | |
| 38 new_commits = cmd.run(['git', 'log', '--oneline', 'origin/blink..origin/mast er']) | |
| 39 if not new_commits and cmd.options.verbose: | |
| 40 print >>sys.stderr, 'No new commits found in %s' % repo | |
| 41 # FIXME: check if there are any changes to W3CImportExpectations, too. | |
| 42 return | |
| 43 | |
| 44 master_commitish = cmd.run(['git', 'show-ref', 'origin/master']).split()[0] | |
| 45 status = cmd.run(['git', 'status']) | |
| 46 if status and not 'nothing to commit, working directory clean' in status: | |
|
ojan
2014/02/08 00:36:28
This is kind of gross. webkitpy git does the follo
Dirk Pranke
2014/02/08 01:04:31
Yeah, will look into doing something stronger here
Dirk Pranke
2014/03/10 21:19:27
Turns out that 'git diff --quiet commitish' probab
| |
| 47 print >> sys.stderr, "%s is not clean, exiting" % repo | |
| 48 sys.exit(1) | |
| 49 | |
| 50 if cmd.run(['git', 'branch', '--list', 'blink']): | |
| 51 cmd.run(['git', 'checkout', 'origin/master']) | |
| 52 cmd.run(['git', 'branch', '-D', 'blink']) | |
| 53 cmd.run(['git', 'checkout', '--track', '-b', 'blink', 'origin/blink']) | |
| 54 | |
| 55 # FIXME: Figure out why Gerrit won't let me record merge commits ... | |
| 56 # cmd.run(['git', 'merge', '--no-commit', '-s', 'ours', 'origin/master']) | |
| 57 | |
| 58 cmd.run(['git', 'rm', '-fr', '*']) | |
| 59 cmd.run(['git', 'checkout', 'origin/blink', 'README.blink']) | |
| 60 cmd.run(['git', 'checkout', 'origin/master', '--', '.']) | |
| 61 cmd.run([sys.executable, cmd.path_from_webkit_base('Tools', 'Scripts', 'impo rt-w3c-tests')]) | |
| 62 cmd.run(['git', 'add', '--all', '.']) | |
| 63 cmd.run(['git', 'commit', '-m', 'import origin/master@%s using blink@%s' % | |
| 64 (master_commitish, blink_commitish)]) | |
| 65 | |
| 66 | |
| 67 class CommandRunner(object): | |
| 68 def __init__(self, host, options): | |
| 69 host = host | |
| 70 self.executive = host.executive | |
| 71 self.fs = host.filesystem | |
| 72 self.finder = WebKitFinder(self.fs) | |
| 73 self.options = options | |
| 74 | |
| 75 def run(self, cmd, **args): | |
| 76 cmd_str = ' '.join([arg for arg in cmd]) | |
| 77 if self.options.verbose: | |
| 78 print >>sys.stderr, cmd_str | |
| 79 if self.options.dryrun: | |
| 80 return | |
| 81 | |
| 82 proc = self.executive.popen(cmd, stdout=self.executive.PIPE, | |
| 83 stderr=self.executive.PIPE, **args) | |
| 84 out, err = proc.communicate() | |
| 85 if proc.returncode: | |
| 86 print >> sys.stderr, "'%s' failed:\n%s\%s" % (cmd_str, out, err) | |
| 87 sys.exit(proc.returncode) | |
| 88 if self.options.verbose: | |
| 89 if out: | |
| 90 print out | |
| 91 if err: | |
| 92 print >>sys.stderr, err | |
| 93 return out | |
| 94 | |
| 95 def cd(self, *comps): | |
| 96 dest = self.path_from_webkit_base(*comps) | |
| 97 if self.options.verbose: | |
| 98 print "cd %s" % dest | |
| 99 if self.options.dryrun: | |
| 100 return | |
| 101 self.fs.chdir(dest) | |
| 102 | |
| 103 def path_from_webkit_base(self, *comps): | |
| 104 return self.finder.path_from_webkit_base(*comps) | |
| 105 | |
| 106 | |
| 107 if __name__ == '__main__': | |
| 108 main() | |
| OLD | NEW |