Commit 28ae2168 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Show first V8 branch in mergeinfo.py

Change-Id: I169b4d91463cb59aa2a91e79eda2d7e877f88d72
Reviewed-on: https://chromium-review.googlesource.com/456319
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMichael Hablich <hablich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44338}
parent 928a9462
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import argparse import argparse
import os import os
import sys import sys
import re
from search_related_commits import git_execute from search_related_commits import git_execute
...@@ -56,12 +57,10 @@ def get_branches_for_commit(git_working_dir, hash_to_search): ...@@ -56,12 +57,10 @@ def get_branches_for_commit(git_working_dir, hash_to_search):
branches = branches.splitlines() branches = branches.splitlines()
return map(str.strip, branches) return map(str.strip, branches)
def is_lkgr(git_working_dir, hash_to_search): def is_lkgr(branches):
branches = get_branches_for_commit(git_working_dir, hash_to_search)
return 'remotes/origin/lkgr' in branches return 'remotes/origin/lkgr' in branches
def get_first_canary(git_working_dir, hash_to_search): def get_first_canary(branches):
branches = get_branches_for_commit(git_working_dir, hash_to_search)
canaries = ([currentBranch for currentBranch in branches if canaries = ([currentBranch for currentBranch in branches if
currentBranch.startswith('remotes/origin/chromium/')]) currentBranch.startswith('remotes/origin/chromium/')])
canaries.sort() canaries.sort()
...@@ -69,15 +68,25 @@ def get_first_canary(git_working_dir, hash_to_search): ...@@ -69,15 +68,25 @@ def get_first_canary(git_working_dir, hash_to_search):
return 'No Canary coverage' return 'No Canary coverage'
return canaries[0].split('/')[-1] return canaries[0].split('/')[-1]
def get_first_v8_version(branches):
version_re = re.compile("remotes/origin/[0-9]+\.[0-9]+\.[0-9]+")
versions = filter(lambda branch: version_re.match(branch), branches)
if len(versions) == 0:
return "--"
version = versions[0].split("/")[-1]
return version
def print_analysis(git_working_dir, hash_to_search): def print_analysis(git_working_dir, hash_to_search):
print '1.) Searching for "' + hash_to_search + '"' print '1.) Searching for "' + hash_to_search + '"'
print '=====================ORIGINAL COMMIT START===================' print '=====================ORIGINAL COMMIT START==================='
print describe_commit(git_working_dir, hash_to_search) print describe_commit(git_working_dir, hash_to_search)
print '=====================ORIGINAL COMMIT END=====================' print '=====================ORIGINAL COMMIT END====================='
print '2.) General information:' print '2.) General information:'
print 'Is LKGR: ' + str(is_lkgr(git_working_dir, hash_to_search)) branches = get_branches_for_commit(git_working_dir, hash_to_search)
print 'Is on Canary: ' + ( print 'Is LKGR: ' + str(is_lkgr(branches))
str(get_first_canary(git_working_dir, hash_to_search))) print 'Is on Canary: ' + str(get_first_canary(branches))
print 'First V8 branch: ' + str(get_first_v8_version(branches)) + \
' (Might not be the rolled version)'
print '3.) Found follow-up commits, reverts and ports:' print '3.) Found follow-up commits, reverts and ports:'
followups = get_followup_commits(git_working_dir, hash_to_search) followups = get_followup_commits(git_working_dir, hash_to_search)
for followup in followups: for followup in followups:
......
...@@ -73,6 +73,9 @@ class TestMergeInfo(unittest.TestCase): ...@@ -73,6 +73,9 @@ class TestMergeInfo(unittest.TestCase):
["log", "--format=%H", "--reverse"]).splitlines() ["log", "--format=%H", "--reverse"]).splitlines()
return commits return commits
def _get_branches(self, hash):
return mergeinfo.get_branches_for_commit(self.base_dir, hash)
def _make_empty_commit(self, message): def _make_empty_commit(self, message):
self._execute_git(["commit", "--allow-empty", "-m", message]) self._execute_git(["commit", "--allow-empty", "-m", message])
self._update_origin() self._update_origin()
...@@ -166,23 +169,41 @@ class TestMergeInfo(unittest.TestCase): ...@@ -166,23 +169,41 @@ class TestMergeInfo(unittest.TestCase):
self._execute_git(['branch', 'remotes/origin/lkgr']) self._execute_git(['branch', 'remotes/origin/lkgr'])
hash_of_not_lkgr = self._make_empty_commit('This one is not yet lkgr') hash_of_not_lkgr = self._make_empty_commit('This one is not yet lkgr')
self.assertTrue(mergeinfo.is_lkgr( branches = self._get_branches(hash_of_first_commit);
self.base_dir, hash_of_first_commit)) self.assertTrue(mergeinfo.is_lkgr(branches))
self.assertFalse(mergeinfo.is_lkgr( branches = self._get_branches(hash_of_not_lkgr);
self.base_dir, hash_of_not_lkgr)) self.assertFalse(mergeinfo.is_lkgr(branches))
def testShowFirstCanary(self): def testShowFirstCanary(self):
commits = self._get_commits() commits = self._get_commits()
hash_of_first_commit = commits[0] hash_of_first_commit = commits[0]
self.assertEqual(mergeinfo.get_first_canary( branches = self._get_branches(hash_of_first_commit);
self.base_dir, hash_of_first_commit), 'No Canary coverage') self.assertEqual(mergeinfo.get_first_canary(branches), 'No Canary coverage')
self._execute_git(['branch', 'remotes/origin/chromium/2345']) self._execute_git(['branch', 'remotes/origin/chromium/2345'])
self._execute_git(['branch', 'remotes/origin/chromium/2346']) self._execute_git(['branch', 'remotes/origin/chromium/2346'])
self.assertEqual(mergeinfo.get_first_canary( branches = self._get_branches(hash_of_first_commit);
self.base_dir, hash_of_first_commit), '2345') self.assertEqual(mergeinfo.get_first_canary(branches), '2345')
def testFirstV8Version(self):
commits = self._get_commits()
hash_of_first_commit = commits[0]
self._execute_git(['branch', 'remotes/origin/chromium/2345'])
self._execute_git(['branch', 'remotes/origin/chromium/2346'])
branches = self._get_branches(hash_of_first_commit);
self.assertEqual(mergeinfo.get_first_v8_version(branches), '--')
self._execute_git(['branch', 'remotes/origin/5.7.1'])
self._execute_git(['branch', 'remotes/origin/5.8.1'])
branches = self._get_branches(hash_of_first_commit);
self.assertEqual(mergeinfo.get_first_v8_version(branches), '5.7.1')
self._execute_git(['branch', 'remotes/origin/5.6.1'])
branches = self._get_branches(hash_of_first_commit);
self.assertEqual(mergeinfo.get_first_v8_version(branches), '5.6.1')
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
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