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

Side by Side Diff: update_deps.py

Issue 243953003: Update script to roll chrome DEPS for all our variants (Closed) Base URL: svn://svn.chromium.org/chrome/branches/dart/1847/src/dartium_tools
Patch Set: Created 6 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 from time import strptime 11 from time import strptime
12 12
13 # Instructions: 13 # Instructions:
14 # 14 #
15 # To run locally: 15 # To run locally:
16 # (a) Create and change to a directory to run the updater in: 16 # (a) Create and change to a directory to run the updater in:
17 # > mkdir /usr/local/google/home/$USER/dartium_deps_updater 17 # > mkdir /usr/local/google/home/$USER/dartium_deps_updater
18 # > cd /usr/local/google/home/$USER/dartium_deps_updater 18 # > cd /usr/local/google/home/$USER/dartium_deps_updater
19 # 19 #
20 # (b) Checkout a copy of the DEPS for the updater to process / update: 20 # (b) Make a 'deps' directory to store temporary files:
21 # > svn co https://dart.googlecode.com/svn/branches/bleeding_edge/deps/dart ium.deps 21 # > mkdir deps
22 # 22 #
23 # (c) Checkout dartium_tools (with this script) using the current branch instea d of 1750: 23 # (c) Checkout dartium_tools (with this script) using the current branch instea d of 1847:
24 # > svn co svn://svn.chromium.org/chrome/branches/dart/1750/src/dartium_too ls 24 # > svn co svn://svn.chromium.org/chrome/branches/dart/1847/src/dartium_too ls
25 # 25 #
26 # (d) If your home directory is remote, consider redefining it for this shell/s cript: 26 # (d) If your home directory is remote, consider redefining it for this shell/s cript:
27 # > cp -R $HOME/.subversion /usr/local/google/home/$USER 27 # > cp -R $HOME/.subversion /usr/local/google/home/$USER
28 # > export HOME=/usr/local/google/home/$USER 28 # > export HOME=/usr/local/google/home/$USER
29 # 29 #
30 # (e) Test by running (Ctrl-C to quit): 30 # (e) Test by running (Ctrl-C to quit):
31 # > ./dartium_tools/update_deps.py 31 # > ./dartium_tools/update_deps.py
32 # > ./dartium_tools/update_deps.py --target=multivm
33 # > ./dartium_tools/update_deps.py --target=clank
34 # > ./dartium_tools/update_deps.py --target=integration
32 # 35 #
33 # (f) Run periodical update: 36 # (f) Run periodical update:
34 # > while true; do ./dartium_tools/update_deps.py --force ; sleep 300 ; don e 37 # > while true; do ./dartium_tools/update_deps.py --force ; sleep 300 ; don e
35 38
36 ######################################################################## 39 ########################################################################
37 # Repositories to auto-update 40 # Repositories to auto-update
38 ######################################################################## 41 ########################################################################
39 42
43 BRANCH_CURRENT="dart/1847"
44 BRANCH_NEXT="dart/1908"
45 BRANCH_MULTIVM="dart/multivm"
46
47 TARGETS = {
48 'dartium': (
49 'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/dartium.deps',
50 'dartium',
51 ['webkit', 'chromium'],
52 BRANCH_CURRENT,
53 ),
54 'integration': (
55 'https://dart.googlecode.com/svn/branches/dartium_integration/deps/dartium.d eps',
56 'dartium',
57 ['webkit', 'chromium'],
58 BRANCH_NEXT,
59 ),
60 'clank': (
61 'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/clank.deps',
62 'dartium',
63 ['webkit', 'chromium'],
64 BRANCH_CURRENT,
65 ),
66 'multivm': (
67 'https://dart.googlecode.com/svn/branches/bleeding_edge/deps/multivm.deps',
68 'multivm',
69 ['blink'],
70 BRANCH_MULTIVM,
71 ),
72 }
73
40 # Each element in this map represents a repository to update. Entries 74 # Each element in this map represents a repository to update. Entries
41 # take the form: 75 # take the form:
42 # (repo_tag: (svn_url, view_url)) 76 # (repo_tag: (svn_url, view_url))
43 # 77 #
44 # The repo_tag must match the DEPS revision entry. I.e, there must be 78 # The repo_tag must match the DEPS revision entry. I.e, there must be
45 # an entry of the form: 79 # an entry of the form:
46 # 'dartium_%s_revision' % repo_tag 80 # 'dartium_%s_revision' % repo_tag
47 # to roll forward. 81 # to roll forward.
48 # 82 #
49 # The view_url should be parameterized by revision number. This is 83 # The view_url should be parameterized by revision number. This is
50 # used to generated the commit message. 84 # used to generated the commit message.
51 REPOSITORY_INFO = { 85 REPOSITORY_INFO = {
52 'webkit': ( 86 'webkit': (
53 'http://src.chromium.org/blink/branches/dart/1750', 87 'http://src.chromium.org/blink/branches/%s',
54 'http://src.chromium.org/viewvc/blink/branches/dart/1750?view=rev&revisi on=%s'), 88 'http://src.chromium.org/viewvc/blink?view=rev&revision=%s'),
89 'blink': (
90 'http://src.chromium.org/blink/branches/%s',
91 'http://src.chromium.org/viewvc/blink?view=rev&revision=%s'),
55 'chromium': ( 92 'chromium': (
56 'http://src.chromium.org/chrome/branches/dart/1750/src', 93 'http://src.chromium.org/chrome/branches/%s',
57 'http://src.chromium.org/viewvc/chrome/branches/dart/1750/src?view=rev&r evision=%s'), 94 'http://src.chromium.org/viewvc/chrome?view=rev&revision=%s'),
58 } 95 }
59 96
60 REPOSITORIES = REPOSITORY_INFO.keys() 97 REPOSITORIES = REPOSITORY_INFO.keys()
61 98
62 ######################################################################## 99 ########################################################################
63 # Actions 100 # Actions
64 ######################################################################## 101 ########################################################################
65 102
66 def write_file(filename, content): 103 def write_file(filename, content):
67 f = open(filename, "w") 104 f = open(filename, "w")
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 def merge_revs(revs): 178 def merge_revs(revs):
142 position = find_max(revs) 179 position = find_max(revs)
143 if position is None: 180 if position is None:
144 return [] 181 return []
145 item = revs[position][0] 182 item = revs[position][0]
146 revs[position] = revs[position][1:] 183 revs[position] = revs[position][1:]
147 return [item] + merge_revs(revs) 184 return [item] + merge_revs(revs)
148 185
149 def main(): 186 def main():
150 option_parser = optparse.OptionParser() 187 option_parser = optparse.OptionParser()
188 option_parser.add_option('', '--target', help="Update one of [dartium|integrat ion|multivm|clank]", action="store", dest="target", default="dartium")
151 option_parser.add_option('', '--force', help="Push DEPS update to server witho ut prompting", action="store_true", dest="force") 189 option_parser.add_option('', '--force', help="Push DEPS update to server witho ut prompting", action="store_true", dest="force")
152 options, args = option_parser.parse_args() 190 options, args = option_parser.parse_args()
153 191
154 src_dir = "/usr/local/google/home/%s/dartium_deps_updater/dartium.deps" % os.e nviron["USER"] 192 target = options.target
193 if not target in TARGETS.keys():
194 print "Error: invalid target"
195 print "Choose one of " + str(TARGETS)
196 (deps_dir, prefix, repos, branch) = TARGETS[target]
197 deps_file = deps_dir + '/DEPS'
198
199 src_dir = "/usr/local/google/home/%s/dartium_deps_updater/deps/%s" % (os.envir on["USER"], target)
155 os.putenv("GIT_PAGER", "") 200 os.putenv("GIT_PAGER", "")
156 201
157 if not os.path.exists(src_dir): 202 if not os.path.exists(src_dir):
158 print "Error: prior to running this script, you need to check out a Dartium source tree at" 203 print run_cmd(['svn', 'co', deps_dir, src_dir])
159 print " %s" % src_dir
160 print "Please reserve the above directory for this script and do not use it for other purposes."
161 sys.exit(1)
162 204
163 os.chdir(src_dir) 205 os.chdir(src_dir)
164 206
165 # parse DEPS 207 # parse DEPS
166 deps = run_cmd(['svn', 'cat', 'https://dart.googlecode.com/svn/branches/bleedi ng_edge/deps/dartium.deps/DEPS']) 208 deps = run_cmd(['svn', 'cat', deps_file])
167 rev_num = {} 209 rev_num = {}
168 for repo in REPOSITORIES: 210 for repo in repos:
169 revision = 'dartium_%s_revision":\s*"(.+)"' % repo 211 revision = '%s_%s_revision":\s*"(.+)"' % (prefix, repo)
170 rev_num[repo] = re.search(revision, deps).group(1) 212 rev_num[repo] = re.search(revision, deps).group(1)
171 213
172 # update repos 214 # update repos
173 all_revs = [] 215 all_revs = []
174 for repo, (svn_url, _) in REPOSITORY_INFO.items(): 216 for repo in repos:
175 output = run_cmd(["svn", "log", "-r", "HEAD:%s" % rev_num[repo], svn_url]) 217 (svn_url, _) = REPOSITORY_INFO[repo]
218 output = run_cmd(["svn", "log", "-r", "HEAD:%s" % rev_num[repo], svn_url % branch])
176 revs = parse_svn_log(output, repo) 219 revs = parse_svn_log(output, repo)
177 if revs and revs[-1]['rev'] == rev_num[repo]: 220 if revs and revs[-1]['rev'] == rev_num[repo]:
178 revs.pop() 221 revs.pop()
179 all_revs.append(revs) 222 all_revs.append(revs)
180 223
181 pending_updates = merge_revs(all_revs) 224 pending_updates = merge_revs(all_revs)
182 pending_updates.reverse() 225 pending_updates.reverse()
183 226
184 print 227 print
185 print "Current DEPS revisions:" 228 print "Current DEPS revisions:"
186 for repo in REPOSITORIES: 229 for repo in repos:
187 print ' dartium_%s_revision=%s' % (repo, rev_num[repo]) 230 print ' %s_%s_revision=%s' % (prefix, repo, rev_num[repo])
188 231
189 if len(pending_updates) == 0: 232 if len(pending_updates) == 0:
190 print "DEPS is up-to-date." 233 print "DEPS is up-to-date."
191 sys.exit(0) 234 sys.exit(0)
192 else: 235 else:
193 print "Pending DEPS updates:" 236 print "Pending DEPS updates:"
194 for s in pending_updates: 237 for s in pending_updates:
195 print " %s to %s (%s) %s" % (s['repo'], s['rev'], s['isotime'], s['info'] ) 238 print " %s to %s (%s) %s" % (s['repo'], s['rev'], s['isotime'], s['info'] )
196 239
197 # make the next DEPS update 240 # make the next DEPS update
198 os.chdir(src_dir) 241 os.chdir(src_dir)
199 run_cmd(['rm', 'DEPS']) 242 run_cmd(['rm', 'DEPS'])
200 print run_cmd(['svn', 'update']) 243 print run_cmd(['svn', 'update'])
201 s = pending_updates[0] 244 s = pending_updates[0]
202 245
203 pattern = re.compile('dartium_' + s['repo'] + '_revision":\s*"(.+)"') 246 pattern = re.compile(prefix + '_' + s['repo'] + '_revision":\s*"(.+)"')
204 new_deps = pattern.sub('dartium_' + s['repo'] + '_revision": "' + s['rev'] + ' "', deps) 247 new_deps = pattern.sub(prefix + '_' + s['repo'] + '_revision": "' + s['rev'] + '"', deps)
205 write_file('DEPS', new_deps) 248 write_file('DEPS', new_deps)
206 249
207 commit_log = 'DEPS AutoUpdate: %s to %s (%s) %s\n' % (s['repo'], s['rev'], s[' isotime'], s['author']) 250 commit_log = 'DEPS AutoUpdate: %s to %s (%s) %s\n' % (s['repo'], s['rev'], s[' isotime'], s['author'])
208 commit_log += s['info'] + '\n' + commit_url(s['repo'], s['rev']) 251 commit_log += s['info'] + '\n' + commit_url(s['repo'], s['rev'])
209 252
210 write_file('commit_log.txt', commit_log) 253 write_file('commit_log.txt', commit_log)
211 print run_cmd(['svn', 'diff']) 254 print run_cmd(['svn', 'diff'])
212 print 255 print
213 print "Commit log:" 256 print "Commit log:"
214 print "---------------------------------------------" 257 print "---------------------------------------------"
215 print commit_log 258 print commit_log
216 print "---------------------------------------------" 259 print "---------------------------------------------"
217 260
218 if not options.force: 261 if not options.force:
219 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..."
220 sys.stdin.readline() 263 sys.stdin.readline()
221 print run_cmd(['svn', 'commit', '--file', 'commit_log.txt']) 264 print run_cmd(['svn', 'commit', '--file', 'commit_log.txt'])
222 print "Done." 265 print "Done."
223 266
224 267
225 if '__main__' == __name__: 268 if '__main__' == __name__:
226 main() 269 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698