Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Update Dartium DEPS automatically. | 3 # Update Dartium DEPS automatically. |
| 4 | 4 |
| 5 from datetime import datetime, timedelta | 5 from datetime import datetime, timedelta |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 from subprocess import Popen, PIPE | 9 from subprocess import Popen, PIPE |
| 10 import sys | 10 import sys |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 ######################################################################## | 39 ######################################################################## |
| 40 # Repositories to auto-update | 40 # Repositories to auto-update |
| 41 ######################################################################## | 41 ######################################################################## |
| 42 | 42 |
| 43 BRANCH_CURRENT="dart/dartium" | 43 BRANCH_CURRENT="dart/dartium" |
| 44 BRANCH_NEXT="dart/dartium" | 44 BRANCH_NEXT="dart/dartium" |
| 45 BRANCH_MULTIVM="dart/multivm" | 45 BRANCH_MULTIVM="dart/multivm" |
| 46 | 46 |
| 47 TARGETS = { | 47 TARGETS = { |
| 48 'dartium': ( | 48 'dartium': ( |
| 49 'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/dartium.deps', | 49 'git@github.com:dart-lang/sdk.git', |
| 50 'tools/deps/dartium.deps', | |
| 51 'origin/master', | |
| 50 'dartium', | 52 'dartium', |
| 51 # TODO(vsm): Reenable 'chromium' | 53 # TODO(vsm): Reenable 'chromium' |
| 52 ['webkit'], | 54 ['webkit'], |
| 53 BRANCH_CURRENT, | 55 BRANCH_CURRENT, |
| 54 ), | 56 ), |
| 55 'integration': ( | 57 'integration': ( |
| 58 # TODO(jacobr): what is the git repo for integration if any? | |
|
rmacnak
2015/10/08 00:40:32
git@github.com:dart-lang/sdk.git@integration
| |
| 56 'https://dart.googlecode.com/svn/branches/dartium_integration/deps/dartium.d eps', | 59 'https://dart.googlecode.com/svn/branches/dartium_integration/deps/dartium.d eps', |
| 60 'tools/deps/dartium.deps', | |
| 61 'origin/master', | |
| 57 'dartium', | 62 'dartium', |
| 58 # TODO(vsm): Reenable 'chromium' | 63 # TODO(vsm): Reenable 'chromium' |
| 59 ['webkit'], | 64 ['webkit'], |
| 60 BRANCH_NEXT, | 65 BRANCH_NEXT, |
| 61 ), | 66 ), |
| 62 'clank': ( | |
| 63 'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/clank.deps', | |
| 64 'dartium', | |
| 65 ['webkit', 'chromium'], | |
| 66 BRANCH_CURRENT, | |
| 67 ), | |
| 68 'multivm': ( | |
| 69 'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/multivm.deps', | |
| 70 'multivm', | |
| 71 ['blink'], | |
| 72 BRANCH_MULTIVM, | |
| 73 ), | |
| 74 } | 67 } |
| 75 | 68 |
| 76 # Each element in this map represents a repository to update. Entries | 69 # Each element in this map represents a repository to update. Entries |
| 77 # take the form: | 70 # take the form: |
| 78 # (repo_tag: (svn_url, view_url)) | 71 # (repo_tag: (svn_url, view_url)) |
| 79 # | 72 # |
| 80 # The repo_tag must match the DEPS revision entry. I.e, there must be | 73 # The repo_tag must match the DEPS revision entry. I.e, there must be |
| 81 # an entry of the form: | 74 # an entry of the form: |
| 82 # 'dartium_%s_revision' % repo_tag | 75 # 'dartium_%s_revision' % repo_tag |
| 83 # to roll forward. | 76 # to roll forward. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 def merge_revs(revs): | 173 def merge_revs(revs): |
| 181 position = find_max(revs) | 174 position = find_max(revs) |
| 182 if position is None: | 175 if position is None: |
| 183 return [] | 176 return [] |
| 184 item = revs[position][0] | 177 item = revs[position][0] |
| 185 revs[position] = revs[position][1:] | 178 revs[position] = revs[position][1:] |
| 186 return [item] + merge_revs(revs) | 179 return [item] + merge_revs(revs) |
| 187 | 180 |
| 188 def main(): | 181 def main(): |
| 189 option_parser = optparse.OptionParser() | 182 option_parser = optparse.OptionParser() |
| 190 option_parser.add_option('', '--target', help="Update one of [dartium|integrat ion|multivm|clank]", action="store", dest="target", default="dartium") | 183 option_parser.add_option('', '--target', help="Update one of [dartium|integrat ion]", action="store", dest="target", default="dartium") |
| 191 option_parser.add_option('', '--force', help="Push DEPS update to server witho ut prompting", action="store_true", dest="force") | 184 option_parser.add_option('', '--force', help="Push DEPS update to server witho ut prompting", action="store_true", dest="force") |
| 192 options, args = option_parser.parse_args() | 185 options, args = option_parser.parse_args() |
| 193 | 186 |
| 194 target = options.target | 187 target = options.target |
| 195 if not target in TARGETS.keys(): | 188 if not target in TARGETS.keys(): |
| 196 print "Error: invalid target" | 189 print "Error: invalid target" |
| 197 print "Choose one of " + str(TARGETS) | 190 print "Choose one of " + str(TARGETS) |
| 198 (deps_dir, prefix, repos, branch) = TARGETS[target] | 191 (repo_name, deps_dir, repo_branch, prefix, repos, branch) = TARGETS[target] |
| 199 deps_file = deps_dir + '/DEPS' | 192 deps_file = deps_dir + '/DEPS' |
| 193 repo_branch_parts = repo_branch.split('/') | |
| 200 | 194 |
| 201 src_dir = "/usr/local/google/home/%s/dartium_deps_updater/deps/%s" % (os.envir on["USER"], target) | 195 src_dir = "/usr/local/google/home/%s/dartium_deps_updater/deps/%s" % (os.envir on["USER"], target) |
| 202 os.putenv("GIT_PAGER", "") | 196 os.putenv("GIT_PAGER", "") |
| 203 | 197 |
| 204 if not os.path.exists(src_dir): | 198 if not os.path.exists(src_dir): |
| 205 print run_cmd(['svn', 'co', deps_dir, src_dir]) | 199 print run_cmd(['git', 'clone', repo_name, src_dir]) |
| 206 | 200 |
| 207 os.chdir(src_dir) | 201 os.chdir(src_dir) |
| 202 deps = run_cmd(['git', 'fetch']) | |
| 203 deps = run_cmd(['git', 'stash']) | |
| 204 deps = run_cmd(['git', 'checkout', '-B', repo_branch_parts[1], repo_branch]) | |
| 208 | 205 |
| 209 # parse DEPS | 206 # parse DEPS |
| 210 deps = run_cmd(['svn', 'cat', deps_file]) | 207 deps = run_cmd(['cat', deps_file]) |
| 211 rev_num = {} | 208 rev_num = {} |
| 212 for repo in repos: | 209 for repo in repos: |
| 213 revision = '%s_%s_revision":\s*"(.+)"' % (prefix, repo) | 210 revision = '%s_%s_revision":\s*"(.+)"' % (prefix, repo) |
| 214 rev_num[repo] = re.search(revision, deps).group(1) | 211 rev_num[repo] = re.search(revision, deps).group(1) |
| 215 | 212 |
| 216 # update repos | 213 # update repos |
| 217 all_revs = [] | 214 all_revs = [] |
| 218 for repo in repos: | 215 for repo in repos: |
| 219 (svn_url, _) = REPOSITORY_INFO[repo] | 216 (svn_url, _) = REPOSITORY_INFO[repo] |
| 220 output = run_cmd(["svn", "log", "-r", "HEAD:%s" % rev_num[repo], svn_url % branch]) | 217 output = run_cmd(["svn", "log", "-r", "HEAD:%s" % rev_num[repo], svn_url % branch]) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 234 if len(pending_updates) == 0: | 231 if len(pending_updates) == 0: |
| 235 print "DEPS is up-to-date." | 232 print "DEPS is up-to-date." |
| 236 sys.exit(0) | 233 sys.exit(0) |
| 237 else: | 234 else: |
| 238 print "Pending DEPS updates:" | 235 print "Pending DEPS updates:" |
| 239 for s in pending_updates: | 236 for s in pending_updates: |
| 240 print " %s to %s (%s) %s" % (s['repo'], s['rev'], s['isotime'], s['info'] ) | 237 print " %s to %s (%s) %s" % (s['repo'], s['rev'], s['isotime'], s['info'] ) |
| 241 | 238 |
| 242 # make the next DEPS update | 239 # make the next DEPS update |
| 243 os.chdir(src_dir) | 240 os.chdir(src_dir) |
| 244 run_cmd(['rm', 'DEPS']) | 241 run_cmd(['rm', deps_file]) |
| 245 print run_cmd(['svn', 'update']) | |
| 246 s = pending_updates[0] | 242 s = pending_updates[0] |
| 247 | 243 |
| 248 pattern = re.compile(prefix + '_' + s['repo'] + '_revision":\s*"(.+)"') | 244 pattern = re.compile(prefix + '_' + s['repo'] + '_revision":\s*"(.+)"') |
| 249 new_deps = pattern.sub(prefix + '_' + s['repo'] + '_revision": "' + s['rev'] + '"', deps) | 245 new_deps = pattern.sub(prefix + '_' + s['repo'] + '_revision": "' + s['rev'] + '"', deps) |
| 250 write_file('DEPS', new_deps) | 246 write_file(deps_file, new_deps) |
| 251 | 247 |
| 252 commit_log = 'DEPS AutoUpdate: %s to %s (%s) %s\n' % (s['repo'], s['rev'], s[' isotime'], s['author']) | 248 commit_log = 'DEPS AutoUpdate: %s to %s (%s) %s\n' % (s['repo'], s['rev'], s[' isotime'], s['author']) |
| 253 commit_log += s['info'] + '\n' + commit_url(s['repo'], s['rev']) | 249 commit_log += s['info'] + '\n' + commit_url(s['repo'], s['rev']) |
| 254 | 250 |
| 255 write_file('commit_log.txt', commit_log) | 251 write_file('commit_log.txt', commit_log) |
| 256 print run_cmd(['svn', 'diff']) | 252 run_cmd(['git', 'add', deps_file]) |
| 253 | |
| 254 print run_cmd(['git', 'diff', 'HEAD']) | |
| 257 print | 255 print |
| 258 print "Commit log:" | 256 print "Commit log:" |
| 259 print "---------------------------------------------" | 257 print "---------------------------------------------" |
| 260 print commit_log | 258 print commit_log |
| 261 print "---------------------------------------------" | 259 print "---------------------------------------------" |
| 262 | 260 |
| 263 if not options.force: | 261 if not options.force: |
| 264 print "Ready to push; press Enter to continue or Control-C to abort..." | 262 print "Ready to push; press Enter to continue or Control-C to abort..." |
| 265 sys.stdin.readline() | 263 sys.stdin.readline() |
| 266 print run_cmd(['svn', 'commit', '--file', 'commit_log.txt']) | 264 print run_cmd(['git', 'commit', '-F', 'commit_log.txt']) |
| 265 print run_cmd(['git', 'push', repo_branch_parts[0], repo_branch_parts[1]]) | |
| 267 print "Done." | 266 print "Done." |
| 268 | 267 |
| 269 | 268 |
| 270 if '__main__' == __name__: | 269 if '__main__' == __name__: |
| 271 main() | 270 main() |
| OLD | NEW |