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

Side by Side Diff: tools/push-to-trunk/releases.py

Issue 594773003: Refactoring: Remove global configs in release scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove global configs. Created 6 years, 2 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 the V8 project authors. All rights reserved. 2 # Copyright 2014 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # This script retrieves the history of all V8 branches and trunk revisions and 6 # This script retrieves the history of all V8 branches and trunk revisions and
7 # their corresponding Chromium revisions. 7 # their corresponding Chromium revisions.
8 8
9 # Requires a chromium checkout with branch heads: 9 # Requires a chromium checkout with branch heads:
10 # gclient sync --with_branch_heads 10 # gclient sync --with_branch_heads
11 # gclient fetch 11 # gclient fetch
12 12
13 import argparse 13 import argparse
14 import csv 14 import csv
15 import itertools 15 import itertools
16 import json 16 import json
17 import os 17 import os
18 import re 18 import re
19 import sys 19 import sys
20 20
21 from common_includes import * 21 from common_includes import *
22 22
23 CHROMIUM = "CHROMIUM"
24
25 CONFIG = { 23 CONFIG = {
26 BRANCHNAME: "retrieve-v8-releases", 24 "BRANCHNAME": "retrieve-v8-releases",
27 PERSISTFILE_BASENAME: "/tmp/v8-releases-tempfile", 25 "PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile",
28 } 26 }
29 27
30 # Expression for retrieving the bleeding edge revision from a commit message. 28 # Expression for retrieving the bleeding edge revision from a commit message.
31 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") 29 PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$")
32 30
33 # Expression for retrieving the merged patches from a merge commit message 31 # Expression for retrieving the merged patches from a merge commit message
34 # (old and new format). 32 # (old and new format).
35 MERGE_MESSAGE_RE = re.compile(r"^.*[M|m]erged (.+)(\)| into).*$", re.M) 33 MERGE_MESSAGE_RE = re.compile(r"^.*[M|m]erged (.+)(\)| into).*$", re.M)
36 34
37 # Expression for retrieving reverted patches from a commit message (old and 35 # Expression for retrieving reverted patches from a commit message (old and
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 222
225 # Allow Ctrl-C interrupt. 223 # Allow Ctrl-C interrupt.
226 except (KeyboardInterrupt, SystemExit): # pragma: no cover 224 except (KeyboardInterrupt, SystemExit): # pragma: no cover
227 pass 225 pass
228 226
229 # Clean up checked-out version file. 227 # Clean up checked-out version file.
230 self.GitCheckoutFileSafe(VERSION_FILE, "HEAD") 228 self.GitCheckoutFileSafe(VERSION_FILE, "HEAD")
231 return releases 229 return releases
232 230
233 def RunStep(self): 231 def RunStep(self):
234 self.GitCreateBranch(self._config[BRANCHNAME]) 232 self.GitCreateBranch(self._config["BRANCHNAME"])
235 # Get relevant remote branches, e.g. "svn/3.25". 233 # Get relevant remote branches, e.g. "svn/3.25".
236 branches = filter(lambda s: re.match(r"^svn/\d+\.\d+$", s), 234 branches = filter(lambda s: re.match(r"^svn/\d+\.\d+$", s),
237 self.GitRemotes()) 235 self.GitRemotes())
238 # Remove 'svn/' prefix. 236 # Remove 'svn/' prefix.
239 branches = map(lambda s: s[4:], branches) 237 branches = map(lambda s: s[4:], branches)
240 238
241 releases = [] 239 releases = []
242 if self._options.branch == 'recent': 240 if self._options.branch == 'recent':
243 # Get only recent development on trunk, beta and stable. 241 # Get only recent development on trunk, beta and stable.
244 if self._options.max_releases == 0: # pragma: no cover 242 if self._options.max_releases == 0: # pragma: no cover
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 self.Die("DEPS file not present.") 275 self.Die("DEPS file not present.")
278 276
279 277
280 class UpdateChromiumCheckout(Step): 278 class UpdateChromiumCheckout(Step):
281 MESSAGE = "Update the checkout and create a new branch." 279 MESSAGE = "Update the checkout and create a new branch."
282 280
283 def RunStep(self): 281 def RunStep(self):
284 cwd = self._options.chromium 282 cwd = self._options.chromium
285 self.GitCheckout("master", cwd=cwd) 283 self.GitCheckout("master", cwd=cwd)
286 self.GitPull(cwd=cwd) 284 self.GitPull(cwd=cwd)
287 self.GitCreateBranch(self.Config(BRANCHNAME), cwd=cwd) 285 self.GitCreateBranch(self.Config("BRANCHNAME"), cwd=cwd)
288 286
289 287
290 def ConvertToCommitNumber(step, revision): 288 def ConvertToCommitNumber(step, revision):
291 # Simple check for git hashes. 289 # Simple check for git hashes.
292 if revision.isdigit() and len(revision) < 8: 290 if revision.isdigit() and len(revision) < 8:
293 return revision 291 return revision
294 return step.GitConvertToSVNRevision( 292 return step.GitConvertToSVNRevision(
295 revision, cwd=os.path.join(step._options.chromium, "v8")) 293 revision, cwd=os.path.join(step._options.chromium, "v8"))
296 294
297 295
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 trunk_dict = dict((r["revision"], r) for r in trunk_releases) 399 trunk_dict = dict((r["revision"], r) for r in trunk_releases)
402 for revision, ranges in all_ranges.iteritems(): 400 for revision, ranges in all_ranges.iteritems():
403 trunk_dict.get(revision, {})["chromium_branch"] = ranges 401 trunk_dict.get(revision, {})["chromium_branch"] = ranges
404 402
405 403
406 class CleanUp(Step): 404 class CleanUp(Step):
407 MESSAGE = "Clean up." 405 MESSAGE = "Clean up."
408 406
409 def RunStep(self): 407 def RunStep(self):
410 self.GitCheckout("master", cwd=self._options.chromium) 408 self.GitCheckout("master", cwd=self._options.chromium)
411 self.GitDeleteBranch(self.Config(BRANCHNAME), cwd=self._options.chromium) 409 self.GitDeleteBranch(self.Config("BRANCHNAME"), cwd=self._options.chromium)
412 self.CommonCleanup() 410 self.CommonCleanup()
413 411
414 412
415 class WriteOutput(Step): 413 class WriteOutput(Step):
416 MESSAGE = "Print output." 414 MESSAGE = "Print output."
417 415
418 def Run(self): 416 def Run(self):
419 if self._options.csv: 417 if self._options.csv:
420 with open(self._options.csv, "w") as f: 418 with open(self._options.csv, "w") as f:
421 writer = csv.DictWriter(f, 419 writer = csv.DictWriter(f,
(...skipping 20 matching lines...) Expand all
442 help=("The path to your Chromium src/ " 440 help=("The path to your Chromium src/ "
443 "directory to automate the V8 roll.")) 441 "directory to automate the V8 roll."))
444 parser.add_argument("--csv", help="Path to a CSV file for export.") 442 parser.add_argument("--csv", help="Path to a CSV file for export.")
445 parser.add_argument("-m", "--max-releases", type=int, default=0, 443 parser.add_argument("-m", "--max-releases", type=int, default=0,
446 help="The maximum number of releases to track.") 444 help="The maximum number of releases to track.")
447 parser.add_argument("--json", help="Path to a JSON file for export.") 445 parser.add_argument("--json", help="Path to a JSON file for export.")
448 446
449 def _ProcessOptions(self, options): # pragma: no cover 447 def _ProcessOptions(self, options): # pragma: no cover
450 return True 448 return True
451 449
450 def _Config(self):
451 return {
452 "BRANCHNAME": "retrieve-v8-releases",
453 "PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile",
454 }
455
452 def _Steps(self): 456 def _Steps(self):
453 return [ 457 return [
454 Preparation, 458 Preparation,
455 RetrieveV8Releases, 459 RetrieveV8Releases,
456 SwitchChromium, 460 SwitchChromium,
457 UpdateChromiumCheckout, 461 UpdateChromiumCheckout,
458 RetrieveChromiumV8Releases, 462 RetrieveChromiumV8Releases,
459 RietrieveChromiumBranches, 463 RietrieveChromiumBranches,
460 CleanUp, 464 CleanUp,
461 WriteOutput, 465 WriteOutput,
462 ] 466 ]
463 467
464 468
465 if __name__ == "__main__": # pragma: no cover 469 if __name__ == "__main__": # pragma: no cover
466 sys.exit(Releases(CONFIG).Run()) 470 sys.exit(Releases().Run())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698