Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 import textwrap | 40 import textwrap |
| 41 import time | 41 import time |
| 42 import urllib | 42 import urllib |
| 43 import urllib2 | 43 import urllib2 |
| 44 | 44 |
| 45 from git_recipes import GitRecipesMixin | 45 from git_recipes import GitRecipesMixin |
| 46 from git_recipes import GitFailedException | 46 from git_recipes import GitFailedException |
| 47 | 47 |
| 48 CHANGELOG_FILE = "ChangeLog" | 48 CHANGELOG_FILE = "ChangeLog" |
| 49 VERSION_FILE = os.path.join("src", "version.cc") | 49 VERSION_FILE = os.path.join("src", "version.cc") |
| 50 VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$") | |
| 50 | 51 |
| 51 # V8 base directory. | 52 # V8 base directory. |
| 52 V8_BASE = os.path.dirname( | 53 V8_BASE = os.path.dirname( |
| 53 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 54 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 54 | 55 |
| 55 | 56 |
| 56 def TextToFile(text, file_name): | 57 def TextToFile(text, file_name): |
| 57 with open(file_name, "w") as f: | 58 with open(file_name, "w") as f: |
| 58 f.write(text) | 59 f.write(text) |
| 59 | 60 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 os.path.join(self._options.work_dir, "v8")) | 374 os.path.join(self._options.work_dir, "v8")) |
| 374 | 375 |
| 375 assert self._number >= 0 | 376 assert self._number >= 0 |
| 376 assert self._config is not None | 377 assert self._config is not None |
| 377 assert self._state is not None | 378 assert self._state is not None |
| 378 assert self._side_effect_handler is not None | 379 assert self._side_effect_handler is not None |
| 379 | 380 |
| 380 def __getitem__(self, key): | 381 def __getitem__(self, key): |
| 381 # Convenience method to allow direct [] access on step classes for | 382 # Convenience method to allow direct [] access on step classes for |
| 382 # manipulating the backed state dict. | 383 # manipulating the backed state dict. |
| 383 return self._state[key] | 384 return self._state.get(key) |
|
tandrii(chromium)
2015/01/27 23:59:28
Are you sure there were no code relying on KeyErro
| |
| 384 | 385 |
| 385 def __setitem__(self, key, value): | 386 def __setitem__(self, key, value): |
| 386 # Convenience method to allow direct [] access on step classes for | 387 # Convenience method to allow direct [] access on step classes for |
| 387 # manipulating the backed state dict. | 388 # manipulating the backed state dict. |
| 388 self._state[key] = value | 389 self._state[key] = value |
| 389 | 390 |
| 390 def Config(self, key): | 391 def Config(self, key): |
| 391 return self._config[key] | 392 return self._config[key] |
| 392 | 393 |
| 393 def Run(self): | 394 def Run(self): |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 print "> ", | 583 print "> ", |
| 583 answer = self.ReadLine() | 584 answer = self.ReadLine() |
| 584 | 585 |
| 585 # Takes a file containing the patch to apply as first argument. | 586 # Takes a file containing the patch to apply as first argument. |
| 586 def ApplyPatch(self, patch_file, revert=False): | 587 def ApplyPatch(self, patch_file, revert=False): |
| 587 try: | 588 try: |
| 588 self.GitApplyPatch(patch_file, revert) | 589 self.GitApplyPatch(patch_file, revert) |
| 589 except GitFailedException: | 590 except GitFailedException: |
| 590 self.WaitForResolvingConflicts(patch_file) | 591 self.WaitForResolvingConflicts(patch_file) |
| 591 | 592 |
| 593 def GetLatestVersion(self): | |
| 594 # Use cached version if available. | |
| 595 if self["latest_version"]: | |
| 596 return self["latest_version"] | |
| 597 | |
| 598 # Make sure tags are fetched. | |
| 599 self.Git("fetch origin +refs/tags/*:refs/tags/*") | |
| 600 version_parts = sorted(filter(VERSION_RE.match, self.vc.GetTags()), | |
| 601 key=SortingKey, reverse=True)[0].split(".") | |
| 602 if len(version_parts) == 3: | |
| 603 version_parts.append("0") | |
| 604 self["latest_version"] = ".".join(version_parts) | |
| 605 return self["latest_version"] | |
| 606 | |
| 592 def FindLastCandidatesPush( | 607 def FindLastCandidatesPush( |
| 593 self, parent_hash="", branch="", include_patches=False): | 608 self, parent_hash="", branch="", include_patches=False): |
| 594 push_pattern = "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*" | 609 push_pattern = "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*" |
| 595 if not include_patches: | 610 if not include_patches: |
| 596 # Non-patched versions only have three numbers followed by the "(based | 611 # Non-patched versions only have three numbers followed by the "(based |
| 597 # on...) comment." | 612 # on...) comment." |
| 598 push_pattern += " (based" | 613 push_pattern += " (based" |
| 599 branch = "" if parent_hash else branch or self.vc.RemoteCandidateBranch() | 614 branch = "" if parent_hash else branch or self.vc.RemoteCandidateBranch() |
| 600 return self.GitLog(n=1, format="%H", grep=push_pattern, | 615 return self.GitLog(n=1, format="%H", grep=push_pattern, |
| 601 parent_hash=parent_hash, branch=branch) | 616 parent_hash=parent_hash, branch=branch) |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 for (number, step_class) in enumerate([BootstrapStep] + step_classes): | 819 for (number, step_class) in enumerate([BootstrapStep] + step_classes): |
| 805 steps.append(MakeStep(step_class, number, self._state, self._config, | 820 steps.append(MakeStep(step_class, number, self._state, self._config, |
| 806 options, self._side_effect_handler)) | 821 options, self._side_effect_handler)) |
| 807 for step in steps[options.step:]: | 822 for step in steps[options.step:]: |
| 808 if step.Run(): | 823 if step.Run(): |
| 809 return 0 | 824 return 0 |
| 810 return 0 | 825 return 0 |
| 811 | 826 |
| 812 def Run(self, args=None): | 827 def Run(self, args=None): |
| 813 return self.RunSteps(self._Steps(), args) | 828 return self.RunSteps(self._Steps(), args) |
| OLD | NEW |