| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import re | 6 import re |
| 7 import time | 7 import time |
| 8 import urllib | 8 import urllib |
| 9 | 9 |
| 10 from . import depot_config | 10 from . import depot_config |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 Args: | 141 Args: |
| 142 rev (str): A commit hash or commit position number. | 142 rev (str): A commit hash or commit position number. |
| 143 | 143 |
| 144 Returns: | 144 Returns: |
| 145 A 40-digit git commit hash string. | 145 A 40-digit git commit hash string. |
| 146 """ | 146 """ |
| 147 if self._is_sha1(rev): # pragma: no cover | 147 if self._is_sha1(rev): # pragma: no cover |
| 148 return rev | 148 return rev |
| 149 if rev.isdigit(): | 149 if rev.isdigit(): |
| 150 commit_position = self._api.m.commit_position.construct( | 150 return self._api.m.commit_position.chromium_hash_from_commit_position(rev) |
| 151 branch='refs/heads/master', value=rev) | |
| 152 try: | |
| 153 return self._api.m.crrev.to_commit_hash(commit_position) | |
| 154 except self.api.m.step.StepFailure: # pragma: no cover | |
| 155 self.surface_result('BAD_REV') | |
| 156 raise | |
| 157 self.surface_result('BAD_REV') # pragma: no cover | 151 self.surface_result('BAD_REV') # pragma: no cover |
| 158 raise self.api.m.step.StepFailure( | 152 raise self.api.m.step.StepFailure( |
| 159 'Invalid input revision: %r' % (rev,)) # pragma: no cover | 153 'Invalid input revision: %r' % (rev,)) # pragma: no cover |
| 160 | 154 |
| 161 @staticmethod | 155 @staticmethod |
| 162 def _is_sha1(s): | 156 def _is_sha1(s): |
| 163 return bool(re.match('^[0-9A-Fa-f]{40}$', s)) | 157 return bool(re.match('^[0-9A-Fa-f]{40}$', s)) |
| 164 | 158 |
| 165 def significantly_different( | 159 def significantly_different( |
| 166 self, list_a, list_b, | 160 self, list_a, list_b, |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 }) | 848 }) |
| 855 return revision_rows | 849 return revision_rows |
| 856 | 850 |
| 857 def _get_build_url(self): | 851 def _get_build_url(self): |
| 858 properties = self.api.m.properties | 852 properties = self.api.m.properties |
| 859 bot_url = properties.get('buildbotURL', | 853 bot_url = properties.get('buildbotURL', |
| 860 'http://build.chromium.org/p/chromium/') | 854 'http://build.chromium.org/p/chromium/') |
| 861 builder_name = urllib.quote(properties.get('buildername', '')) | 855 builder_name = urllib.quote(properties.get('buildername', '')) |
| 862 builder_number = str(properties.get('buildnumber', '')) | 856 builder_number = str(properties.get('buildnumber', '')) |
| 863 return '%sbuilders/%s/builds/%s' % (bot_url, builder_name, builder_number) | 857 return '%sbuilders/%s/builds/%s' % (bot_url, builder_name, builder_number) |
| OLD | NEW |