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 | 8 |
9 from . import bisect_utils | 9 from . import bisect_utils |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 svn_revision = int(revision_to_check) | 147 svn_revision = int(revision_to_check) |
148 git_revision = None | 148 git_revision = None |
149 | 149 |
150 if search > 0: | 150 if search > 0: |
151 search_range = xrange(svn_revision, svn_revision + search, 1) | 151 search_range = xrange(svn_revision, svn_revision + search, 1) |
152 else: | 152 else: |
153 search_range = xrange(svn_revision, svn_revision + search, -1) | 153 search_range = xrange(svn_revision, svn_revision + search, -1) |
154 | 154 |
155 for i in search_range: | 155 for i in search_range: |
156 svn_pattern = 'git-svn-id: %s@%d' % (depot_svn, i) | 156 svn_pattern = 'git-svn-id: %s@%d' % (depot_svn, i) |
157 commit_position_pattern = 'Cr-Commit-Position: .*@{#%d}' % i | 157 commit_position_pattern = '^Cr-Commit-Position: .*@{#%d}' % i |
158 cmd = ['log', '--format=%H', '-1', '--grep', svn_pattern, | 158 cmd = ['log', '--format=%H', '-1', '--grep', svn_pattern, |
159 '--grep', commit_position_pattern, 'origin/master'] | 159 '--grep', commit_position_pattern, 'origin/master'] |
160 | 160 |
161 (log_output, return_code) = bisect_utils.RunGit(cmd, cwd=cwd) | 161 (log_output, return_code) = bisect_utils.RunGit(cmd, cwd=cwd) |
162 | 162 |
163 assert not return_code, 'An error occurred while running'\ | 163 assert not return_code, 'An error occurred while running'\ |
164 ' "git %s"' % ' '.join(cmd) | 164 ' "git %s"' % ' '.join(cmd) |
165 | 165 |
166 if not return_code: | 166 if not return_code: |
167 log_output = log_output.strip() | 167 log_output = log_output.strip() |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 revision_end: End of revision range. | 285 revision_end: End of revision range. |
286 | 286 |
287 Returns: | 287 Returns: |
288 Returns a list of commits that touched this file. | 288 Returns a list of commits that touched this file. |
289 """ | 289 """ |
290 cmd = ['log', '--format=%H', '%s~1..%s' % (revision_start, revision_end), | 290 cmd = ['log', '--format=%H', '%s~1..%s' % (revision_start, revision_end), |
291 '--', filename] | 291 '--', filename] |
292 output = bisect_utils.CheckRunGit(cmd) | 292 output = bisect_utils.CheckRunGit(cmd) |
293 | 293 |
294 return [o for o in output.split('\n') if o] | 294 return [o for o in output.split('\n') if o] |
OLD | NEW |