Chromium Code Reviews| Index: tools/bisect-builds.py |
| diff --git a/tools/bisect-builds.py b/tools/bisect-builds.py |
| index 968e9b9d6112a38b9018523da74c7deb91088c71..b639fddf22354a51c916b9c5a9cb84835422d754 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 |
| @@ -97,6 +97,7 @@ class PathContext(object): |
| # The name of the ZIP file in a revision directory on the server. |
| self.archive_name = None |
| + self.use_local_repo = use_local_repo |
|
Robert Sesek
2014/07/08 18:52:58
nit: blank line before and a comment about what th
pshenoy
2014/07/08 19:58:19
Done.
|
| # Set some internal members: |
| # _listing_platform_dir = Directory that holds revisions. Ends with a '/'. |
| @@ -253,7 +254,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 +272,45 @@ 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 = [] |
| + command.append('svn') |
|
Robert Sesek
2014/07/08 18:52:58
Why .append() these things? command = ['svn', 'fin
pshenoy
2014/07/08 19:58:19
Done.
|
| + command.append('find-rev') |
| + command.append(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 --git') |
|
Robert Sesek
2014/07/08 18:52:58
--use-local-repo
pshenoy
2014/07/08 19:58:19
Done.
|
| + sys.exit(0) |
|
Robert Sesek
2014/07/08 18:52:58
Code 1 for errors
pshenoy
2014/07/08 19:58:19
Done.
|
| + |
| + 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 +553,7 @@ def Bisect(base_url, |
| platform, |
| official_builds, |
| is_aura, |
| + use_local_repo, |
| good_rev=0, |
| bad_rev=0, |
| num_runs=1, |
| @@ -556,7 +597,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 +886,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.') |
|
Robert Sesek
2014/07/08 18:52:58
"from a Chromium checkout."
pshenoy
2014/07/08 19:58:19
Done.
|
| (opts, args) = parser.parse_args() |
| @@ -867,7 +915,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 +950,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: |