Commit 6a7a5d60 authored by pshenoy@chromium.org's avatar pshenoy@chromium.org

Added an option (--use-local-repo) to run bisect-builds.py from git checkout so that

'Downloading list of known revisions' step is faster. If the script is run with
--use-local-repo option, it will use "git svn find-rev <SHA1>" command to convert git hash 
to svn revision. This method is significantly faster than running the script
without git checkout.

Eg: Command to run:
time ./tools/bisect-builds.py -g 280588 -b 280590 --archive linux64 --use-local-repo

Output:
real	5m16.089s
user	3m50.326s
sys	1m1.190s

time ./tools/bisect-builds.py -g 280588 -b 280590 --archive linux64

Output:
real	10m51.194s
user	0m10.248s
sys	0m1.419s


BUG=390547
NOTRY=True

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281936 0039d316-1c4b-4281-b951-d872f2087c98
parent 76f62954
...@@ -79,7 +79,7 @@ class PathContext(object): ...@@ -79,7 +79,7 @@ class PathContext(object):
"""A PathContext is used to carry the information used to construct URLs and """A PathContext is used to carry the information used to construct URLs and
paths when dealing with the storage server and archives.""" paths when dealing with the storage server and archives."""
def __init__(self, base_url, platform, good_revision, bad_revision, def __init__(self, base_url, platform, good_revision, bad_revision,
is_official, is_aura, flash_path = None): is_official, is_aura, use_local_repo, flash_path = None):
super(PathContext, self).__init__() super(PathContext, self).__init__()
# Store off the input parameters. # Store off the input parameters.
self.base_url = base_url self.base_url = base_url
...@@ -98,6 +98,12 @@ class PathContext(object): ...@@ -98,6 +98,12 @@ class PathContext(object):
# The name of the ZIP file in a revision directory on the server. # The name of the ZIP file in a revision directory on the server.
self.archive_name = None self.archive_name = None
# If the script is run from a local Chromium checkout,
# "--use-local-repo" option can be used to make the script run faster.
# It uses "git svn find-rev <SHA1>" command to convert git hash to svn
# revision number.
self.use_local_repo = use_local_repo
# Set some internal members: # Set some internal members:
# _listing_platform_dir = Directory that holds revisions. Ends with a '/'. # _listing_platform_dir = Directory that holds revisions. Ends with a '/'.
# _archive_extract_dir = Uncompressed directory in the archive_name file. # _archive_extract_dir = Uncompressed directory in the archive_name file.
...@@ -253,7 +259,7 @@ class PathContext(object): ...@@ -253,7 +259,7 @@ class PathContext(object):
self.githash_svn_dict.update(new_dict) self.githash_svn_dict.update(new_dict)
return revisions return revisions
def GetSVNRevisionFromGitHash(self, git_sha1, depot='chromium'): def _GetSVNRevisionFromGitHashWithoutGitCheckout(self, git_sha1, depot):
json_url = GITHASH_TO_SVN_URL[depot] % git_sha1 json_url = GITHASH_TO_SVN_URL[depot] % git_sha1
try: try:
response = urllib.urlopen(json_url) response = urllib.urlopen(json_url)
...@@ -271,6 +277,42 @@ class PathContext(object): ...@@ -271,6 +277,42 @@ class PathContext(object):
print 'Failed to get svn revision number for %s' % git_sha1 print 'Failed to get svn revision number for %s' % git_sha1
return None return None
def _GetSVNRevisionFromGitHashFromGitCheckout(self, git_sha1, depot):
def _RunGit(command, path):
command = ['git'] + command
if path:
original_path = os.getcwd()
os.chdir(path)
shell = sys.platform.startswith('win')
proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, _) = proc.communicate()
if path:
os.chdir(original_path)
return (output, proc.returncode)
path = None
if depot == 'blink':
path = os.path.join(os.getcwd(), 'third_party', 'WebKit')
if os.path.basename(os.getcwd()) == 'src':
command = ['svn', 'find-rev', git_sha1]
(git_output, return_code) = _RunGit(command, path)
if not return_code:
return git_output.strip('\n')
return None
else:
print ('Script should be run from src folder. ' +
'Eg: python tools/bisect-builds.py -g 280588 -b 280590' +
'--archive linux64 --use-local-repo')
sys.exit(1)
def GetSVNRevisionFromGitHash(self, git_sha1, depot='chromium'):
if not self.use_local_repo:
return self._GetSVNRevisionFromGitHashWithoutGitCheckout(git_sha1, depot)
else:
return self._GetSVNRevisionFromGitHashFromGitCheckout(git_sha1, depot)
def GetRevList(self): def GetRevList(self):
"""Gets the list of revision numbers between self.good_revision and """Gets the list of revision numbers between self.good_revision and
self.bad_revision.""" self.bad_revision."""
...@@ -513,6 +555,7 @@ def Bisect(base_url, ...@@ -513,6 +555,7 @@ def Bisect(base_url,
platform, platform,
official_builds, official_builds,
is_aura, is_aura,
use_local_repo,
good_rev=0, good_rev=0,
bad_rev=0, bad_rev=0,
num_runs=1, num_runs=1,
...@@ -556,7 +599,7 @@ def Bisect(base_url, ...@@ -556,7 +599,7 @@ def Bisect(base_url,
profile = 'profile' profile = 'profile'
context = PathContext(base_url, platform, good_rev, bad_rev, context = PathContext(base_url, platform, good_rev, bad_rev,
official_builds, is_aura, flash_path) official_builds, is_aura, use_local_repo, flash_path)
cwd = os.getcwd() cwd = os.getcwd()
print "Downloading list of known revisions..." print "Downloading list of known revisions..."
...@@ -845,6 +888,13 @@ def main(): ...@@ -845,6 +888,13 @@ def main():
action='store_true', action='store_true',
default=False, default=False,
help='Allow the script to bisect aura builds') help='Allow the script to bisect aura builds')
parser.add_option('--use-local-repo',
dest='use_local_repo',
action='store_true',
default=False,
help='Allow the script to convert git SHA1 to SVN ' +
'revision using "git svn find-rev <SHA1>" ' +
'command from a Chromium checkout.')
(opts, args) = parser.parse_args() (opts, args) = parser.parse_args()
...@@ -867,7 +917,8 @@ def main(): ...@@ -867,7 +917,8 @@ def main():
# Create the context. Initialize 0 for the revisions as they are set below. # Create the context. Initialize 0 for the revisions as they are set below.
context = PathContext(base_url, opts.archive, 0, 0, context = PathContext(base_url, opts.archive, 0, 0,
opts.official_builds, opts.aura, None) opts.official_builds, opts.aura, opts.use_local_repo,
None)
# Pick a starting point, try to get HEAD for this. # Pick a starting point, try to get HEAD for this.
if opts.bad: if opts.bad:
bad_rev = opts.bad bad_rev = opts.bad
...@@ -901,9 +952,9 @@ def main(): ...@@ -901,9 +952,9 @@ def main():
return 1 return 1
(min_chromium_rev, max_chromium_rev) = Bisect( (min_chromium_rev, max_chromium_rev) = Bisect(
base_url, opts.archive, opts.official_builds, opts.aura, good_rev, base_url, opts.archive, opts.official_builds, opts.aura,
bad_rev, opts.times, opts.command, args, opts.profile, opts.flash_path, opts.use_local_repo, good_rev, bad_rev, opts.times, opts.command,
not opts.not_interactive) args, opts.profile, opts.flash_path, not opts.not_interactive)
# Get corresponding blink revisions. # Get corresponding blink revisions.
try: try:
......
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