Remove all official code.

[email protected], ananthak, stip
NOTRY=true

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

Cr-Commit-Position: refs/branch-heads/2704@{#501}
Cr-Branched-From: 6e53600def8f60d8c632fadc70d7c1939ccea347-refs/heads/master@{#386251}
(cherry picked from commit 1776675e8658043c75b7bd3d8e6a334f496d7687)

BUG=

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

Cr-Commit-Position: refs/heads/master@{#393039}
diff --git a/tools/bisect-builds.py b/tools/bisect-builds.py
index 57f0ca8..6db0047 100755
--- a/tools/bisect-builds.py
+++ b/tools/bisect-builds.py
@@ -20,25 +20,12 @@
 ASAN_BASE_URL = ('http://commondatastorage.googleapis.com'
                  '/chromium-browser-asan')
 
-# GS bucket name.
-GS_BUCKET_NAME = 'chrome-unsigned/desktop-5c0tCh'
-
-# Base URL for downloading official builds.
-GOOGLE_APIS_URL = 'commondatastorage.googleapis.com'
-
-# The base URL for official builds.
-OFFICIAL_BASE_URL = 'http://%s/%s' % (GOOGLE_APIS_URL, GS_BUCKET_NAME)
-
 # URL template for viewing changelogs between revisions.
 CHANGELOG_URL = ('https://chromium.googlesource.com/chromium/src/+log/%s..%s')
 
 # URL to convert SVN revision to git hash.
 CRREV_URL = ('https://cr-rev.appspot.com/_ah/api/crrev/v1/redirect/')
 
-# URL template for viewing changelogs between official versions.
-OFFICIAL_CHANGELOG_URL = ('https://chromium.googlesource.com/chromium/'
-                          'src/+log/%s..%s?pretty=full')
-
 # DEPS file URL.
 DEPS_FILE_OLD = ('http://src.chromium.org/viewvc/chrome/trunk/src/'
                  'DEPS?revision=%d')
@@ -108,14 +95,13 @@
   """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_asan, use_local_cache, flash_path = None):
+               is_asan, use_local_cache, flash_path = None):
     super(PathContext, self).__init__()
     # Store off the input parameters.
     self.base_url = base_url
     self.platform = platform  # What's passed in to the '-a/--archive' option.
     self.good_revision = good_revision
     self.bad_revision = bad_revision
-    self.is_official = is_official
     self.is_asan = is_asan
     self.build_type = 'release'
     self.flash_path = flash_path
@@ -157,47 +143,22 @@
     else:
       raise Exception('Invalid platform: %s' % self.platform)
 
-    if is_official:
+    if self.platform in ('linux', 'linux64', 'linux-arm', 'chromeos'):
+      self.archive_name = 'chrome-linux.zip'
+      self._archive_extract_dir = 'chrome-linux'
       if self.platform == 'linux':
-        self._listing_platform_dir = 'precise32/'
-        self.archive_name = 'chrome-precise32.zip'
-        self._archive_extract_dir = 'chrome-precise32'
+        self._listing_platform_dir = 'Linux/'
       elif self.platform == 'linux64':
-        self._listing_platform_dir = 'precise64/'
-        self.archive_name = 'chrome-precise64.zip'
-        self._archive_extract_dir = 'chrome-precise64'
-      elif self.platform == 'mac':
-        self._listing_platform_dir = 'mac/'
-        self._binary_name = 'Google Chrome.app/Contents/MacOS/Google Chrome'
-      elif self.platform == 'mac64':
-        self._listing_platform_dir = 'mac64/'
-        self._binary_name = 'Google Chrome.app/Contents/MacOS/Google Chrome'
-      elif self.platform == 'win':
-        self._listing_platform_dir = 'win/'
-        self.archive_name = 'chrome-win.zip'
-        self._archive_extract_dir = 'chrome-win'
-      elif self.platform == 'win64':
-        self._listing_platform_dir = 'win64/'
-        self.archive_name = 'chrome-win64.zip'
-        self._archive_extract_dir = 'chrome-win64'
-    else:
-      if self.platform in ('linux', 'linux64', 'linux-arm', 'chromeos'):
-        self.archive_name = 'chrome-linux.zip'
-        self._archive_extract_dir = 'chrome-linux'
-        if self.platform == 'linux':
-          self._listing_platform_dir = 'Linux/'
-        elif self.platform == 'linux64':
-          self._listing_platform_dir = 'Linux_x64/'
-        elif self.platform == 'linux-arm':
-          self._listing_platform_dir = 'Linux_ARM_Cross-Compile/'
-        elif self.platform == 'chromeos':
-          self._listing_platform_dir = 'Linux_ChromiumOS_Full/'
-      # There is no 64-bit distinction for non-official mac builds.
-      elif self.platform in ('mac', 'mac64'):
-        self._listing_platform_dir = 'Mac/'
-        self._binary_name = 'Chromium.app/Contents/MacOS/Chromium'
-      elif self.platform == 'win':
-        self._listing_platform_dir = 'Win/'
+        self._listing_platform_dir = 'Linux_x64/'
+      elif self.platform == 'linux-arm':
+        self._listing_platform_dir = 'Linux_ARM_Cross-Compile/'
+      elif self.platform == 'chromeos':
+        self._listing_platform_dir = 'Linux_ChromiumOS_Full/'
+    elif self.platform in ('mac', 'mac64'):
+      self._listing_platform_dir = 'Mac/'
+      self._binary_name = 'Chromium.app/Contents/MacOS/Chromium'
+    elif self.platform == 'win':
+      self._listing_platform_dir = 'Win/'
 
   def GetASANPlatformDir(self):
     """ASAN builds are in directories like "linux-release", or have filenames
@@ -226,15 +187,10 @@
       return '%s/%s-%s/%s-%d.zip' % (
           ASAN_BASE_URL, self.GetASANPlatformDir(), self.build_type,
           self.GetASANBaseName(), revision)
-    if self.is_official:
-      return '%s/%s/%s%s' % (
-          OFFICIAL_BASE_URL, revision, self._listing_platform_dir,
-          self.archive_name)
-    else:
-      if str(revision) in self.githash_svn_dict:
-        revision = self.githash_svn_dict[str(revision)]
-      return '%s/%s%s/%s' % (self.base_url, self._listing_platform_dir,
-                             revision, self.archive_name)
+    if str(revision) in self.githash_svn_dict:
+      revision = self.githash_svn_dict[str(revision)]
+    return '%s/%s%s/%s' % (self.base_url, self._listing_platform_dir,
+                           revision, self.archive_name)
 
   def GetLastChangeURL(self):
     """Returns a URL to the LAST_CHANGE file."""
@@ -496,72 +452,6 @@
                                                    self.bad_revision)
     return revlist
 
-  def GetOfficialBuildsList(self):
-    """Gets the list of official build numbers between self.good_revision and
-    self.bad_revision."""
-
-    def CheckDepotToolsInPath():
-      delimiter = ';' if sys.platform.startswith('win') else ':'
-      path_list = os.environ['PATH'].split(delimiter)
-      for path in path_list:
-        if path.rstrip(os.path.sep).endswith('depot_tools'):
-          return path
-      return None
-
-    def RunGsutilCommand(args):
-      gsutil_path = CheckDepotToolsInPath()
-      if gsutil_path is None:
-        print ('Follow the instructions in this document '
-               'http://dev.chromium.org/developers/how-tos/install-depot-tools'
-               ' to install depot_tools and then try again.')
-        sys.exit(1)
-      gsutil_path = os.path.join(gsutil_path, 'third_party', 'gsutil', 'gsutil')
-      gsutil = subprocess.Popen([sys.executable, gsutil_path] + args,
-                                stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-                                env=None)
-      stdout, stderr = gsutil.communicate()
-      if gsutil.returncode:
-        if (re.findall(r'status[ |=]40[1|3]', stderr) or
-            stderr.startswith(CREDENTIAL_ERROR_MESSAGE)):
-          print ('Follow these steps to configure your credentials and try'
-                 ' running the bisect-builds.py again.:\n'
-                 '  1. Run "python %s config" and follow its instructions.\n'
-                 '  2. If you have a @google.com account, use that account.\n'
-                 '  3. For the project-id, just enter 0.' % gsutil_path)
-          sys.exit(1)
-        else:
-          raise Exception('Error running the gsutil command: %s' % stderr)
-      return stdout
-
-    def GsutilList(bucket):
-      query = 'gs://%s/' % bucket
-      stdout = RunGsutilCommand(['ls', query])
-      return [url[len(query):].strip('/') for url in stdout.splitlines()]
-
-    # Download the revlist and filter for just the range between good and bad.
-    minrev = min(self.good_revision, self.bad_revision)
-    maxrev = max(self.good_revision, self.bad_revision)
-    build_numbers = GsutilList(GS_BUCKET_NAME)
-    revision_re = re.compile(r'(\d\d\.\d\.\d{4}\.\d+)')
-    build_numbers = filter(lambda b: revision_re.search(b), build_numbers)
-    final_list = []
-    parsed_build_numbers = [LooseVersion(x) for x in build_numbers]
-    connection = httplib.HTTPConnection(GOOGLE_APIS_URL)
-    for build_number in sorted(parsed_build_numbers):
-      if build_number > maxrev:
-        break
-      if build_number < minrev:
-        continue
-      path = ('/' + GS_BUCKET_NAME + '/' + str(build_number) + '/' +
-              self._listing_platform_dir + self.archive_name)
-      connection.request('HEAD', path)
-      response = connection.getresponse()
-      if response.status == 200:
-        final_list.append(str(build_number))
-      response.read()
-    connection.close()
-    return final_list
-
 def UnzipFilenameToDir(filename, directory):
   """Unzip |filename| to |directory|."""
   cwd = os.getcwd()
@@ -648,8 +538,7 @@
   # Run the build as many times as specified.
   testargs = ['--user-data-dir=%s' % profile] + args
   # The sandbox must be run as root on Official Chrome, so bypass it.
-  if ((context.is_official or context.flash_path) and
-      context.platform.startswith('linux')):
+  if (context.flash_path and context.platform.startswith('linux')):
     testargs.append('--no-sandbox')
   if context.flash_path:
     testargs.append('--ppapi-flash-path=%s' % context.flash_path)
@@ -687,11 +576,11 @@
   return results[0]
 
 
-# The arguments official_builds, status, stdout and stderr are unused.
+# The arguments status, stdout and stderr are unused.
 # They are present here because this function is passed to Bisect which then
 # calls it with 5 arguments.
 # pylint: disable=W0613
-def AskIsGoodBuild(rev, official_builds, exit_status, stdout, stderr):
+def AskIsGoodBuild(rev, exit_status, stdout, stderr):
   """Asks the user whether build |rev| is good or bad."""
   # Loop until we get a response that we can parse.
   while True:
@@ -707,7 +596,7 @@
       print stderr
 
 
-def IsGoodASANBuild(rev, official_builds, exit_status, stdout, stderr):
+def IsGoodASANBuild(rev, exit_status, stdout, stderr):
   """Determine if an ASAN build |rev| is good or bad
 
   Will examine stderr looking for the error message emitted by ASAN. If not
@@ -721,10 +610,10 @@
     if bad_count > 0:
       print 'Revision %d determined to be bad.' % rev
       return 'b'
-  return AskIsGoodBuild(rev, official_builds, exit_status, stdout, stderr)
+  return AskIsGoodBuild(rev, exit_status, stdout, stderr)
 
 
-def DidCommandSucceed(rev, official_builds, exit_status, stdout, stderr):
+def DidCommandSucceed(rev, exit_status, stdout, stderr):
   if exit_status:
     print 'Bad revision: %s' % rev
     return 'b'
@@ -790,8 +679,7 @@
         context, rev, fetch.zip_file, profile, num_runs, command, try_args)
   except Exception, e:
     print >> sys.stderr, e
-  if (evaluate(rev, context.is_official, exit_status, stdout, stderr) !=
-      expected_answer):
+  if (evaluate(rev, exit_status, stdout, stderr) != expected_answer):
     print 'Unexpected result at a range boundary! Your range is not correct.'
     raise SystemExit
 
@@ -838,16 +726,13 @@
   cwd = os.getcwd()
 
   print 'Downloading list of known revisions...',
-  if not context.use_local_cache and not context.is_official:
+  if not context.use_local_cache:
     print '(use --use-local-cache to cache and re-use the list of revisions)'
   else:
     print
   _GetDownloadPath = lambda rev: os.path.join(cwd,
       '%s-%s' % (str(rev), context.archive_name))
-  if context.is_official:
-    revlist = context.GetOfficialBuildsList()
-  else:
-    revlist = context.GetRevList()
+  revlist = context.GetRevList()
 
   # Get a list of revisions to bisect across.
   if len(revlist) < 2:  # Don't have enough builds to bisect.
@@ -930,7 +815,7 @@
     # On that basis, kill one of the background downloads and complete the
     # other, as described in the comments above.
     try:
-      answer = evaluate(rev, context.is_official, exit_status, stdout, stderr)
+      answer = evaluate(rev, exit_status, stdout, stderr)
       if ((answer == 'g' and good_rev < bad_rev)
           or (answer == 'b' and bad_rev < good_rev)):
         fetch.Stop()
@@ -1111,7 +996,6 @@
            'the bad one.\n'
            '\n'
            'Revision numbers should use\n'
-           '  Official versions (e.g. 1.0.1000.0) for official builds. (-o)\n'
            '  SVN revisions (e.g. 123456) for chromium builds, from trunk.\n'
            '    Use base_trunk_revision from http://omahaproxy.appspot.com/\n'
            '    for earlier revs.\n'
@@ -1127,11 +1011,6 @@
                     choices=choices,
                     help='The buildbot archive to bisect [%s].' %
                          '|'.join(choices))
-  parser.add_option('-o',
-                    action='store_true',
-                    dest='official_builds',
-                    help='Bisect across official Chrome builds (internal '
-                         'only) instead of Chromium archives.')
   parser.add_option('-b', '--bad',
                     type='str',
                     help='A bad revision to start bisection. '
@@ -1207,9 +1086,6 @@
       print 'Error: ASAN bisecting only supported on these platforms: [%s].' % (
             '|'.join(supported_platforms))
       return 1
-    if opts.official_builds:
-      print 'Error: Do not yet support bisecting official ASAN builds.'
-      return 1
 
   if opts.asan:
     base_url = ASAN_BASE_URL
@@ -1220,7 +1096,7 @@
 
   # Create the context. Initialize 0 for the revisions as they are set below.
   context = PathContext(base_url, opts.archive, opts.good, opts.bad,
-                        opts.official_builds, opts.asan, opts.use_local_cache,
+                        opts.asan, opts.use_local_cache,
                         opts.flash_path)
 
   # Pick a starting point, try to get HEAD for this.
@@ -1231,18 +1107,14 @@
 
   # Find out when we were good.
   if not opts.good:
-    context.good_revision = '0.0.0.0' if opts.official_builds else 0
+    context.good_revision = 0
 
   if opts.flash_path:
     msg = 'Could not find Flash binary at %s' % opts.flash_path
     assert os.path.exists(opts.flash_path), msg
 
-  if opts.official_builds:
-    context.good_revision = LooseVersion(context.good_revision)
-    context.bad_revision = LooseVersion(context.bad_revision)
-  else:
-    context.good_revision = int(context.good_revision)
-    context.bad_revision = int(context.bad_revision)
+  context.good_revision = int(context.good_revision)
+  context.bad_revision = int(context.bad_revision)
 
   if opts.times < 1:
     print('Number of times to run (%d) must be greater than or equal to 1.' %
@@ -1299,10 +1171,7 @@
              'you might also want to do a Blink bisect.')
 
     print 'CHANGELOG URL:'
-    if opts.official_builds:
-      print OFFICIAL_CHANGELOG_URL % (min_chromium_rev, max_chromium_rev)
-    else:
-      PrintChangeLog(min_chromium_rev, max_chromium_rev)
+    PrintChangeLog(min_chromium_rev, max_chromium_rev)
 
 
 if __name__ == '__main__':