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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 DAY_IN_SECONDS = 24 * 60 * 60 | 49 DAY_IN_SECONDS = 24 * 60 * 60 |
50 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") | 50 PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$") |
51 PUSH_MSG_NEW_RE = re.compile(r"^Version \d+\.\d+\.\d+$") | 51 PUSH_MSG_NEW_RE = re.compile(r"^Version \d+\.\d+\.\d+$") |
52 VERSION_FILE = os.path.join("include", "v8-version.h") | 52 VERSION_FILE = os.path.join("include", "v8-version.h") |
53 VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$") | 53 VERSION_RE_RAW = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$") |
54 VERSION_RE_TAGS = re.compile(r"^tags\/\d+\.\d+\.\d+(?:\.\d+)?$") | |
54 | 55 |
55 # V8 base directory. | 56 # V8 base directory. |
56 V8_BASE = os.path.dirname( | 57 V8_BASE = os.path.dirname( |
57 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 58 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
58 | 59 |
59 | 60 |
60 def TextToFile(text, file_name): | 61 def TextToFile(text, file_name): |
61 with open(file_name, "w") as f: | 62 with open(file_name, "w") as f: |
62 f.write(text) | 63 f.write(text) |
63 | 64 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 | 601 |
601 # Takes a file containing the patch to apply as first argument. | 602 # Takes a file containing the patch to apply as first argument. |
602 def ApplyPatch(self, patch_file, revert=False): | 603 def ApplyPatch(self, patch_file, revert=False): |
603 try: | 604 try: |
604 self.GitApplyPatch(patch_file, revert) | 605 self.GitApplyPatch(patch_file, revert) |
605 except GitFailedException: | 606 except GitFailedException: |
606 self.WaitForResolvingConflicts(patch_file) | 607 self.WaitForResolvingConflicts(patch_file) |
607 | 608 |
608 def GetVersionTag(self, revision): | 609 def GetVersionTag(self, revision): |
609 tag = self.Git("describe --tags %s" % revision).strip() | 610 tag = self.Git("describe --tags %s" % revision).strip() |
610 if VERSION_RE.match(tag): | 611 return self._SanitizeVersionTag(tag) |
611 return tag | |
612 else: | |
613 return None | |
614 | 612 |
615 def GetRecentReleases(self, max_age): | 613 def GetRecentReleases(self, max_age): |
616 # Make sure tags are fetched. | 614 # Make sure tags are fetched. |
617 self.Git("fetch origin +refs/tags/*:refs/tags/*") | 615 self.Git("fetch origin +refs/tags/*:refs/tags/*") |
618 | 616 |
619 # Current timestamp. | 617 # Current timestamp. |
620 time_now = int(self._side_effect_handler.GetUTCStamp()) | 618 time_now = int(self._side_effect_handler.GetUTCStamp()) |
621 | 619 |
622 # List every tag from a given period. | 620 # List every tag from a given period. |
623 revisions = self.Git("rev-list --max-age=%d --tags" % | 621 revisions = self.Git("rev-list --max-age=%d --tags" % |
624 int(time_now - max_age)).strip() | 622 int(time_now - max_age)).strip() |
625 | 623 |
626 # Filter out revisions who's tag is off by one or more commits. | 624 # Filter out revisions who's tag is off by one or more commits. |
627 return filter(lambda r: self.GetVersionTag(r), revisions.splitlines()) | 625 return filter(lambda r: self.GetVersionTag(r), revisions.splitlines()) |
628 | 626 |
629 def GetLatestVersion(self): | 627 def GetLatestVersion(self): |
630 # Use cached version if available. | 628 # Use cached version if available. |
631 if self["latest_version"]: | 629 if self["latest_version"]: |
632 return self["latest_version"] | 630 return self["latest_version"] |
633 | 631 |
634 # Make sure tags are fetched. | 632 # Make sure tags are fetched. |
635 self.Git("fetch origin +refs/tags/*:refs/tags/*") | 633 self.Git("fetch origin +refs/tags/*:refs/tags/*") |
636 version = sorted(filter(VERSION_RE.match, self.vc.GetTags()), | 634 |
635 all_tags = self.vc.GetTags() | |
636 only_version_tags = [] | |
637 | |
638 # Remove tags/ prefix because of packed refs. | |
639 for current_tag in all_tags: | |
640 version_tag = self._SanitizeVersionTag(current_tag) | |
641 if version_tag != None: | |
642 only_version_tags.append(version_tag) | |
643 | |
644 version = sorted(only_version_tags, | |
637 key=SortingKey, reverse=True)[0] | 645 key=SortingKey, reverse=True)[0] |
638 self["latest_version"] = version | 646 self["latest_version"] = version |
639 return version | 647 return version |
640 | 648 |
641 def GetLatestRelease(self): | 649 def GetLatestRelease(self): |
642 """The latest release is the git hash of the latest tagged version. | 650 """The latest release is the git hash of the latest tagged version. |
643 | 651 |
644 This revision should be rolled into chromium. | 652 This revision should be rolled into chromium. |
645 """ | 653 """ |
646 latest_version = self.GetLatestVersion() | 654 latest_version = self.GetLatestVersion() |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 elif line.startswith("#define V8_BUILD_NUMBER"): | 713 elif line.startswith("#define V8_BUILD_NUMBER"): |
706 line = re.sub("\d+$", self[prefix + "build"], line) | 714 line = re.sub("\d+$", self[prefix + "build"], line) |
707 elif line.startswith("#define V8_PATCH_LEVEL"): | 715 elif line.startswith("#define V8_PATCH_LEVEL"): |
708 line = re.sub("\d+$", self[prefix + "patch"], line) | 716 line = re.sub("\d+$", self[prefix + "patch"], line) |
709 elif (self[prefix + "candidate"] and | 717 elif (self[prefix + "candidate"] and |
710 line.startswith("#define V8_IS_CANDIDATE_VERSION")): | 718 line.startswith("#define V8_IS_CANDIDATE_VERSION")): |
711 line = re.sub("\d+$", self[prefix + "candidate"], line) | 719 line = re.sub("\d+$", self[prefix + "candidate"], line) |
712 output += "%s\n" % line | 720 output += "%s\n" % line |
713 TextToFile(output, version_file) | 721 TextToFile(output, version_file) |
714 | 722 |
723 def _SanitizeVersionTag(self, tag): | |
Michael Achenbach
2015/11/05 13:08:38
I'd prefer to just do this:
if tag.startswith('ta
Michael Hablich
2015/11/05 13:31:54
I still need to check and filter for valid version
Michael Achenbach
2015/11/05 14:07:55
I generally find functional things easier to read.
Michael Hablich
2015/11/05 14:38:21
Well, I converted the method to a function so it c
| |
724 if VERSION_RE_RAW.match(tag): | |
725 return tag | |
726 elif VERSION_RE_TAGS.match(tag): | |
727 return tag[5:] | |
Michael Achenbach
2015/11/05 13:08:38
nit tag[len('tags/'):] might make the intention cl
Michael Hablich
2015/11/05 13:31:54
Acknowledged.
| |
728 else: | |
729 return None | |
730 | |
715 | 731 |
716 class BootstrapStep(Step): | 732 class BootstrapStep(Step): |
717 MESSAGE = "Bootstapping v8 checkout." | 733 MESSAGE = "Bootstapping v8 checkout." |
718 | 734 |
719 def RunStep(self): | 735 def RunStep(self): |
720 if os.path.realpath(self.default_cwd) == os.path.realpath(V8_BASE): | 736 if os.path.realpath(self.default_cwd) == os.path.realpath(V8_BASE): |
721 self.Die("Can't use v8 checkout with calling script as work checkout.") | 737 self.Die("Can't use v8 checkout with calling script as work checkout.") |
722 # Directory containing the working v8 checkout. | 738 # Directory containing the working v8 checkout. |
723 if not os.path.exists(self._options.work_dir): | 739 if not os.path.exists(self._options.work_dir): |
724 os.makedirs(self._options.work_dir) | 740 os.makedirs(self._options.work_dir) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
872 for (number, step_class) in enumerate([BootstrapStep] + step_classes): | 888 for (number, step_class) in enumerate([BootstrapStep] + step_classes): |
873 steps.append(MakeStep(step_class, number, self._state, self._config, | 889 steps.append(MakeStep(step_class, number, self._state, self._config, |
874 options, self._side_effect_handler)) | 890 options, self._side_effect_handler)) |
875 for step in steps[options.step:]: | 891 for step in steps[options.step:]: |
876 if step.Run(): | 892 if step.Run(): |
877 return 0 | 893 return 0 |
878 return 0 | 894 return 0 |
879 | 895 |
880 def Run(self, args=None): | 896 def Run(self, args=None): |
881 return self.RunSteps(self._Steps(), args) | 897 return self.RunSteps(self._Steps(), args) |
OLD | NEW |