OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """This module contains the SourceControl class and related functions.""" | 5 """This module contains the SourceControl class and related functions.""" |
6 | 6 |
7 import os | 7 import os |
8 import re | 8 import re |
9 | 9 |
10 from . import bisect_utils | 10 from . import bisect_utils |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 output = bisect_utils.CheckRunGit(cmd, cwd) | 223 output = bisect_utils.CheckRunGit(cmd, cwd) |
224 svn_revision = output.strip() | 224 svn_revision = output.strip() |
225 | 225 |
226 if bisect_utils.IsStringInt(svn_revision): | 226 if bisect_utils.IsStringInt(svn_revision): |
227 return int(svn_revision) | 227 return int(svn_revision) |
228 | 228 |
229 # Retrieve commit position number from git log body for the given revision. | 229 # Retrieve commit position number from git log body for the given revision. |
230 # TODO(prasadv): Use an appropriate command to find commit position instead | 230 # TODO(prasadv): Use an appropriate command to find commit position instead |
231 # of parsing the log. Resolve this once 407316 is fixed. | 231 # of parsing the log. Resolve this once 407316 is fixed. |
232 commit_position_pattern = 'Cr-Commit-Position: .*@\{#(?P<commit>[0-9]+)\}' | 232 commit_position_pattern = 'Cr-Commit-Position: .*@\{#(?P<commit>[0-9]+)\}' |
233 cmd = ['log', '--format=%b', '-1', 'origin/master', git_revision] | 233 cmd = ['log', '--format=%b', '-1', git_revision] |
234 output = bisect_utils.CheckRunGit(cmd, cwd=cwd) | 234 output = bisect_utils.CheckRunGit(cmd, cwd=cwd) |
235 if output: | 235 if output: |
236 version_re = re.compile(commit_position_pattern) | 236 version_re = re.compile(commit_position_pattern) |
237 commit_reg = version_re.search(output) | 237 commit_reg = version_re.search(output) |
238 if commit_reg and bisect_utils.IsStringInt(commit_reg.group('commit')): | 238 if commit_reg and bisect_utils.IsStringInt(commit_reg.group('commit')): |
239 return int(commit_reg.group('commit')) | 239 return int(commit_reg.group('commit')) |
240 | 240 |
241 return None | 241 return None |
242 | 242 |
243 def QueryRevisionInfo(self, revision, cwd=None): | 243 def QueryRevisionInfo(self, revision, cwd=None): |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 revision_end: End of revision range. | 298 revision_end: End of revision range. |
299 | 299 |
300 Returns: | 300 Returns: |
301 Returns a list of commits that touched this file. | 301 Returns a list of commits that touched this file. |
302 """ | 302 """ |
303 cmd = ['log', '--format=%H', '%s~1..%s' % (revision_start, revision_end), | 303 cmd = ['log', '--format=%H', '%s~1..%s' % (revision_start, revision_end), |
304 '--', filename] | 304 '--', filename] |
305 output = bisect_utils.CheckRunGit(cmd) | 305 output = bisect_utils.CheckRunGit(cmd) |
306 | 306 |
307 return [o for o in output.split('\n') if o] | 307 return [o for o in output.split('\n') if o] |
OLD | NEW |