OLD | NEW |
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 # 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 class Preparation(Step): | 53 class Preparation(Step): |
54 MESSAGE = "Preparation." | 54 MESSAGE = "Preparation." |
55 | 55 |
56 def RunStep(self): | 56 def RunStep(self): |
57 if os.path.exists(self.Config(ALREADY_MERGING_SENTINEL_FILE)): | 57 if os.path.exists(self.Config(ALREADY_MERGING_SENTINEL_FILE)): |
58 if self._options.force: | 58 if self._options.force: |
59 os.remove(self.Config(ALREADY_MERGING_SENTINEL_FILE)) | 59 os.remove(self.Config(ALREADY_MERGING_SENTINEL_FILE)) |
60 elif self._options.step == 0: | 60 elif self._options.step == 0: # pragma: no cover |
61 self.Die("A merge is already in progress") | 61 self.Die("A merge is already in progress") |
62 open(self.Config(ALREADY_MERGING_SENTINEL_FILE), "a").close() | 62 open(self.Config(ALREADY_MERGING_SENTINEL_FILE), "a").close() |
63 | 63 |
64 self.InitialEnvironmentChecks() | 64 self.InitialEnvironmentChecks() |
65 if self._options.revert_bleeding_edge: | 65 if self._options.revert_bleeding_edge: |
66 self["merge_to_branch"] = "bleeding_edge" | 66 self["merge_to_branch"] = "bleeding_edge" |
67 elif self._options.branch: | 67 elif self._options.branch: |
68 self["merge_to_branch"] = self._options.branch | 68 self["merge_to_branch"] = self._options.branch |
69 else: | 69 else: # pragma: no cover |
70 self.Die("Please specify a branch to merge to") | 70 self.Die("Please specify a branch to merge to") |
71 | 71 |
72 self.CommonPrepare() | 72 self.CommonPrepare() |
73 self.PrepareBranch() | 73 self.PrepareBranch() |
74 | 74 |
75 | 75 |
76 class CreateBranch(Step): | 76 class CreateBranch(Step): |
77 MESSAGE = "Create a fresh branch for the patch." | 77 MESSAGE = "Create a fresh branch for the patch." |
78 | 78 |
79 def RunStep(self): | 79 def RunStep(self): |
80 self.GitCreateBranch(self.Config(BRANCHNAME), | 80 self.GitCreateBranch(self.Config(BRANCHNAME), |
81 "svn/%s" % self["merge_to_branch"]) | 81 "svn/%s" % self["merge_to_branch"]) |
82 | 82 |
83 | 83 |
84 class SearchArchitecturePorts(Step): | 84 class SearchArchitecturePorts(Step): |
85 MESSAGE = "Search for corresponding architecture ports." | 85 MESSAGE = "Search for corresponding architecture ports." |
86 | 86 |
87 def RunStep(self): | 87 def RunStep(self): |
88 self["full_revision_list"] = list(OrderedDict.fromkeys( | 88 self["full_revision_list"] = list(OrderedDict.fromkeys( |
89 self._options.revisions)) | 89 self._options.revisions)) |
90 port_revision_list = [] | 90 port_revision_list = [] |
91 for revision in self["full_revision_list"]: | 91 for revision in self["full_revision_list"]: |
92 # Search for commits which matches the "Port rXXX" pattern. | 92 # Search for commits which matches the "Port rXXX" pattern. |
93 git_hashes = self.GitLog(reverse=True, format="%H", | 93 git_hashes = self.GitLog(reverse=True, format="%H", |
94 grep="Port r%d" % int(revision), | 94 grep="Port r%d" % int(revision), |
95 branch="svn/bleeding_edge") | 95 branch="svn/bleeding_edge") |
96 for git_hash in git_hashes.splitlines(): | 96 for git_hash in git_hashes.splitlines(): |
97 svn_revision = self.GitSVNFindSVNRev(git_hash, "svn/bleeding_edge") | 97 svn_revision = self.GitSVNFindSVNRev(git_hash, "svn/bleeding_edge") |
98 if not svn_revision: | 98 if not svn_revision: # pragma: no cover |
99 self.Die("Cannot determine svn revision for %s" % git_hash) | 99 self.Die("Cannot determine svn revision for %s" % git_hash) |
100 revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash) | 100 revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash) |
101 | 101 |
102 # Is this revision included in the original revision list? | 102 # Is this revision included in the original revision list? |
103 if svn_revision in self["full_revision_list"]: | 103 if svn_revision in self["full_revision_list"]: |
104 print("Found port of r%s -> r%s (already included): %s" | 104 print("Found port of r%s -> r%s (already included): %s" |
105 % (revision, svn_revision, revision_title)) | 105 % (revision, svn_revision, revision_title)) |
106 else: | 106 else: |
107 print("Found port of r%s -> r%s: %s" | 107 print("Found port of r%s -> r%s: %s" |
108 % (revision, svn_revision, revision_title)) | 108 % (revision, svn_revision, revision_title)) |
109 port_revision_list.append(svn_revision) | 109 port_revision_list.append(svn_revision) |
110 | 110 |
111 # Do we find any port? | 111 # Do we find any port? |
112 if len(port_revision_list) > 0: | 112 if len(port_revision_list) > 0: |
113 if self.Confirm("Automatically add corresponding ports (%s)?" | 113 if self.Confirm("Automatically add corresponding ports (%s)?" |
114 % ", ".join(port_revision_list)): | 114 % ", ".join(port_revision_list)): |
115 #: 'y': Add ports to revision list. | 115 #: 'y': Add ports to revision list. |
116 self["full_revision_list"].extend(port_revision_list) | 116 self["full_revision_list"].extend(port_revision_list) |
117 | 117 |
118 | 118 |
119 class FindGitRevisions(Step): | 119 class FindGitRevisions(Step): |
120 MESSAGE = "Find the git revisions associated with the patches." | 120 MESSAGE = "Find the git revisions associated with the patches." |
121 | 121 |
122 def RunStep(self): | 122 def RunStep(self): |
123 self["patch_commit_hashes"] = [] | 123 self["patch_commit_hashes"] = [] |
124 for revision in self["full_revision_list"]: | 124 for revision in self["full_revision_list"]: |
125 next_hash = self.GitSVNFindGitHash(revision, "svn/bleeding_edge") | 125 next_hash = self.GitSVNFindGitHash(revision, "svn/bleeding_edge") |
126 if not next_hash: | 126 if not next_hash: # pragma: no cover |
127 self.Die("Cannot determine git hash for r%s" % revision) | 127 self.Die("Cannot determine git hash for r%s" % revision) |
128 self["patch_commit_hashes"].append(next_hash) | 128 self["patch_commit_hashes"].append(next_hash) |
129 | 129 |
130 # Stringify: [123, 234] -> "r123, r234" | 130 # Stringify: [123, 234] -> "r123, r234" |
131 self["revision_list"] = ", ".join(map(lambda s: "r%s" % s, | 131 self["revision_list"] = ", ".join(map(lambda s: "r%s" % s, |
132 self["full_revision_list"])) | 132 self["full_revision_list"])) |
133 | 133 |
134 if not self["revision_list"]: | 134 if not self["revision_list"]: # pragma: no cover |
135 self.Die("Revision list is empty.") | 135 self.Die("Revision list is empty.") |
136 | 136 |
137 if self._options.revert: | 137 if self._options.revert: |
138 if not self._options.revert_bleeding_edge: | 138 if not self._options.revert_bleeding_edge: |
139 self["new_commit_msg"] = ("Rollback of %s in %s branch." | 139 self["new_commit_msg"] = ("Rollback of %s in %s branch." |
140 % (self["revision_list"], self["merge_to_branch"])) | 140 % (self["revision_list"], self["merge_to_branch"])) |
141 else: | 141 else: |
142 self["new_commit_msg"] = "Revert %s." % self["revision_list"] | 142 self["new_commit_msg"] = "Revert %s." % self["revision_list"] |
143 else: | 143 else: |
144 self["new_commit_msg"] = ("Merged %s into %s branch." | 144 self["new_commit_msg"] = ("Merged %s into %s branch." |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 class PrepareSVN(Step): | 226 class PrepareSVN(Step): |
227 MESSAGE = "Determine svn commit revision." | 227 MESSAGE = "Determine svn commit revision." |
228 | 228 |
229 def RunStep(self): | 229 def RunStep(self): |
230 if self._options.revert_bleeding_edge: | 230 if self._options.revert_bleeding_edge: |
231 return | 231 return |
232 self.GitSVNFetch() | 232 self.GitSVNFetch() |
233 commit_hash = self.GitLog(n=1, format="%H", grep=self["new_commit_msg"], | 233 commit_hash = self.GitLog(n=1, format="%H", grep=self["new_commit_msg"], |
234 branch="svn/%s" % self["merge_to_branch"]) | 234 branch="svn/%s" % self["merge_to_branch"]) |
235 if not commit_hash: | 235 if not commit_hash: # pragma: no cover |
236 self.Die("Unable to map git commit to svn revision.") | 236 self.Die("Unable to map git commit to svn revision.") |
237 self["svn_revision"] = self.GitSVNFindSVNRev(commit_hash) | 237 self["svn_revision"] = self.GitSVNFindSVNRev(commit_hash) |
238 print "subversion revision number is r%s" % self["svn_revision"] | 238 print "subversion revision number is r%s" % self["svn_revision"] |
239 | 239 |
240 | 240 |
241 class TagRevision(Step): | 241 class TagRevision(Step): |
242 MESSAGE = "Create the tag." | 242 MESSAGE = "Create the tag." |
243 | 243 |
244 def RunStep(self): | 244 def RunStep(self): |
245 if self._options.revert_bleeding_edge: | 245 if self._options.revert_bleeding_edge: |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 IncrementVersion, | 320 IncrementVersion, |
321 CommitLocal, | 321 CommitLocal, |
322 UploadStep, | 322 UploadStep, |
323 CommitRepository, | 323 CommitRepository, |
324 PrepareSVN, | 324 PrepareSVN, |
325 TagRevision, | 325 TagRevision, |
326 CleanUp, | 326 CleanUp, |
327 ] | 327 ] |
328 | 328 |
329 | 329 |
330 if __name__ == "__main__": | 330 if __name__ == "__main__": # pragma: no cover |
331 sys.exit(MergeToBranch(CONFIG).Run()) | 331 sys.exit(MergeToBranch(CONFIG).Run()) |
OLD | NEW |