Make auto_roll run with a pure git checkout.

BUG=410721
LOG=n
TBR=jarin@chromium.org

Review URL: https://codereview.chromium.org/540513002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23672 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4f165b86
...@@ -50,8 +50,9 @@ class DetectLastPush(Step): ...@@ -50,8 +50,9 @@ class DetectLastPush(Step):
MESSAGE = "Detect commit ID of the last push to trunk." MESSAGE = "Detect commit ID of the last push to trunk."
def RunStep(self): def RunStep(self):
push_hash = self.FindLastTrunkPush(include_patches=True) push_hash = self.FindLastTrunkPush(
self["last_push"] = self.GitSVNFindSVNRev(push_hash) branch="origin/master", include_patches=True)
self["last_push"] = self.GetCommitPositionNumber(push_hash)
class DetectLastRoll(Step): class DetectLastRoll(Step):
...@@ -62,7 +63,9 @@ class DetectLastRoll(Step): ...@@ -62,7 +63,9 @@ class DetectLastRoll(Step):
Var = lambda var: '%s' Var = lambda var: '%s'
exec(self.ReadURL(CR_DEPS_URL)) exec(self.ReadURL(CR_DEPS_URL))
last_roll = vars['v8_revision'] last_roll = vars['v8_revision']
if last_roll >= self["last_push"]: # FIXME(machenbach): When rolling from bleeding edge and from trunk there
# be different commit numbers here. Better use version?
if int(last_roll) >= int(self["last_push"]):
print("There is no newer v8 revision than the one in Chromium (%s)." print("There is no newer v8 revision than the one in Chromium (%s)."
% last_roll) % last_roll)
return True return True
......
...@@ -23,7 +23,8 @@ class Preparation(Step): ...@@ -23,7 +23,8 @@ class Preparation(Step):
MESSAGE = "Preparation." MESSAGE = "Preparation."
def RunStep(self): def RunStep(self):
self.CommonPrepare() # Update v8 remote tracking branches.
self.GitFetchOrigin()
class DetectLastPush(Step): class DetectLastPush(Step):
...@@ -31,8 +32,8 @@ class DetectLastPush(Step): ...@@ -31,8 +32,8 @@ class DetectLastPush(Step):
def RunStep(self): def RunStep(self):
self["last_push"] = self._options.last_push or self.FindLastTrunkPush( self["last_push"] = self._options.last_push or self.FindLastTrunkPush(
include_patches=True) branch="origin/master", include_patches=True)
self["trunk_revision"] = self.GitSVNFindSVNRev(self["last_push"]) self["trunk_revision"] = self.GetCommitPositionNumber(self["last_push"])
self["push_title"] = self.GitLog(n=1, format="%s", self["push_title"] = self.GitLog(n=1, format="%s",
git_hash=self["last_push"]) git_hash=self["last_push"])
......
...@@ -471,13 +471,14 @@ class Step(GitRecipesMixin): ...@@ -471,13 +471,14 @@ class Step(GitRecipesMixin):
except GitFailedException: except GitFailedException:
self.WaitForResolvingConflicts(patch_file) self.WaitForResolvingConflicts(patch_file)
def FindLastTrunkPush(self, parent_hash="", include_patches=False): def FindLastTrunkPush(
self, parent_hash="", branch="", include_patches=False):
push_pattern = "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*" push_pattern = "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*"
if not include_patches: if not include_patches:
# Non-patched versions only have three numbers followed by the "(based # Non-patched versions only have three numbers followed by the "(based
# on...) comment." # on...) comment."
push_pattern += " (based" push_pattern += " (based"
branch = "" if parent_hash else "svn/trunk" branch = "" if parent_hash else branch or "svn/trunk"
return self.GitLog(n=1, format="%H", grep=push_pattern, return self.GitLog(n=1, format="%H", grep=push_pattern,
parent_hash=parent_hash, branch=branch) parent_hash=parent_hash, branch=branch)
......
...@@ -29,7 +29,49 @@ ...@@ -29,7 +29,49 @@
import re import re
SHA1_RE = re.compile('^[a-fA-F0-9]{40}$') SHA1_RE = re.compile('^[a-fA-F0-9]{40}$')
GIT_SVN_ID_RE = re.compile('^git-svn-id: .*@([0-9]+) .*$') ROLL_DEPS_GIT_SVN_ID_RE = re.compile('^git-svn-id: .*@([0-9]+) .*$')
# Regular expression that matches a single commit footer line.
COMMIT_FOOTER_ENTRY_RE = re.compile(r'([^:]+):\s+(.+)')
# Footer metadata key for commit position.
COMMIT_POSITION_FOOTER_KEY = 'Cr-Commit-Position'
# Regular expression to parse a commit position
COMMIT_POSITION_RE = re.compile(r'(.+)@\{#(\d+)\}')
# Key for the 'git-svn' ID metadata commit footer entry.
GIT_SVN_ID_FOOTER_KEY = 'git-svn-id'
# e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117
# ce2b1a6d-e550-0410-aec6-3dcde31c8c00
GIT_SVN_ID_RE = re.compile(r'((?:\w+)://[^@]+)@(\d+)\s+(?:[a-zA-Z0-9\-]+)')
# Copied from bot_update.py.
def GetCommitMessageFooterMap(message):
"""Returns: (dict) A dictionary of commit message footer entries.
"""
footers = {}
# Extract the lines in the footer block.
lines = []
for line in message.strip().splitlines():
line = line.strip()
if len(line) == 0:
del(lines[:])
continue
lines.append(line)
# Parse the footer
for line in lines:
m = COMMIT_FOOTER_ENTRY_RE.match(line)
if not m:
# If any single line isn't valid, the entire footer is invalid.
footers.clear()
return footers
footers[m.group(1)] = m.group(2).strip()
return footers
class GitFailedException(Exception): class GitFailedException(Exception):
...@@ -199,11 +241,42 @@ class GitRecipesMixin(object): ...@@ -199,11 +241,42 @@ class GitRecipesMixin(object):
raise GitFailedException("Git hash %s is unknown." % git_hash) raise GitFailedException("Git hash %s is unknown." % git_hash)
log = self.GitLog(n=1, format="%B", git_hash=git_hash) log = self.GitLog(n=1, format="%B", git_hash=git_hash)
for line in reversed(log.splitlines()): for line in reversed(log.splitlines()):
match = GIT_SVN_ID_RE.match(line.strip()) match = ROLL_DEPS_GIT_SVN_ID_RE.match(line.strip())
if match: if match:
return match.group(1) return match.group(1)
raise GitFailedException("Couldn't convert %s to SVN." % git_hash) raise GitFailedException("Couldn't convert %s to SVN." % git_hash)
@Strip
# Copied from bot_update.py and modified for svn-like numbers only.
def GetCommitPositionNumber(self, git_hash):
"""Dumps the 'git' log for a specific revision and parses out the commit
position number.
If a commit position metadata key is found, its number will be returned.
Otherwise, we will search for a 'git-svn' metadata entry. If one is found,
its SVN revision value is returned.
"""
git_log = self.GitLog(format='%B', n=1, git_hash=git_hash)
footer_map = GetCommitMessageFooterMap(git_log)
# Search for commit position metadata
value = footer_map.get(COMMIT_POSITION_FOOTER_KEY)
if value:
match = COMMIT_POSITION_RE.match(value)
if match:
return match.group(2)
# Extract the svn revision from 'git-svn' metadata
value = footer_map.get(GIT_SVN_ID_FOOTER_KEY)
if value:
match = GIT_SVN_ID_RE.match(value)
if match:
return match.group(2)
return None
### Git svn stuff
def GitSVNFetch(self): def GitSVNFetch(self):
self.Git("svn fetch") self.Git("svn fetch")
......
...@@ -57,77 +57,6 @@ DEPS_RE = re.compile(r"""^\s*(?:["']v8_revision["']: ["']""" ...@@ -57,77 +57,6 @@ DEPS_RE = re.compile(r"""^\s*(?:["']v8_revision["']: ["']"""
BLEEDING_EDGE_TAGS_RE = re.compile( BLEEDING_EDGE_TAGS_RE = re.compile(
r"A \/tags\/([^\s]+) \(from \/branches\/bleeding_edge\:(\d+)\)") r"A \/tags\/([^\s]+) \(from \/branches\/bleeding_edge\:(\d+)\)")
# Regular expression that matches a single commit footer line.
COMMIT_FOOTER_ENTRY_RE = re.compile(r'([^:]+):\s+(.+)')
# Footer metadata key for commit position.
COMMIT_POSITION_FOOTER_KEY = 'Cr-Commit-Position'
# Regular expression to parse a commit position
COMMIT_POSITION_RE = re.compile(r'(.+)@\{#(\d+)\}')
# Key for the 'git-svn' ID metadata commit footer entry.
GIT_SVN_ID_FOOTER_KEY = 'git-svn-id'
# e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117
# ce2b1a6d-e550-0410-aec6-3dcde31c8c00
GIT_SVN_ID_RE = re.compile(r'((?:\w+)://[^@]+)@(\d+)\s+(?:[a-zA-Z0-9\-]+)')
# Copied from bot_update.py.
def GetCommitMessageFooterMap(message):
"""Returns: (dict) A dictionary of commit message footer entries.
"""
footers = {}
# Extract the lines in the footer block.
lines = []
for line in message.strip().splitlines():
line = line.strip()
if len(line) == 0:
del(lines[:])
continue
lines.append(line)
# Parse the footer
for line in lines:
m = COMMIT_FOOTER_ENTRY_RE.match(line)
if not m:
# If any single line isn't valid, the entire footer is invalid.
footers.clear()
return footers
footers[m.group(1)] = m.group(2).strip()
return footers
# Copied from bot_update.py and modified for svn-like numbers only.
def GetCommitPositionNumber(step, git_hash):
"""Dumps the 'git' log for a specific revision and parses out the commit
position number.
If a commit position metadata key is found, its number will be returned.
Otherwise, we will search for a 'git-svn' metadata entry. If one is found,
its SVN revision value is returned.
"""
git_log = step.GitLog(format='%B', n=1, git_hash=git_hash)
footer_map = GetCommitMessageFooterMap(git_log)
# Search for commit position metadata
value = footer_map.get(COMMIT_POSITION_FOOTER_KEY)
if value:
match = COMMIT_POSITION_RE.match(value)
if match:
return match.group(2)
# Extract the svn revision from 'git-svn' metadata
value = footer_map.get(GIT_SVN_ID_FOOTER_KEY)
if value:
match = GIT_SVN_ID_RE.match(value)
if match:
return match.group(2)
return None
def SortBranches(branches): def SortBranches(branches):
"""Sort branches with version number names.""" """Sort branches with version number names."""
...@@ -419,7 +348,7 @@ class RetrieveChromiumV8Releases(Step): ...@@ -419,7 +348,7 @@ class RetrieveChromiumV8Releases(Step):
deps = FileToText(self.Config(DEPS_FILE)) deps = FileToText(self.Config(DEPS_FILE))
match = DEPS_RE.search(deps) match = DEPS_RE.search(deps)
if match: if match:
cr_rev = GetCommitPositionNumber(self, git_hash) cr_rev = self.GetCommitPositionNumber(git_hash)
if cr_rev: if cr_rev:
v8_rev = ConvertToCommitNumber(self, match.group(1)) v8_rev = ConvertToCommitNumber(self, match.group(1))
cr_releases.append([cr_rev, v8_rev]) cr_releases.append([cr_rev, v8_rev])
......
...@@ -800,6 +800,18 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -800,6 +800,18 @@ Performance and stability improvements on all platforms.""", commit)
def testPushToTrunkForced(self): def testPushToTrunkForced(self):
self._PushToTrunk(force=True) self._PushToTrunk(force=True)
C_V8_22624_LOG = """V8 CL.
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
"""
C_V8_123456_LOG = """V8 CL.
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123456 123
"""
def testChromiumRoll(self): def testChromiumRoll(self):
googlers_mapping_py = "%s-mapping.py" % TEST_CONFIG[PERSISTFILE_BASENAME] googlers_mapping_py = "%s-mapping.py" % TEST_CONFIG[PERSISTFILE_BASENAME]
with open(googlers_mapping_py, "w") as f: with open(googlers_mapping_py, "w") as f:
...@@ -817,19 +829,17 @@ def get_list(): ...@@ -817,19 +829,17 @@ def get_list():
TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line",
TEST_CONFIG[DEPS_FILE]) TEST_CONFIG[DEPS_FILE])
def WriteDeps(): def WriteDeps():
TextToFile("Some line\n \"v8_revision\": \"123455\",\n some line", TextToFile("Some line\n \"v8_revision\": \"22624\",\n some line",
TEST_CONFIG[DEPS_FILE]) TEST_CONFIG[DEPS_FILE])
expectations = [ expectations = [
Cmd("git status -s -uno", ""), Cmd("git fetch origin", ""),
Cmd("git status -s -b -uno", "## some_branch\n"),
Cmd("git svn fetch", ""),
Cmd(("git log -1 --format=%H --grep=" Cmd(("git log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" "
"svn/trunk"), "push_hash\n"), "origin/master"), "push_hash\n"),
Cmd("git svn find-rev push_hash", "123455\n"), Cmd("git log -1 --format=%B push_hash", self.C_V8_22624_LOG),
Cmd("git log -1 --format=%s push_hash", Cmd("git log -1 --format=%s push_hash",
"Version 3.22.5 (based on bleeding_edge revision r123454)\n"), "Version 3.22.5 (based on bleeding_edge revision r22622)\n"),
URL("https://chromium-build.appspot.com/p/chromium/sheriff_v8.js", URL("https://chromium-build.appspot.com/p/chromium/sheriff_v8.js",
"document.write('g_name')"), "document.write('g_name')"),
Cmd("git status -s -uno", ""), Cmd("git status -s -uno", ""),
...@@ -837,10 +847,10 @@ def get_list(): ...@@ -837,10 +847,10 @@ def get_list():
Cmd("gclient sync --nohooks", "syncing..."), Cmd("gclient sync --nohooks", "syncing..."),
Cmd("git pull", ""), Cmd("git pull", ""),
Cmd("git fetch origin", ""), Cmd("git fetch origin", ""),
Cmd("git checkout -b v8-roll-123455", ""), Cmd("git checkout -b v8-roll-22624", ""),
Cmd("roll-dep v8 123455", "rolled", cb=WriteDeps), Cmd("roll-dep v8 22624", "rolled", cb=WriteDeps),
Cmd(("git commit -am \"Update V8 to version 3.22.5 " Cmd(("git commit -am \"Update V8 to version 3.22.5 "
"(based on bleeding_edge revision r123454).\n\n" "(based on bleeding_edge revision r22622).\n\n"
"Please reply to the V8 sheriff c_name@chromium.org in " "Please reply to the V8 sheriff c_name@chromium.org in "
"case of problems.\n\nTBR=c_name@chromium.org\" " "case of problems.\n\nTBR=c_name@chromium.org\" "
"--author \"author@chromium.org <author@chromium.org>\""), "--author \"author@chromium.org <author@chromium.org>\""),
...@@ -855,7 +865,7 @@ def get_list(): ...@@ -855,7 +865,7 @@ def get_list():
ChromiumRoll(TEST_CONFIG, self).Run(args) ChromiumRoll(TEST_CONFIG, self).Run(args)
deps = FileToText(TEST_CONFIG[DEPS_FILE]) deps = FileToText(TEST_CONFIG[DEPS_FILE])
self.assertTrue(re.search("\"v8_revision\": \"123455\"", deps)) self.assertTrue(re.search("\"v8_revision\": \"22624\"", deps))
def testCheckLastPushRecently(self): def testCheckLastPushRecently(self):
self.Expect([ self.Expect([
...@@ -960,8 +970,8 @@ deps = { ...@@ -960,8 +970,8 @@ deps = {
("{\"results\": [{\"subject\": \"different\"}]}")), ("{\"results\": [{\"subject\": \"different\"}]}")),
Cmd(("git log -1 --format=%H --grep=" Cmd(("git log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" "
"svn/trunk"), "push_hash\n"), "origin/master"), "push_hash\n"),
Cmd("git svn find-rev push_hash", "123455\n"), Cmd("git log -1 --format=%B push_hash", self.C_V8_22624_LOG),
URL("http://src.chromium.org/svn/trunk/src/DEPS", URL("http://src.chromium.org/svn/trunk/src/DEPS",
self.FAKE_DEPS), self.FAKE_DEPS),
]) ])
...@@ -980,8 +990,8 @@ deps = { ...@@ -980,8 +990,8 @@ deps = {
("{\"results\": [{\"subject\": \"different\"}]}")), ("{\"results\": [{\"subject\": \"different\"}]}")),
Cmd(("git log -1 --format=%H --grep=" Cmd(("git log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" "
"svn/trunk"), "push_hash\n"), "origin/master"), "push_hash\n"),
Cmd("git svn find-rev push_hash", "123456\n"), Cmd("git log -1 --format=%B push_hash", self.C_V8_123456_LOG),
URL("http://src.chromium.org/svn/trunk/src/DEPS", URL("http://src.chromium.org/svn/trunk/src/DEPS",
self.FAKE_DEPS), self.FAKE_DEPS),
]) ])
...@@ -1169,11 +1179,6 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b ...@@ -1169,11 +1179,6 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
"""
c_v8_22624_log = """V8 CL.
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
""" """
json_output = self.MakeEmptyTempFile() json_output = self.MakeEmptyTempFile()
csv_output = self.MakeEmptyTempFile() csv_output = self.MakeEmptyTempFile()
...@@ -1263,7 +1268,7 @@ git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123 ...@@ -1263,7 +1268,7 @@ git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
Cmd("git rev-list -n 1 0123456789012345678901234567890123456789", Cmd("git rev-list -n 1 0123456789012345678901234567890123456789",
"0123456789012345678901234567890123456789"), "0123456789012345678901234567890123456789"),
Cmd("git log -1 --format=%B 0123456789012345678901234567890123456789", Cmd("git log -1 --format=%B 0123456789012345678901234567890123456789",
c_v8_22624_log), self.C_V8_22624_LOG),
Cmd("git diff --name-only c_hash3 c_hash3^", TEST_CONFIG[DEPS_FILE]), Cmd("git diff --name-only c_hash3 c_hash3^", TEST_CONFIG[DEPS_FILE]),
Cmd("git checkout -f c_hash3 -- %s" % TEST_CONFIG[DEPS_FILE], "", Cmd("git checkout -f c_hash3 -- %s" % TEST_CONFIG[DEPS_FILE], "",
cb=ResetDEPS(345)), cb=ResetDEPS(345)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment