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

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

Issue 607463002: Refactoring: Extract interface for VC in release scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review. 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
« no previous file with comments | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/push_to_trunk.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # 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 27 matching lines...) Expand all
38 def RunStep(self): 38 def RunStep(self):
39 if os.path.exists(self.Config("ALREADY_MERGING_SENTINEL_FILE")): 39 if os.path.exists(self.Config("ALREADY_MERGING_SENTINEL_FILE")):
40 if self._options.force: 40 if self._options.force:
41 os.remove(self.Config("ALREADY_MERGING_SENTINEL_FILE")) 41 os.remove(self.Config("ALREADY_MERGING_SENTINEL_FILE"))
42 elif self._options.step == 0: # pragma: no cover 42 elif self._options.step == 0: # pragma: no cover
43 self.Die("A merge is already in progress") 43 self.Die("A merge is already in progress")
44 open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close() 44 open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close()
45 45
46 self.InitialEnvironmentChecks(self.default_cwd) 46 self.InitialEnvironmentChecks(self.default_cwd)
47 if self._options.revert_bleeding_edge: 47 if self._options.revert_bleeding_edge:
48 # FIXME(machenbach): Make revert bleeding_edge obsolete?
48 self["merge_to_branch"] = "bleeding_edge" 49 self["merge_to_branch"] = "bleeding_edge"
49 elif self._options.branch: 50 elif self._options.branch:
50 self["merge_to_branch"] = self._options.branch 51 self["merge_to_branch"] = self._options.branch
51 else: # pragma: no cover 52 else: # pragma: no cover
52 self.Die("Please specify a branch to merge to") 53 self.Die("Please specify a branch to merge to")
53 54
54 self.CommonPrepare() 55 self.CommonPrepare()
55 self.PrepareBranch() 56 self.PrepareBranch()
56 57
57 58
58 class CreateBranch(Step): 59 class CreateBranch(Step):
59 MESSAGE = "Create a fresh branch for the patch." 60 MESSAGE = "Create a fresh branch for the patch."
60 61
61 def RunStep(self): 62 def RunStep(self):
62 self.GitCreateBranch(self.Config("BRANCHNAME"), 63 self.GitCreateBranch(self.Config("BRANCHNAME"),
63 "svn/%s" % self["merge_to_branch"]) 64 self.vc.RemoteBranch(self["merge_to_branch"]))
64 65
65 66
66 class SearchArchitecturePorts(Step): 67 class SearchArchitecturePorts(Step):
67 MESSAGE = "Search for corresponding architecture ports." 68 MESSAGE = "Search for corresponding architecture ports."
68 69
69 def RunStep(self): 70 def RunStep(self):
70 self["full_revision_list"] = list(OrderedDict.fromkeys( 71 self["full_revision_list"] = list(OrderedDict.fromkeys(
71 self._options.revisions)) 72 self._options.revisions))
72 port_revision_list = [] 73 port_revision_list = []
73 for revision in self["full_revision_list"]: 74 for revision in self["full_revision_list"]:
74 # Search for commits which matches the "Port rXXX" pattern. 75 # Search for commits which matches the "Port rXXX" pattern.
75 git_hashes = self.GitLog(reverse=True, format="%H", 76 git_hashes = self.GitLog(reverse=True, format="%H",
76 grep="Port r%d" % int(revision), 77 grep="Port r%d" % int(revision),
77 branch="svn/bleeding_edge") 78 branch=self.vc.RemoteMasterBranch())
78 for git_hash in git_hashes.splitlines(): 79 for git_hash in git_hashes.splitlines():
79 svn_revision = self.GitSVNFindSVNRev(git_hash, "svn/bleeding_edge") 80 svn_revision = self.vc.GitSvn(git_hash, self.vc.RemoteMasterBranch())
80 if not svn_revision: # pragma: no cover 81 if not svn_revision: # pragma: no cover
81 self.Die("Cannot determine svn revision for %s" % git_hash) 82 self.Die("Cannot determine svn revision for %s" % git_hash)
82 revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash) 83 revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash)
83 84
84 # Is this revision included in the original revision list? 85 # Is this revision included in the original revision list?
85 if svn_revision in self["full_revision_list"]: 86 if svn_revision in self["full_revision_list"]:
86 print("Found port of r%s -> r%s (already included): %s" 87 print("Found port of r%s -> r%s (already included): %s"
87 % (revision, svn_revision, revision_title)) 88 % (revision, svn_revision, revision_title))
88 else: 89 else:
89 print("Found port of r%s -> r%s: %s" 90 print("Found port of r%s -> r%s: %s"
90 % (revision, svn_revision, revision_title)) 91 % (revision, svn_revision, revision_title))
91 port_revision_list.append(svn_revision) 92 port_revision_list.append(svn_revision)
92 93
93 # Do we find any port? 94 # Do we find any port?
94 if len(port_revision_list) > 0: 95 if len(port_revision_list) > 0:
95 if self.Confirm("Automatically add corresponding ports (%s)?" 96 if self.Confirm("Automatically add corresponding ports (%s)?"
96 % ", ".join(port_revision_list)): 97 % ", ".join(port_revision_list)):
97 #: 'y': Add ports to revision list. 98 #: 'y': Add ports to revision list.
98 self["full_revision_list"].extend(port_revision_list) 99 self["full_revision_list"].extend(port_revision_list)
99 100
100 101
101 class FindGitRevisions(Step): 102 class FindGitRevisions(Step):
102 MESSAGE = "Find the git revisions associated with the patches." 103 MESSAGE = "Find the git revisions associated with the patches."
103 104
104 def RunStep(self): 105 def RunStep(self):
105 self["patch_commit_hashes"] = [] 106 self["patch_commit_hashes"] = []
106 for revision in self["full_revision_list"]: 107 for revision in self["full_revision_list"]:
107 next_hash = self.GitSVNFindGitHash(revision, "svn/bleeding_edge") 108 next_hash = self.vc.SvnGit(revision, self.vc.RemoteMasterBranch())
108 if not next_hash: # pragma: no cover 109 if not next_hash: # pragma: no cover
109 self.Die("Cannot determine git hash for r%s" % revision) 110 self.Die("Cannot determine git hash for r%s" % revision)
110 self["patch_commit_hashes"].append(next_hash) 111 self["patch_commit_hashes"].append(next_hash)
111 112
112 # Stringify: [123, 234] -> "r123, r234" 113 # Stringify: [123, 234] -> "r123, r234"
113 self["revision_list"] = ", ".join(map(lambda s: "r%s" % s, 114 self["revision_list"] = ", ".join(map(lambda s: "r%s" % s,
114 self["full_revision_list"])) 115 self["full_revision_list"]))
115 116
116 if not self["revision_list"]: # pragma: no cover 117 if not self["revision_list"]: # pragma: no cover
117 self.Die("Revision list is empty.") 118 self.Die("Revision list is empty.")
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 self.GitCommit(file_name=self.Config("COMMITMSG_FILE")) 203 self.GitCommit(file_name=self.Config("COMMITMSG_FILE"))
203 204
204 205
205 class CommitRepository(Step): 206 class CommitRepository(Step):
206 MESSAGE = "Commit to the repository." 207 MESSAGE = "Commit to the repository."
207 208
208 def RunStep(self): 209 def RunStep(self):
209 self.GitCheckout(self.Config("BRANCHNAME")) 210 self.GitCheckout(self.Config("BRANCHNAME"))
210 self.WaitForLGTM() 211 self.WaitForLGTM()
211 self.GitPresubmit() 212 self.GitPresubmit()
212 self.GitDCommit() 213 self.vc.CLLand()
213
214
215 class PrepareSVN(Step):
216 MESSAGE = "Determine svn commit revision."
217
218 def RunStep(self):
219 if self._options.revert_bleeding_edge:
220 return
221 self.GitSVNFetch()
222 commit_hash = self.GitLog(n=1, format="%H", grep=self["new_commit_msg"],
223 branch="svn/%s" % self["merge_to_branch"])
224 if not commit_hash: # pragma: no cover
225 self.Die("Unable to map git commit to svn revision.")
226 self["svn_revision"] = self.GitSVNFindSVNRev(commit_hash)
227 print "subversion revision number is r%s" % self["svn_revision"]
228 214
229 215
230 class TagRevision(Step): 216 class TagRevision(Step):
231 MESSAGE = "Create the tag." 217 MESSAGE = "Create the tag."
232 218
233 def RunStep(self): 219 def RunStep(self):
234 if self._options.revert_bleeding_edge: 220 if self._options.revert_bleeding_edge:
235 return 221 return
236 print "Creating tag svn/tags/%s" % self["version"] 222 print "Creating tag svn/tags/%s" % self["version"]
237 if self["merge_to_branch"] == "trunk": 223 self.vc.Tag(self["version"])
238 self["to_url"] = "trunk"
239 else:
240 self["to_url"] = "branches/%s" % self["merge_to_branch"]
241 self.SVN("copy -r %s https://v8.googlecode.com/svn/%s "
242 "https://v8.googlecode.com/svn/tags/%s -m "
243 "\"Tagging version %s\""
244 % (self["svn_revision"], self["to_url"],
245 self["version"], self["version"]))
246 224
247 225
248 class CleanUp(Step): 226 class CleanUp(Step):
249 MESSAGE = "Cleanup." 227 MESSAGE = "Cleanup."
250 228
251 def RunStep(self): 229 def RunStep(self):
252 self.CommonCleanup() 230 self.CommonCleanup()
253 if not self._options.revert_bleeding_edge: 231 if not self._options.revert_bleeding_edge:
254 print "*** SUMMARY ***" 232 print "*** SUMMARY ***"
255 print "version: %s" % self["version"] 233 print "version: %s" % self["version"]
256 print "branch: %s" % self["to_url"] 234 print "branch: %s" % self["merge_to_branch"]
257 print "svn revision: %s" % self["svn_revision"]
258 if self["revision_list"]: 235 if self["revision_list"]:
259 print "patches: %s" % self["revision_list"] 236 print "patches: %s" % self["revision_list"]
260 237
261 238
262 class MergeToBranch(ScriptsBase): 239 class MergeToBranch(ScriptsBase):
263 def _Description(self): 240 def _Description(self):
264 return ("Performs the necessary steps to merge revisions from " 241 return ("Performs the necessary steps to merge revisions from "
265 "bleeding_edge to other branches, including trunk.") 242 "bleeding_edge to other branches, including trunk.")
266 243
267 def _PrepareOptions(self, parser): 244 def _PrepareOptions(self, parser):
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 Preparation, 287 Preparation,
311 CreateBranch, 288 CreateBranch,
312 SearchArchitecturePorts, 289 SearchArchitecturePorts,
313 FindGitRevisions, 290 FindGitRevisions,
314 ApplyPatches, 291 ApplyPatches,
315 PrepareVersion, 292 PrepareVersion,
316 IncrementVersion, 293 IncrementVersion,
317 CommitLocal, 294 CommitLocal,
318 UploadStep, 295 UploadStep,
319 CommitRepository, 296 CommitRepository,
320 PrepareSVN,
321 TagRevision, 297 TagRevision,
322 CleanUp, 298 CleanUp,
323 ] 299 ]
324 300
325 301
326 if __name__ == "__main__": # pragma: no cover 302 if __name__ == "__main__": # pragma: no cover
327 sys.exit(MergeToBranch().Run()) 303 sys.exit(MergeToBranch().Run())
OLDNEW
« no previous file with comments | « tools/push-to-trunk/common_includes.py ('k') | tools/push-to-trunk/push_to_trunk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698