summaryrefslogtreecommitdiffstats
path: root/tools/bisect-builds.py
diff options
context:
space:
mode:
authorpshenoy@chromium.org <pshenoy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-09 04:45:50 +0000
committerpshenoy@chromium.org <pshenoy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-09 04:45:50 +0000
commit6a7a5d60f972611d3df92d4ee9ed67be6d05937c (patch)
tree7a719f0fec002bc88a3e796bf4473d691b9bc76d /tools/bisect-builds.py
parent76f6295421551a3df2a93ba68acb820f14cc4408 (diff)
downloadchromium_src-6a7a5d60f972611d3df92d4ee9ed67be6d05937c.zip
chromium_src-6a7a5d60f972611d3df92d4ee9ed67be6d05937c.tar.gz
chromium_src-6a7a5d60f972611d3df92d4ee9ed67be6d05937c.tar.bz2
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
Diffstat (limited to 'tools/bisect-builds.py')
-rwxr-xr-xtools/bisect-builds.py65
1 files changed, 58 insertions, 7 deletions
diff --git a/tools/bisect-builds.py b/tools/bisect-builds.py
index 968e9b9..e1f5e03 100755
--- a/tools/bisect-builds.py
+++ b/tools/bisect-builds.py
@@ -79,7 +79,7 @@ class PathContext(object):
"""A PathContext is used to carry the information used to construct URLs and
paths when dealing with the storage server and archives."""
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__()
# Store off the input parameters.
self.base_url = base_url
@@ -98,6 +98,12 @@ class PathContext(object):
# The name of the ZIP file in a revision directory on the server.
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:
# _listing_platform_dir = Directory that holds revisions. Ends with a '/'.
# _archive_extract_dir = Uncompressed directory in the archive_name file.
@@ -253,7 +259,7 @@ class PathContext(object):
self.githash_svn_dict.update(new_dict)
return revisions
- def GetSVNRevisionFromGitHash(self, git_sha1, depot='chromium'):
+ def _GetSVNRevisionFromGitHashWithoutGitCheckout(self, git_sha1, depot):
json_url = GITHASH_TO_SVN_URL[depot] % git_sha1
try:
response = urllib.urlopen(json_url)
@@ -271,6 +277,42 @@ class PathContext(object):
print 'Failed to get svn revision number for %s' % git_sha1
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):
"""Gets the list of revision numbers between self.good_revision and
self.bad_revision."""
@@ -513,6 +555,7 @@ def Bisect(base_url,
platform,
official_builds,
is_aura,
+ use_local_repo,
good_rev=0,
bad_rev=0,
num_runs=1,
@@ -556,7 +599,7 @@ def Bisect(base_url,
profile = 'profile'
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()
print "Downloading list of known revisions..."
@@ -845,6 +888,13 @@ def main():
action='store_true',
default=False,
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()
@@ -867,7 +917,8 @@ def main():
# Create the context. Initialize 0 for the revisions as they are set below.
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.
if opts.bad:
bad_rev = opts.bad
@@ -901,9 +952,9 @@ def main():
return 1
(min_chromium_rev, max_chromium_rev) = Bisect(
- base_url, opts.archive, opts.official_builds, opts.aura, good_rev,
- bad_rev, opts.times, opts.command, args, opts.profile, opts.flash_path,
- not opts.not_interactive)
+ base_url, opts.archive, opts.official_builds, opts.aura,
+ opts.use_local_repo, good_rev, bad_rev, opts.times, opts.command,
+ args, opts.profile, opts.flash_path, not opts.not_interactive)
# Get corresponding blink revisions.
try: