| 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 24 matching lines...) Expand all Loading... |
| 35 import subprocess | 35 import subprocess |
| 36 import sys | 36 import sys |
| 37 import textwrap | 37 import textwrap |
| 38 import time | 38 import time |
| 39 import urllib2 | 39 import urllib2 |
| 40 | 40 |
| 41 from git_recipes import GitRecipesMixin | 41 from git_recipes import GitRecipesMixin |
| 42 from git_recipes import GitFailedException | 42 from git_recipes import GitFailedException |
| 43 | 43 |
| 44 PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME" | 44 PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME" |
| 45 TEMP_BRANCH = "TEMP_BRANCH" | |
| 46 BRANCHNAME = "BRANCHNAME" | 45 BRANCHNAME = "BRANCHNAME" |
| 47 DOT_GIT_LOCATION = "DOT_GIT_LOCATION" | 46 DOT_GIT_LOCATION = "DOT_GIT_LOCATION" |
| 48 VERSION_FILE = "VERSION_FILE" | 47 VERSION_FILE = "VERSION_FILE" |
| 49 CHANGELOG_FILE = "CHANGELOG_FILE" | 48 CHANGELOG_FILE = "CHANGELOG_FILE" |
| 50 CHANGELOG_ENTRY_FILE = "CHANGELOG_ENTRY_FILE" | 49 CHANGELOG_ENTRY_FILE = "CHANGELOG_ENTRY_FILE" |
| 51 COMMITMSG_FILE = "COMMITMSG_FILE" | 50 COMMITMSG_FILE = "COMMITMSG_FILE" |
| 52 PATCH_FILE = "PATCH_FILE" | 51 PATCH_FILE = "PATCH_FILE" |
| 53 | 52 |
| 54 | 53 |
| 55 def TextToFile(text, file_name): | 54 def TextToFile(text, file_name): |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 else: | 168 else: |
| 170 return "" | 169 return "" |
| 171 | 170 |
| 172 | 171 |
| 173 # Some commands don't like the pipe, e.g. calling vi from within the script or | 172 # Some commands don't like the pipe, e.g. calling vi from within the script or |
| 174 # from subscripts like git cl upload. | 173 # from subscripts like git cl upload. |
| 175 def Command(cmd, args="", prefix="", pipe=True): | 174 def Command(cmd, args="", prefix="", pipe=True): |
| 176 # TODO(machenbach): Use timeout. | 175 # TODO(machenbach): Use timeout. |
| 177 cmd_line = "%s %s %s" % (prefix, cmd, args) | 176 cmd_line = "%s %s %s" % (prefix, cmd, args) |
| 178 print "Command: %s" % cmd_line | 177 print "Command: %s" % cmd_line |
| 178 sys.stdout.flush() |
| 179 try: | 179 try: |
| 180 if pipe: | 180 if pipe: |
| 181 return subprocess.check_output(cmd_line, shell=True) | 181 return subprocess.check_output(cmd_line, shell=True) |
| 182 else: | 182 else: |
| 183 return subprocess.check_call(cmd_line, shell=True) | 183 return subprocess.check_call(cmd_line, shell=True) |
| 184 except subprocess.CalledProcessError: | 184 except subprocess.CalledProcessError: |
| 185 return None | 185 return None |
| 186 finally: |
| 187 sys.stdout.flush() |
| 188 sys.stderr.flush() |
| 186 | 189 |
| 187 | 190 |
| 188 # Wrapper for side effects. | 191 # Wrapper for side effects. |
| 189 class SideEffectHandler(object): # pragma: no cover | 192 class SideEffectHandler(object): # pragma: no cover |
| 190 def Call(self, fun, *args, **kwargs): | 193 def Call(self, fun, *args, **kwargs): |
| 191 return fun(*args, **kwargs) | 194 return fun(*args, **kwargs) |
| 192 | 195 |
| 193 def Command(self, cmd, args="", prefix="", pipe=True): | 196 def Command(self, cmd, args="", prefix="", pipe=True): |
| 194 return Command(cmd, args, prefix, pipe) | 197 return Command(cmd, args, prefix, pipe) |
| 195 | 198 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 if not self.GitIsWorkdirClean(): # pragma: no cover | 372 if not self.GitIsWorkdirClean(): # pragma: no cover |
| 370 self.Die("Workspace is not clean. Please commit or undo your changes.") | 373 self.Die("Workspace is not clean. Please commit or undo your changes.") |
| 371 | 374 |
| 372 # Persist current branch. | 375 # Persist current branch. |
| 373 self["current_branch"] = self.GitCurrentBranch() | 376 self["current_branch"] = self.GitCurrentBranch() |
| 374 | 377 |
| 375 # Fetch unfetched revisions. | 378 # Fetch unfetched revisions. |
| 376 self.GitSVNFetch() | 379 self.GitSVNFetch() |
| 377 | 380 |
| 378 def PrepareBranch(self): | 381 def PrepareBranch(self): |
| 379 # Get ahold of a safe temporary branch and check it out. | |
| 380 if self["current_branch"] != self._config[TEMP_BRANCH]: | |
| 381 self.DeleteBranch(self._config[TEMP_BRANCH]) | |
| 382 self.GitCreateBranch(self._config[TEMP_BRANCH]) | |
| 383 | |
| 384 # Delete the branch that will be created later if it exists already. | 382 # Delete the branch that will be created later if it exists already. |
| 385 self.DeleteBranch(self._config[BRANCHNAME]) | 383 self.DeleteBranch(self._config[BRANCHNAME]) |
| 386 | 384 |
| 387 def CommonCleanup(self): | 385 def CommonCleanup(self): |
| 388 self.GitCheckout(self["current_branch"]) | 386 self.GitCheckout(self["current_branch"]) |
| 389 if self._config[TEMP_BRANCH] != self["current_branch"]: | |
| 390 self.GitDeleteBranch(self._config[TEMP_BRANCH]) | |
| 391 if self._config[BRANCHNAME] != self["current_branch"]: | 387 if self._config[BRANCHNAME] != self["current_branch"]: |
| 392 self.GitDeleteBranch(self._config[BRANCHNAME]) | 388 self.GitDeleteBranch(self._config[BRANCHNAME]) |
| 393 | 389 |
| 394 # Clean up all temporary files. | 390 # Clean up all temporary files. |
| 395 Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME]) | 391 Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME]) |
| 396 | 392 |
| 397 def ReadAndPersistVersion(self, prefix=""): | 393 def ReadAndPersistVersion(self, prefix=""): |
| 398 def ReadAndPersist(var_name, def_name): | 394 def ReadAndPersist(var_name, def_name): |
| 399 match = re.match(r"^#define %s\s+(\d*)" % def_name, line) | 395 match = re.match(r"^#define %s\s+(\d*)" % def_name, line) |
| 400 if match: | 396 if match: |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 for (number, step_class) in enumerate(step_classes): | 597 for (number, step_class) in enumerate(step_classes): |
| 602 steps.append(MakeStep(step_class, number, self._state, self._config, | 598 steps.append(MakeStep(step_class, number, self._state, self._config, |
| 603 options, self._side_effect_handler)) | 599 options, self._side_effect_handler)) |
| 604 for step in steps[options.step:]: | 600 for step in steps[options.step:]: |
| 605 if step.Run(): | 601 if step.Run(): |
| 606 return 1 | 602 return 1 |
| 607 return 0 | 603 return 0 |
| 608 | 604 |
| 609 def Run(self, args=None): | 605 def Run(self, args=None): |
| 610 return self.RunSteps(self._Steps(), args) | 606 return self.RunSteps(self._Steps(), args) |
| OLD | NEW |