Chromium Code Reviews| Index: tools/release/backport_node.py |
| diff --git a/tools/release/backport_node.py b/tools/release/backport_node.py |
| index 61a931aa03452e18f07c55b63f0c7cf309ad648b..210e5e10da8a0d4530b18514936d710b79692238 100755 |
| --- a/tools/release/backport_node.py |
| +++ b/tools/release/backport_node.py |
| @@ -14,7 +14,8 @@ Usage: |
| $ backport_node.py <path_to_v8> <path_to_node> <commit-hash> |
| This will apply the commit to <path_to_node>/deps/v8 and create a commit in |
| - the Node.js checkout and copy over the original commit message. |
| + the Node.js checkout, increment patch level, and copy over the original |
| + commit message. |
| Optional flags: |
| --no-review Run `gclient sync` on the V8 checkout before updating. |
| @@ -24,8 +25,17 @@ import argparse |
| import os |
| import subprocess |
| import sys |
| +import re |
|
Michael Achenbach
2017/04/27 13:22:04
nit: sort imports, separate local imports with an
Yang
2017/04/27 14:18:57
Done.
|
| +from common_includes import * |
| TARGET_SUBDIR = os.path.join("deps", "v8") |
| +VERSION_FILE = os.path.join("include", "v8-version.h") |
| +VERSION_PATTERN = r'(?<=#define V8_PATCH_LEVEL )\d+' |
| + |
| +def Clean(options): |
| + print ">> Cleaning target directory." |
| + subprocess.check_call(["git", "clean", "-fd"], |
| + cwd = os.path.join(options.node_path, TARGET_SUBDIR)) |
| def CherryPick(options): |
| print ">> Apply patch." |
| @@ -42,6 +52,16 @@ def CherryPick(options): |
| while raw_input("[RESOLVED]") != "RESOLVED": |
| print ">> You need to type RESOLVED" |
| +def UpdateVersion(options): |
| + print ">> Increment patch level." |
| + version_file = os.path.join(options.node_path, TARGET_SUBDIR, VERSION_FILE) |
| + text = FileToText(version_file) |
| + def increment(match): |
| + patch = int(match.group(0)) |
| + return str(patch + 1) |
| + text = re.sub(VERSION_PATTERN, increment, text, flags=re.MULTILINE) |
| + TextToFile(text, version_file) |
| + |
| def CreateCommit(options): |
| print ">> Creating commit." |
| # Find short hash from source. |
| @@ -84,8 +104,10 @@ def ParseOptions(args): |
| def Main(args): |
| options = ParseOptions(args) |
| + Clean(options) |
| try: |
| CherryPick(options) |
| + UpdateVersion(options) |
| CreateCommit(options) |
| except: |
| print ">> Failed. Resetting." |