| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 VERSION_FILE: "src/version.cc", | 46 VERSION_FILE: "src/version.cc", |
| 47 CHANGELOG_FILE: "ChangeLog", | 47 CHANGELOG_FILE: "ChangeLog", |
| 48 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", | 48 CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", |
| 49 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", | 49 PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", |
| 50 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", | 50 COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", |
| 51 DEPS_FILE: "DEPS", | 51 DEPS_FILE: "DEPS", |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 class Preparation(Step): | 55 class Preparation(Step): |
| 56 def __init__(self): | 56 MESSAGE = "Preparation." |
| 57 Step.__init__(self, "Preparation.") | |
| 58 | 57 |
| 59 def RunStep(self): | 58 def RunStep(self): |
| 60 self.InitialEnvironmentChecks() | 59 self.InitialEnvironmentChecks() |
| 61 self.CommonPrepare() | 60 self.CommonPrepare() |
| 62 self.PrepareBranch() | 61 self.PrepareBranch() |
| 63 self.DeleteBranch(self.Config(TRUNKBRANCH)) | 62 self.DeleteBranch(self.Config(TRUNKBRANCH)) |
| 64 | 63 |
| 65 | 64 |
| 66 class FreshBranch(Step): | 65 class FreshBranch(Step): |
| 67 def __init__(self): | 66 MESSAGE = "Create a fresh branch." |
| 68 Step.__init__(self, "Create a fresh branch.") | |
| 69 | 67 |
| 70 def RunStep(self): | 68 def RunStep(self): |
| 71 args = "checkout -b %s svn/bleeding_edge" % self.Config(BRANCHNAME) | 69 args = "checkout -b %s svn/bleeding_edge" % self.Config(BRANCHNAME) |
| 72 if self.Git(args) is None: | 70 if self.Git(args) is None: |
| 73 self.Die("Creating branch %s failed." % self.Config(BRANCHNAME)) | 71 self.Die("Creating branch %s failed." % self.Config(BRANCHNAME)) |
| 74 | 72 |
| 75 | 73 |
| 76 class DetectLastPush(Step): | 74 class DetectLastPush(Step): |
| 77 def __init__(self): | 75 MESSAGE = "Detect commit ID of last push to trunk." |
| 78 Step.__init__(self, "Detect commit ID of last push to trunk.") | |
| 79 | 76 |
| 80 def RunStep(self): | 77 def RunStep(self): |
| 81 last_push = (self._options.l or | 78 last_push = (self._options.l or |
| 82 self.Git("log -1 --format=%H ChangeLog").strip()) | 79 self.Git("log -1 --format=%H ChangeLog").strip()) |
| 83 while True: | 80 while True: |
| 84 # Print assumed commit, circumventing git's pager. | 81 # Print assumed commit, circumventing git's pager. |
| 85 print self.Git("log -1 %s" % last_push) | 82 print self.Git("log -1 %s" % last_push) |
| 86 if self.Confirm("Is the commit printed above the last push to trunk?"): | 83 if self.Confirm("Is the commit printed above the last push to trunk?"): |
| 87 break | 84 break |
| 88 args = "log -1 --format=%H %s^ ChangeLog" % last_push | 85 args = "log -1 --format=%H %s^ ChangeLog" % last_push |
| 89 last_push = self.Git(args).strip() | 86 last_push = self.Git(args).strip() |
| 90 self.Persist("last_push", last_push) | 87 self.Persist("last_push", last_push) |
| 91 self._state["last_push"] = last_push | 88 self._state["last_push"] = last_push |
| 92 | 89 |
| 93 | 90 |
| 94 class PrepareChangeLog(Step): | 91 class PrepareChangeLog(Step): |
| 95 def __init__(self): | 92 MESSAGE = "Prepare raw ChangeLog entry." |
| 96 Step.__init__(self, "Prepare raw ChangeLog entry.") | |
| 97 | 93 |
| 98 def RunStep(self): | 94 def RunStep(self): |
| 99 self.RestoreIfUnset("last_push") | 95 self.RestoreIfUnset("last_push") |
| 100 | 96 |
| 101 # These version numbers are used again later for the trunk commit. | 97 # These version numbers are used again later for the trunk commit. |
| 102 self.ReadAndPersistVersion() | 98 self.ReadAndPersistVersion() |
| 103 | 99 |
| 104 date = datetime.date.today().strftime("%Y-%m-%d") | 100 date = datetime.date.today().strftime("%Y-%m-%d") |
| 105 self.Persist("date", date) | 101 self.Persist("date", date) |
| 106 output = "%s: Version %s.%s.%s\n\n" % (date, | 102 output = "%s: Version %s.%s.%s\n\n" % (date, |
| 107 self._state["major"], | 103 self._state["major"], |
| 108 self._state["minor"], | 104 self._state["minor"], |
| 109 self._state["build"]) | 105 self._state["build"]) |
| 110 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) | 106 TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) |
| 111 | 107 |
| 112 args = "log %s..HEAD --format=%%H" % self._state["last_push"] | 108 args = "log %s..HEAD --format=%%H" % self._state["last_push"] |
| 113 commits = self.Git(args).strip() | 109 commits = self.Git(args).strip() |
| 114 | 110 |
| 115 # Cache raw commit messages. | 111 # Cache raw commit messages. |
| 116 commit_messages = [ | 112 commit_messages = [ |
| 117 [ | 113 [ |
| 118 self.Git("log -1 %s --format=\"%%w(80,8,8)%%s\"" % commit), | 114 self.Git("log -1 %s --format=\"%%s\"" % commit), |
| 119 self.Git("log -1 %s --format=\"%%B\"" % commit), | 115 self.Git("log -1 %s --format=\"%%B\"" % commit), |
| 120 self.Git("log -1 %s --format=\"%%w(80,8,8)(%%an)\"" % commit), | 116 self.Git("log -1 %s --format=\"%%an\"" % commit), |
| 121 ] for commit in commits.splitlines() | 117 ] for commit in commits.splitlines() |
| 122 ] | 118 ] |
| 123 | 119 |
| 124 # Auto-format commit messages. | 120 # Auto-format commit messages. |
| 125 body = MakeChangeLogBody(commit_messages, auto_format=True) | 121 body = MakeChangeLogBody(commit_messages, auto_format=True) |
| 126 AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) | 122 AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) |
| 127 | 123 |
| 128 msg = (" Performance and stability improvements on all platforms." | 124 msg = (" Performance and stability improvements on all platforms." |
| 129 "\n#\n# The change log above is auto-generated. Please review if " | 125 "\n#\n# The change log above is auto-generated. Please review if " |
| 130 "all relevant\n# commit messages from the list below are included." | 126 "all relevant\n# commit messages from the list below are included." |
| 131 "\n# All lines starting with # will be stripped.\n#\n") | 127 "\n# All lines starting with # will be stripped.\n#\n") |
| 132 AppendToFile(msg, self.Config(CHANGELOG_ENTRY_FILE)) | 128 AppendToFile(msg, self.Config(CHANGELOG_ENTRY_FILE)) |
| 133 | 129 |
| 134 # Include unformatted commit messages as a reference in a comment. | 130 # Include unformatted commit messages as a reference in a comment. |
| 135 comment_body = MakeComment(MakeChangeLogBody(commit_messages)) | 131 comment_body = MakeComment(MakeChangeLogBody(commit_messages)) |
| 136 AppendToFile(comment_body, self.Config(CHANGELOG_ENTRY_FILE)) | 132 AppendToFile(comment_body, self.Config(CHANGELOG_ENTRY_FILE)) |
| 137 | 133 |
| 138 | 134 |
| 139 class EditChangeLog(Step): | 135 class EditChangeLog(Step): |
| 140 def __init__(self): | 136 MESSAGE = "Edit ChangeLog entry." |
| 141 Step.__init__(self, "Edit ChangeLog entry.") | |
| 142 | 137 |
| 143 def RunStep(self): | 138 def RunStep(self): |
| 144 print ("Please press <Return> to have your EDITOR open the ChangeLog " | 139 print ("Please press <Return> to have your EDITOR open the ChangeLog " |
| 145 "entry, then edit its contents to your liking. When you're done, " | 140 "entry, then edit its contents to your liking. When you're done, " |
| 146 "save the file and exit your EDITOR. ") | 141 "save the file and exit your EDITOR. ") |
| 147 self.ReadLine(default="") | 142 self.ReadLine(default="") |
| 148 | 143 |
| 149 # TODO(machenbach): Don't use EDITOR in forced mode as soon as script is | 144 # TODO(machenbach): Don't use EDITOR in forced mode as soon as script is |
| 150 # well tested. | 145 # well tested. |
| 151 self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) | 146 self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) |
| 152 handle, new_changelog = tempfile.mkstemp() | 147 handle, new_changelog = tempfile.mkstemp() |
| 153 os.close(handle) | 148 os.close(handle) |
| 154 | 149 |
| 155 # (1) Strip comments, (2) eliminate tabs, (3) fix too little and (4) too | 150 # Strip comments and reformat with correct indentation. |
| 156 # much indentation, and (5) eliminate trailing whitespace. | |
| 157 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() | 151 changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() |
| 158 changelog_entry = StripComments(changelog_entry) | 152 changelog_entry = StripComments(changelog_entry) |
| 159 changelog_entry = MSub(r"\t", r" ", changelog_entry) | 153 changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) |
| 160 changelog_entry = MSub(r"^ {1,7}([^ ])", r" \1", changelog_entry) | |
| 161 changelog_entry = MSub(r"^ {9,80}([^ ])", r" \1", changelog_entry) | |
| 162 changelog_entry = MSub(r" +$", r"", changelog_entry) | |
| 163 | 154 |
| 164 if changelog_entry == "": | 155 if changelog_entry == "": |
| 165 self.Die("Empty ChangeLog entry.") | 156 self.Die("Empty ChangeLog entry.") |
| 166 | 157 |
| 167 with open(new_changelog, "w") as f: | 158 with open(new_changelog, "w") as f: |
| 168 f.write(changelog_entry) | 159 f.write(changelog_entry) |
| 169 f.write("\n\n\n") # Explicitly insert two empty lines. | 160 f.write("\n\n\n") # Explicitly insert two empty lines. |
| 170 | 161 |
| 171 AppendToFile(FileToText(self.Config(CHANGELOG_FILE)), new_changelog) | 162 AppendToFile(FileToText(self.Config(CHANGELOG_FILE)), new_changelog) |
| 172 TextToFile(FileToText(new_changelog), self.Config(CHANGELOG_FILE)) | 163 TextToFile(FileToText(new_changelog), self.Config(CHANGELOG_FILE)) |
| 173 os.remove(new_changelog) | 164 os.remove(new_changelog) |
| 174 | 165 |
| 175 | 166 |
| 176 class IncrementVersion(Step): | 167 class IncrementVersion(Step): |
| 177 def __init__(self): | 168 MESSAGE = "Increment version number." |
| 178 Step.__init__(self, "Increment version number.") | |
| 179 | 169 |
| 180 def RunStep(self): | 170 def RunStep(self): |
| 181 self.RestoreIfUnset("build") | 171 self.RestoreIfUnset("build") |
| 182 new_build = str(int(self._state["build"]) + 1) | 172 new_build = str(int(self._state["build"]) + 1) |
| 183 | 173 |
| 184 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " | 174 if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will " |
| 185 "fire up your EDITOR on %s so you can make arbitrary " | 175 "fire up your EDITOR on %s so you can make arbitrary " |
| 186 "changes. When you're done, save the file and exit your " | 176 "changes. When you're done, save the file and exit your " |
| 187 "EDITOR.)" % self.Config(VERSION_FILE))): | 177 "EDITOR.)" % self.Config(VERSION_FILE))): |
| 188 text = FileToText(self.Config(VERSION_FILE)) | 178 text = FileToText(self.Config(VERSION_FILE)) |
| 189 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | 179 text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 190 r"\g<space>%s" % new_build, | 180 r"\g<space>%s" % new_build, |
| 191 text) | 181 text) |
| 192 TextToFile(text, self.Config(VERSION_FILE)) | 182 TextToFile(text, self.Config(VERSION_FILE)) |
| 193 else: | 183 else: |
| 194 self.Editor(self.Config(VERSION_FILE)) | 184 self.Editor(self.Config(VERSION_FILE)) |
| 195 | 185 |
| 196 self.ReadAndPersistVersion("new_") | 186 self.ReadAndPersistVersion("new_") |
| 197 | 187 |
| 198 | 188 |
| 199 class CommitLocal(Step): | 189 class CommitLocal(Step): |
| 200 def __init__(self): | 190 MESSAGE = "Commit to local branch." |
| 201 Step.__init__(self, "Commit to local branch.") | |
| 202 | 191 |
| 203 def RunStep(self): | 192 def RunStep(self): |
| 204 self.RestoreVersionIfUnset("new_") | 193 self.RestoreVersionIfUnset("new_") |
| 205 prep_commit_msg = ("Prepare push to trunk. " | 194 prep_commit_msg = ("Prepare push to trunk. " |
| 206 "Now working on version %s.%s.%s." % (self._state["new_major"], | 195 "Now working on version %s.%s.%s." % (self._state["new_major"], |
| 207 self._state["new_minor"], | 196 self._state["new_minor"], |
| 208 self._state["new_build"])) | 197 self._state["new_build"])) |
| 209 self.Persist("prep_commit_msg", prep_commit_msg) | 198 self.Persist("prep_commit_msg", prep_commit_msg) |
| 210 if self.Git("commit -a -m \"%s\"" % prep_commit_msg) is None: | 199 if self.Git("commit -a -m \"%s\"" % prep_commit_msg) is None: |
| 211 self.Die("'git commit -a' failed.") | 200 self.Die("'git commit -a' failed.") |
| 212 | 201 |
| 213 | 202 |
| 214 class CommitRepository(Step): | 203 class CommitRepository(Step): |
| 215 def __init__(self): | 204 MESSAGE = "Commit to the repository." |
| 216 Step.__init__(self, "Commit to the repository.") | |
| 217 | 205 |
| 218 def RunStep(self): | 206 def RunStep(self): |
| 219 self.WaitForLGTM() | 207 self.WaitForLGTM() |
| 220 # Re-read the ChangeLog entry (to pick up possible changes). | 208 # Re-read the ChangeLog entry (to pick up possible changes). |
| 221 # FIXME(machenbach): This was hanging once with a broken pipe. | 209 # FIXME(machenbach): This was hanging once with a broken pipe. |
| 222 TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)), | 210 TextToFile(GetLastChangeLogEntries(self.Config(CHANGELOG_FILE)), |
| 223 self.Config(CHANGELOG_ENTRY_FILE)) | 211 self.Config(CHANGELOG_ENTRY_FILE)) |
| 224 | 212 |
| 225 if self.Git("cl dcommit -f", "PRESUBMIT_TREE_CHECK=\"skip\"") is None: | 213 if self.Git("cl dcommit -f", "PRESUBMIT_TREE_CHECK=\"skip\"") is None: |
| 226 self.Die("'git cl dcommit' failed, please try again.") | 214 self.Die("'git cl dcommit' failed, please try again.") |
| 227 | 215 |
| 228 | 216 |
| 229 class StragglerCommits(Step): | 217 class StragglerCommits(Step): |
| 230 def __init__(self): | 218 MESSAGE = ("Fetch straggler commits that sneaked in since this script was " |
| 231 Step.__init__(self, "Fetch straggler commits that sneaked in since this " | 219 "started.") |
| 232 "script was started.") | |
| 233 | 220 |
| 234 def RunStep(self): | 221 def RunStep(self): |
| 235 if self.Git("svn fetch") is None: | 222 if self.Git("svn fetch") is None: |
| 236 self.Die("'git svn fetch' failed.") | 223 self.Die("'git svn fetch' failed.") |
| 237 self.Git("checkout svn/bleeding_edge") | 224 self.Git("checkout svn/bleeding_edge") |
| 238 self.RestoreIfUnset("prep_commit_msg") | 225 self.RestoreIfUnset("prep_commit_msg") |
| 239 args = "log -1 --format=%%H --grep=\"%s\"" % self._state["prep_commit_msg"] | 226 args = "log -1 --format=%%H --grep=\"%s\"" % self._state["prep_commit_msg"] |
| 240 prepare_commit_hash = self.Git(args).strip() | 227 prepare_commit_hash = self.Git(args).strip() |
| 241 self.Persist("prepare_commit_hash", prepare_commit_hash) | 228 self.Persist("prepare_commit_hash", prepare_commit_hash) |
| 242 | 229 |
| 243 | 230 |
| 244 class SquashCommits(Step): | 231 class SquashCommits(Step): |
| 245 def __init__(self): | 232 MESSAGE = "Squash commits into one." |
| 246 Step.__init__(self, "Squash commits into one.") | |
| 247 | 233 |
| 248 def RunStep(self): | 234 def RunStep(self): |
| 249 # Instead of relying on "git rebase -i", we'll just create a diff, because | 235 # Instead of relying on "git rebase -i", we'll just create a diff, because |
| 250 # that's easier to automate. | 236 # that's easier to automate. |
| 251 self.RestoreIfUnset("prepare_commit_hash") | 237 self.RestoreIfUnset("prepare_commit_hash") |
| 252 args = "diff svn/trunk %s" % self._state["prepare_commit_hash"] | 238 args = "diff svn/trunk %s" % self._state["prepare_commit_hash"] |
| 253 TextToFile(self.Git(args), self.Config(PATCH_FILE)) | 239 TextToFile(self.Git(args), self.Config(PATCH_FILE)) |
| 254 | 240 |
| 255 # Convert the ChangeLog entry to commit message format: | 241 # Convert the ChangeLog entry to commit message format: |
| 256 # - remove date | 242 # - remove date |
| (...skipping 21 matching lines...) Expand all Loading... |
| 278 }\ | 264 }\ |
| 279 }'" % (changelog_entry, self._state["date"])) | 265 }'" % (changelog_entry, self._state["date"])) |
| 280 | 266 |
| 281 if not text: | 267 if not text: |
| 282 self.Die("Commit message editing failed.") | 268 self.Die("Commit message editing failed.") |
| 283 TextToFile(text, self.Config(COMMITMSG_FILE)) | 269 TextToFile(text, self.Config(COMMITMSG_FILE)) |
| 284 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) | 270 os.remove(self.Config(CHANGELOG_ENTRY_FILE)) |
| 285 | 271 |
| 286 | 272 |
| 287 class NewBranch(Step): | 273 class NewBranch(Step): |
| 288 def __init__(self): | 274 MESSAGE = "Create a new branch from trunk." |
| 289 Step.__init__(self, "Create a new branch from trunk.") | |
| 290 | 275 |
| 291 def RunStep(self): | 276 def RunStep(self): |
| 292 if self.Git("checkout -b %s svn/trunk" % self.Config(TRUNKBRANCH)) is None: | 277 if self.Git("checkout -b %s svn/trunk" % self.Config(TRUNKBRANCH)) is None: |
| 293 self.Die("Checking out a new branch '%s' failed." % | 278 self.Die("Checking out a new branch '%s' failed." % |
| 294 self.Config(TRUNKBRANCH)) | 279 self.Config(TRUNKBRANCH)) |
| 295 | 280 |
| 296 | 281 |
| 297 class ApplyChanges(Step): | 282 class ApplyChanges(Step): |
| 298 def __init__(self): | 283 MESSAGE = "Apply squashed changes." |
| 299 Step.__init__(self, "Apply squashed changes.") | |
| 300 | 284 |
| 301 def RunStep(self): | 285 def RunStep(self): |
| 302 self.ApplyPatch(self.Config(PATCH_FILE)) | 286 self.ApplyPatch(self.Config(PATCH_FILE)) |
| 303 Command("rm", "-f %s*" % self.Config(PATCH_FILE)) | 287 Command("rm", "-f %s*" % self.Config(PATCH_FILE)) |
| 304 | 288 |
| 305 | 289 |
| 306 class SetVersion(Step): | 290 class SetVersion(Step): |
| 307 def __init__(self): | 291 MESSAGE = "Set correct version for trunk." |
| 308 Step.__init__(self, "Set correct version for trunk.") | |
| 309 | 292 |
| 310 def RunStep(self): | 293 def RunStep(self): |
| 311 self.RestoreVersionIfUnset() | 294 self.RestoreVersionIfUnset() |
| 312 output = "" | 295 output = "" |
| 313 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): | 296 for line in FileToText(self.Config(VERSION_FILE)).splitlines(): |
| 314 if line.startswith("#define MAJOR_VERSION"): | 297 if line.startswith("#define MAJOR_VERSION"): |
| 315 line = re.sub("\d+$", self._state["major"], line) | 298 line = re.sub("\d+$", self._state["major"], line) |
| 316 elif line.startswith("#define MINOR_VERSION"): | 299 elif line.startswith("#define MINOR_VERSION"): |
| 317 line = re.sub("\d+$", self._state["minor"], line) | 300 line = re.sub("\d+$", self._state["minor"], line) |
| 318 elif line.startswith("#define BUILD_NUMBER"): | 301 elif line.startswith("#define BUILD_NUMBER"): |
| 319 line = re.sub("\d+$", self._state["build"], line) | 302 line = re.sub("\d+$", self._state["build"], line) |
| 320 elif line.startswith("#define PATCH_LEVEL"): | 303 elif line.startswith("#define PATCH_LEVEL"): |
| 321 line = re.sub("\d+$", "0", line) | 304 line = re.sub("\d+$", "0", line) |
| 322 elif line.startswith("#define IS_CANDIDATE_VERSION"): | 305 elif line.startswith("#define IS_CANDIDATE_VERSION"): |
| 323 line = re.sub("\d+$", "0", line) | 306 line = re.sub("\d+$", "0", line) |
| 324 output += "%s\n" % line | 307 output += "%s\n" % line |
| 325 TextToFile(output, self.Config(VERSION_FILE)) | 308 TextToFile(output, self.Config(VERSION_FILE)) |
| 326 | 309 |
| 327 | 310 |
| 328 class CommitTrunk(Step): | 311 class CommitTrunk(Step): |
| 329 def __init__(self): | 312 MESSAGE = "Commit to local trunk branch." |
| 330 Step.__init__(self, "Commit to local trunk branch.") | |
| 331 | 313 |
| 332 def RunStep(self): | 314 def RunStep(self): |
| 333 self.Git("add \"%s\"" % self.Config(VERSION_FILE)) | 315 self.Git("add \"%s\"" % self.Config(VERSION_FILE)) |
| 334 if self.Git("commit -F \"%s\"" % self.Config(COMMITMSG_FILE)) is None: | 316 if self.Git("commit -F \"%s\"" % self.Config(COMMITMSG_FILE)) is None: |
| 335 self.Die("'git commit' failed.") | 317 self.Die("'git commit' failed.") |
| 336 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE)) | 318 Command("rm", "-f %s*" % self.Config(COMMITMSG_FILE)) |
| 337 | 319 |
| 338 | 320 |
| 339 class SanityCheck(Step): | 321 class SanityCheck(Step): |
| 340 def __init__(self): | 322 MESSAGE = "Sanity check." |
| 341 Step.__init__(self, "Sanity check.") | |
| 342 | 323 |
| 343 def RunStep(self): | 324 def RunStep(self): |
| 344 if not self.Confirm("Please check if your local checkout is sane: Inspect " | 325 if not self.Confirm("Please check if your local checkout is sane: Inspect " |
| 345 "%s, compile, run tests. Do you want to commit this new trunk " | 326 "%s, compile, run tests. Do you want to commit this new trunk " |
| 346 "revision to the repository?" % self.Config(VERSION_FILE)): | 327 "revision to the repository?" % self.Config(VERSION_FILE)): |
| 347 self.Die("Execution canceled.") | 328 self.Die("Execution canceled.") |
| 348 | 329 |
| 349 | 330 |
| 350 class CommitSVN(Step): | 331 class CommitSVN(Step): |
| 351 def __init__(self): | 332 MESSAGE = "Commit to SVN." |
| 352 Step.__init__(self, "Commit to SVN.") | |
| 353 | 333 |
| 354 def RunStep(self): | 334 def RunStep(self): |
| 355 result = self.Git("svn dcommit 2>&1") | 335 result = self.Git("svn dcommit 2>&1") |
| 356 if not result: | 336 if not result: |
| 357 self.Die("'git svn dcommit' failed.") | 337 self.Die("'git svn dcommit' failed.") |
| 358 result = filter(lambda x: re.search(r"^Committed r[0-9]+", x), | 338 result = filter(lambda x: re.search(r"^Committed r[0-9]+", x), |
| 359 result.splitlines()) | 339 result.splitlines()) |
| 360 if len(result) > 0: | 340 if len(result) > 0: |
| 361 trunk_revision = re.sub(r"^Committed r([0-9]+)", r"\1", result[0]) | 341 trunk_revision = re.sub(r"^Committed r([0-9]+)", r"\1", result[0]) |
| 362 | 342 |
| 363 # Sometimes grepping for the revision fails. No idea why. If you figure | 343 # Sometimes grepping for the revision fails. No idea why. If you figure |
| 364 # out why it is flaky, please do fix it properly. | 344 # out why it is flaky, please do fix it properly. |
| 365 if not trunk_revision: | 345 if not trunk_revision: |
| 366 print("Sorry, grepping for the SVN revision failed. Please look for it " | 346 print("Sorry, grepping for the SVN revision failed. Please look for it " |
| 367 "in the last command's output above and provide it manually (just " | 347 "in the last command's output above and provide it manually (just " |
| 368 "the number, without the leading \"r\").") | 348 "the number, without the leading \"r\").") |
| 369 self.DieInForcedMode("Can't prompt in forced mode.") | 349 self.DieInForcedMode("Can't prompt in forced mode.") |
| 370 while not trunk_revision: | 350 while not trunk_revision: |
| 371 print "> ", | 351 print "> ", |
| 372 trunk_revision = self.ReadLine() | 352 trunk_revision = self.ReadLine() |
| 373 self.Persist("trunk_revision", trunk_revision) | 353 self.Persist("trunk_revision", trunk_revision) |
| 374 | 354 |
| 375 | 355 |
| 376 class TagRevision(Step): | 356 class TagRevision(Step): |
| 377 def __init__(self): | 357 MESSAGE = "Tag the new revision." |
| 378 Step.__init__(self, "Tag the new revision.") | |
| 379 | 358 |
| 380 def RunStep(self): | 359 def RunStep(self): |
| 381 self.RestoreVersionIfUnset() | 360 self.RestoreVersionIfUnset() |
| 382 ver = "%s.%s.%s" % (self._state["major"], | 361 ver = "%s.%s.%s" % (self._state["major"], |
| 383 self._state["minor"], | 362 self._state["minor"], |
| 384 self._state["build"]) | 363 self._state["build"]) |
| 385 if self.Git("svn tag %s -m \"Tagging version %s\"" % (ver, ver)) is None: | 364 if self.Git("svn tag %s -m \"Tagging version %s\"" % (ver, ver)) is None: |
| 386 self.Die("'git svn tag' failed.") | 365 self.Die("'git svn tag' failed.") |
| 387 | 366 |
| 388 | 367 |
| 389 class CheckChromium(Step): | 368 class CheckChromium(Step): |
| 390 def __init__(self): | 369 MESSAGE = "Ask for chromium checkout." |
| 391 Step.__init__(self, "Ask for chromium checkout.") | |
| 392 | 370 |
| 393 def Run(self): | 371 def Run(self): |
| 394 chrome_path = self._options.c | 372 chrome_path = self._options.c |
| 395 if not chrome_path: | 373 if not chrome_path: |
| 396 self.DieInForcedMode("Please specify the path to a Chromium checkout in " | 374 self.DieInForcedMode("Please specify the path to a Chromium checkout in " |
| 397 "forced mode.") | 375 "forced mode.") |
| 398 print ("Do you have a \"NewGit\" Chromium checkout and want " | 376 print ("Do you have a \"NewGit\" Chromium checkout and want " |
| 399 "this script to automate creation of the roll CL? If yes, enter the " | 377 "this script to automate creation of the roll CL? If yes, enter the " |
| 400 "path to (and including) the \"src\" directory here, otherwise just " | 378 "path to (and including) the \"src\" directory here, otherwise just " |
| 401 "press <Return>: "), | 379 "press <Return>: "), |
| 402 chrome_path = self.ReadLine() | 380 chrome_path = self.ReadLine() |
| 403 self.Persist("chrome_path", chrome_path) | 381 self.Persist("chrome_path", chrome_path) |
| 404 | 382 |
| 405 | 383 |
| 406 class SwitchChromium(Step): | 384 class SwitchChromium(Step): |
| 407 def __init__(self): | 385 MESSAGE = "Switch to Chromium checkout." |
| 408 Step.__init__(self, "Switch to Chromium checkout.", requires="chrome_path") | 386 REQUIRES = "chrome_path" |
| 409 | 387 |
| 410 def RunStep(self): | 388 def RunStep(self): |
| 411 v8_path = os.getcwd() | 389 v8_path = os.getcwd() |
| 412 self.Persist("v8_path", v8_path) | 390 self.Persist("v8_path", v8_path) |
| 413 os.chdir(self._state["chrome_path"]) | 391 os.chdir(self._state["chrome_path"]) |
| 414 self.InitialEnvironmentChecks() | 392 self.InitialEnvironmentChecks() |
| 415 # Check for a clean workdir. | 393 # Check for a clean workdir. |
| 416 if self.Git("status -s -uno").strip() != "": | 394 if self.Git("status -s -uno").strip() != "": |
| 417 self.Die("Workspace is not clean. Please commit or undo your changes.") | 395 self.Die("Workspace is not clean. Please commit or undo your changes.") |
| 418 # Assert that the DEPS file is there. | 396 # Assert that the DEPS file is there. |
| 419 if not os.path.exists(self.Config(DEPS_FILE)): | 397 if not os.path.exists(self.Config(DEPS_FILE)): |
| 420 self.Die("DEPS file not present.") | 398 self.Die("DEPS file not present.") |
| 421 | 399 |
| 422 | 400 |
| 423 class UpdateChromiumCheckout(Step): | 401 class UpdateChromiumCheckout(Step): |
| 424 def __init__(self): | 402 MESSAGE = "Update the checkout and create a new branch." |
| 425 Step.__init__(self, "Update the checkout and create a new branch.", | 403 REQUIRES = "chrome_path" |
| 426 requires="chrome_path") | |
| 427 | 404 |
| 428 def RunStep(self): | 405 def RunStep(self): |
| 429 os.chdir(self._state["chrome_path"]) | 406 os.chdir(self._state["chrome_path"]) |
| 430 if self.Git("checkout master") is None: | 407 if self.Git("checkout master") is None: |
| 431 self.Die("'git checkout master' failed.") | 408 self.Die("'git checkout master' failed.") |
| 432 if self.Git("pull") is None: | 409 if self.Git("pull") is None: |
| 433 self.Die("'git pull' failed, please try again.") | 410 self.Die("'git pull' failed, please try again.") |
| 434 | 411 |
| 435 self.RestoreIfUnset("trunk_revision") | 412 self.RestoreIfUnset("trunk_revision") |
| 436 args = "checkout -b v8-roll-%s" % self._state["trunk_revision"] | 413 args = "checkout -b v8-roll-%s" % self._state["trunk_revision"] |
| 437 if self.Git(args) is None: | 414 if self.Git(args) is None: |
| 438 self.Die("Failed to checkout a new branch.") | 415 self.Die("Failed to checkout a new branch.") |
| 439 | 416 |
| 440 | 417 |
| 441 class UploadCL(Step): | 418 class UploadCL(Step): |
| 442 def __init__(self): | 419 MESSAGE = "Create and upload CL." |
| 443 Step.__init__(self, "Create and upload CL.", requires="chrome_path") | 420 REQUIRES = "chrome_path" |
| 444 | 421 |
| 445 def RunStep(self): | 422 def RunStep(self): |
| 446 os.chdir(self._state["chrome_path"]) | 423 os.chdir(self._state["chrome_path"]) |
| 447 | 424 |
| 448 # Patch DEPS file. | 425 # Patch DEPS file. |
| 449 self.RestoreIfUnset("trunk_revision") | 426 self.RestoreIfUnset("trunk_revision") |
| 450 deps = FileToText(self.Config(DEPS_FILE)) | 427 deps = FileToText(self.Config(DEPS_FILE)) |
| 451 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", | 428 deps = re.sub("(?<=\"v8_revision\": \")([0-9]+)(?=\")", |
| 452 self._state["trunk_revision"], | 429 self._state["trunk_revision"], |
| 453 deps) | 430 deps) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 467 args = "commit -am \"Update V8 to version %s.\n\nTBR=%s\"" % (ver, rev) | 444 args = "commit -am \"Update V8 to version %s.\n\nTBR=%s\"" % (ver, rev) |
| 468 if self.Git(args) is None: | 445 if self.Git(args) is None: |
| 469 self.Die("'git commit' failed.") | 446 self.Die("'git commit' failed.") |
| 470 force_flag = " -f" if self._options.f else "" | 447 force_flag = " -f" if self._options.f else "" |
| 471 if self.Git("cl upload --send-mail%s" % force_flag, pipe=False) is None: | 448 if self.Git("cl upload --send-mail%s" % force_flag, pipe=False) is None: |
| 472 self.Die("'git cl upload' failed, please try again.") | 449 self.Die("'git cl upload' failed, please try again.") |
| 473 print "CL uploaded." | 450 print "CL uploaded." |
| 474 | 451 |
| 475 | 452 |
| 476 class SwitchV8(Step): | 453 class SwitchV8(Step): |
| 477 def __init__(self): | 454 MESSAGE = "Returning to V8 checkout." |
| 478 Step.__init__(self, "Returning to V8 checkout.", requires="chrome_path") | 455 REQUIRES = "chrome_path" |
| 479 | 456 |
| 480 def RunStep(self): | 457 def RunStep(self): |
| 481 self.RestoreIfUnset("v8_path") | 458 self.RestoreIfUnset("v8_path") |
| 482 os.chdir(self._state["v8_path"]) | 459 os.chdir(self._state["v8_path"]) |
| 483 | 460 |
| 484 | 461 |
| 485 class CleanUp(Step): | 462 class CleanUp(Step): |
| 486 def __init__(self): | 463 MESSAGE = "Done!" |
| 487 Step.__init__(self, "Done!") | |
| 488 | 464 |
| 489 def RunStep(self): | 465 def RunStep(self): |
| 490 self.RestoreVersionIfUnset() | 466 self.RestoreVersionIfUnset() |
| 491 ver = "%s.%s.%s" % (self._state["major"], | 467 ver = "%s.%s.%s" % (self._state["major"], |
| 492 self._state["minor"], | 468 self._state["minor"], |
| 493 self._state["build"]) | 469 self._state["build"]) |
| 494 self.RestoreIfUnset("trunk_revision") | 470 self.RestoreIfUnset("trunk_revision") |
| 495 self.RestoreIfUnset("chrome_path") | 471 self.RestoreIfUnset("chrome_path") |
| 496 | 472 |
| 497 if self._state["chrome_path"]: | 473 if self._state["chrome_path"]: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 def Main(): | 547 def Main(): |
| 572 parser = BuildOptions() | 548 parser = BuildOptions() |
| 573 (options, args) = parser.parse_args() | 549 (options, args) = parser.parse_args() |
| 574 if not ProcessOptions(options): | 550 if not ProcessOptions(options): |
| 575 parser.print_help() | 551 parser.print_help() |
| 576 return 1 | 552 return 1 |
| 577 RunPushToTrunk(CONFIG, options) | 553 RunPushToTrunk(CONFIG, options) |
| 578 | 554 |
| 579 if __name__ == "__main__": | 555 if __name__ == "__main__": |
| 580 sys.exit(Main()) | 556 sys.exit(Main()) |
| OLD | NEW |