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

Side by Side Diff: tools/release/releases.py

Issue 1060013003: [release-tools] Only read from the chromium checkout in v8rel. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
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 6 # This script retrieves the history of all V8 branches 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
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 # Retrieve history for a specified branch. 307 # Retrieve history for a specified branch.
308 assert self._options.branch in (self.vc.GetBranches() + 308 assert self._options.branch in (self.vc.GetBranches() +
309 [self.vc.CandidateBranch(), self.vc.MasterBranch()]) 309 [self.vc.CandidateBranch(), self.vc.MasterBranch()])
310 releases += self.GetReleasesFromBranch(self._options.branch) 310 releases += self.GetReleasesFromBranch(self._options.branch)
311 311
312 self["releases"] = sorted(releases, 312 self["releases"] = sorted(releases,
313 key=lambda r: SortingKey(r["version"]), 313 key=lambda r: SortingKey(r["version"]),
314 reverse=True) 314 reverse=True)
315 315
316 316
317 class SwitchChromium(Step): 317 class UpdateChromiumCheckout(Step):
318 MESSAGE = "Switch to Chromium checkout." 318 MESSAGE = "Update the chromium checkout."
319 319
320 def RunStep(self): 320 def RunStep(self):
321 cwd = self._options.chromium 321 cwd = self._options.chromium
322 # Check for a clean workdir. 322 self.GitFetchOrigin("+refs/heads/*:refs/remotes/origin/*",
323 if not self.GitIsWorkdirClean(cwd=cwd): # pragma: no cover 323 "+refs/branch-heads/*:refs/remotes/branch-heads/*",
324 self.Die("Workspace is not clean. Please commit or undo your changes.") 324 cwd=cwd)
325 # Assert that the DEPS file is there. 325 # Update v8 checkout in chromium.
326 if not os.path.exists(os.path.join(cwd, "DEPS")): # pragma: no cover 326 self.GitFetchOrigin(cwd=os.path.join(cwd, "v8"))
327 self.Die("DEPS file not present.")
328
329
330 class UpdateChromiumCheckout(Step):
331 MESSAGE = "Update the checkout and create a new branch."
332
333 def RunStep(self):
334 cwd = self._options.chromium
335 self.GitCheckout("master", cwd=cwd)
336 self.GitPull(cwd=cwd)
337 self.DeleteBranch(self.Config("BRANCHNAME"), cwd=cwd)
338 self.GitCreateBranch(self.Config("BRANCHNAME"), cwd=cwd)
339 327
340 328
341 def ConvertToCommitNumber(step, revision): 329 def ConvertToCommitNumber(step, revision):
342 # Simple check for git hashes. 330 # Simple check for git hashes.
343 if revision.isdigit() and len(revision) < 8: 331 if revision.isdigit() and len(revision) < 8:
344 return revision 332 return revision
345 return step.GetCommitPositionNumber( 333 return step.GetCommitPositionNumber(
346 revision, cwd=os.path.join(step._options.chromium, "v8")) 334 revision, cwd=os.path.join(step._options.chromium, "v8"))
347 335
348 336
349 class RetrieveChromiumV8Releases(Step): 337 class RetrieveChromiumV8Releases(Step):
350 MESSAGE = "Retrieve V8 releases from Chromium DEPS." 338 MESSAGE = "Retrieve V8 releases from Chromium DEPS."
351 339
352 def RunStep(self): 340 def RunStep(self):
353 cwd = self._options.chromium 341 cwd = self._options.chromium
354 342
355 # Update v8 checkout in chromium.
356 self.GitFetchOrigin(cwd=os.path.join(cwd, "v8"))
357
358 # All v8 revisions we are interested in. 343 # All v8 revisions we are interested in.
359 releases_dict = dict((r["revision_git"], r) for r in self["releases"]) 344 releases_dict = dict((r["revision_git"], r) for r in self["releases"])
360 345
361 cr_releases = [] 346 cr_releases = []
362 count_past_last_v8 = 0 347 count_past_last_v8 = 0
363 try: 348 try:
364 for git_hash in self.GitLog( 349 for git_hash in self.GitLog(
365 format="%H", grep="V8", cwd=cwd).splitlines(): 350 format="%H", grep="V8", branch="origin/master",
366 if "DEPS" not in self.GitChangedFiles(git_hash, cwd=cwd): 351 path="DEPS", cwd=cwd).splitlines():
367 continue 352 deps = self.GitShowFile(git_hash, "DEPS", cwd=cwd)
368 if not self.GitCheckoutFileSafe("DEPS", git_hash, cwd=cwd):
369 break # pragma: no cover
370 deps = FileToText(os.path.join(cwd, "DEPS"))
371 match = DEPS_RE.search(deps) 353 match = DEPS_RE.search(deps)
372 if match: 354 if match:
373 cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd) 355 cr_rev = self.GetCommitPositionNumber(git_hash, cwd=cwd)
374 if cr_rev: 356 if cr_rev:
375 v8_hsh = match.group(1) 357 v8_hsh = match.group(1)
376 cr_releases.append([cr_rev, v8_hsh]) 358 cr_releases.append([cr_rev, v8_hsh])
377 359
378 if count_past_last_v8: 360 if count_past_last_v8:
379 count_past_last_v8 += 1 # pragma: no cover 361 count_past_last_v8 += 1 # pragma: no cover
380 362
381 if count_past_last_v8 > 10: 363 if count_past_last_v8 > 20:
Michael Achenbach 2015/04/07 14:21:15 10 was a bit too small... missed exactly one commi
382 break # pragma: no cover 364 break # pragma: no cover
383 365
384 # Stop as soon as we find a v8 revision that we didn't fetch in the 366 # Stop as soon as we find a v8 revision that we didn't fetch in the
385 # v8-revision-retrieval part above (i.e. a revision that's too old). 367 # v8-revision-retrieval part above (i.e. a revision that's too old).
386 # Just iterate a few more times in case there were reverts. 368 # Just iterate a few more times in case there were reverts.
387 if v8_hsh not in releases_dict: 369 if v8_hsh not in releases_dict:
388 count_past_last_v8 += 1 # pragma: no cover 370 count_past_last_v8 += 1 # pragma: no cover
389 371
390 # Allow Ctrl-C interrupt. 372 # Allow Ctrl-C interrupt.
391 except (KeyboardInterrupt, SystemExit): # pragma: no cover 373 except (KeyboardInterrupt, SystemExit): # pragma: no cover
392 pass 374 pass
393 375
394 # Clean up.
395 self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
396
397 # Add the chromium ranges to the v8 candidates and master releases. 376 # Add the chromium ranges to the v8 candidates and master releases.
398 all_ranges = BuildRevisionRanges(cr_releases) 377 all_ranges = BuildRevisionRanges(cr_releases)
399 378
400 for hsh, ranges in all_ranges.iteritems(): 379 for hsh, ranges in all_ranges.iteritems():
401 releases_dict.get(hsh, {})["chromium_revision"] = ranges 380 releases_dict.get(hsh, {})["chromium_revision"] = ranges
402 381
403 382
404 # TODO(machenbach): Unify common code with method above. 383 # TODO(machenbach): Unify common code with method above.
405 class RietrieveChromiumBranches(Step): 384 class RietrieveChromiumBranches(Step):
406 MESSAGE = "Retrieve Chromium branch information." 385 MESSAGE = "Retrieve Chromium branch information."
(...skipping 11 matching lines...) Expand all
418 # Transform into pure branch numbers. 397 # Transform into pure branch numbers.
419 branches = map(lambda r: int(re.match(r"branch-heads/(\d+)", r).group(1)), 398 branches = map(lambda r: int(re.match(r"branch-heads/(\d+)", r).group(1)),
420 branches) 399 branches)
421 400
422 branches = sorted(branches, reverse=True) 401 branches = sorted(branches, reverse=True)
423 402
424 cr_branches = [] 403 cr_branches = []
425 count_past_last_v8 = 0 404 count_past_last_v8 = 0
426 try: 405 try:
427 for branch in branches: 406 for branch in branches:
428 if not self.GitCheckoutFileSafe("DEPS", 407 deps = self.GitShowFile(
429 "branch-heads/%d" % branch, 408 "refs/branch-heads/%d" % branch, "DEPS", cwd=cwd)
430 cwd=cwd):
431 break # pragma: no cover
432 deps = FileToText(os.path.join(cwd, "DEPS"))
433 match = DEPS_RE.search(deps) 409 match = DEPS_RE.search(deps)
434 if match: 410 if match:
435 v8_hsh = match.group(1) 411 v8_hsh = match.group(1)
436 cr_branches.append([str(branch), v8_hsh]) 412 cr_branches.append([str(branch), v8_hsh])
437 413
438 if count_past_last_v8: 414 if count_past_last_v8:
439 count_past_last_v8 += 1 # pragma: no cover 415 count_past_last_v8 += 1 # pragma: no cover
440 416
441 if count_past_last_v8 > 10: 417 if count_past_last_v8 > 20:
442 break # pragma: no cover 418 break # pragma: no cover
443 419
444 # Stop as soon as we find a v8 revision that we didn't fetch in the 420 # Stop as soon as we find a v8 revision that we didn't fetch in the
445 # v8-revision-retrieval part above (i.e. a revision that's too old). 421 # v8-revision-retrieval part above (i.e. a revision that's too old).
446 # Just iterate a few more times in case there were reverts. 422 # Just iterate a few more times in case there were reverts.
447 if v8_hsh not in releases_dict: 423 if v8_hsh not in releases_dict:
448 count_past_last_v8 += 1 # pragma: no cover 424 count_past_last_v8 += 1 # pragma: no cover
449 425
450 # Allow Ctrl-C interrupt. 426 # Allow Ctrl-C interrupt.
451 except (KeyboardInterrupt, SystemExit): # pragma: no cover 427 except (KeyboardInterrupt, SystemExit): # pragma: no cover
452 pass 428 pass
453 429
454 # Clean up.
455 self.GitCheckoutFileSafe("DEPS", "HEAD", cwd=cwd)
456
457 # Add the chromium branches to the v8 candidate releases. 430 # Add the chromium branches to the v8 candidate releases.
458 all_ranges = BuildRevisionRanges(cr_branches) 431 all_ranges = BuildRevisionRanges(cr_branches)
459 for revision, ranges in all_ranges.iteritems(): 432 for revision, ranges in all_ranges.iteritems():
460 releases_dict.get(revision, {})["chromium_branch"] = ranges 433 releases_dict.get(revision, {})["chromium_branch"] = ranges
461 434
462 435
463 class CleanUp(Step): 436 class CleanUp(Step):
464 MESSAGE = "Clean up." 437 MESSAGE = "Clean up."
465 438
466 def RunStep(self): 439 def RunStep(self):
467 self.GitCheckout("master", cwd=self._options.chromium)
468 self.GitDeleteBranch(self.Config("BRANCHNAME"), cwd=self._options.chromium)
469 self.CommonCleanup() 440 self.CommonCleanup()
470 441
471 442
472 class WriteOutput(Step): 443 class WriteOutput(Step):
473 MESSAGE = "Print output." 444 MESSAGE = "Print output."
474 445
475 def Run(self): 446 def Run(self):
476 if self._options.csv: 447 if self._options.csv:
477 with open(self._options.csv, "w") as f: 448 with open(self._options.csv, "w") as f:
478 writer = csv.DictWriter(f, 449 writer = csv.DictWriter(f,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 def _Config(self): 482 def _Config(self):
512 return { 483 return {
513 "BRANCHNAME": "retrieve-v8-releases", 484 "BRANCHNAME": "retrieve-v8-releases",
514 "PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile", 485 "PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile",
515 } 486 }
516 487
517 def _Steps(self): 488 def _Steps(self):
518 return [ 489 return [
519 Preparation, 490 Preparation,
520 RetrieveV8Releases, 491 RetrieveV8Releases,
521 SwitchChromium,
522 UpdateChromiumCheckout, 492 UpdateChromiumCheckout,
523 RetrieveChromiumV8Releases, 493 RetrieveChromiumV8Releases,
524 RietrieveChromiumBranches, 494 RietrieveChromiumBranches,
tandrii(chromium) 2015/04/07 15:13:51 unrelated CL nit: /s/RietrieveChromiumBranches/Ret
Michael Achenbach 2015/04/07 19:41:48 Yea - looks like Rietveld :) - but I'll hit the CQ
525 CleanUp, 495 CleanUp,
526 WriteOutput, 496 WriteOutput,
527 ] 497 ]
528 498
529 499
530 if __name__ == "__main__": # pragma: no cover 500 if __name__ == "__main__": # pragma: no cover
531 sys.exit(Releases().Run()) 501 sys.exit(Releases().Run())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698