| 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 10 matching lines...) Expand all Loading... |
| 21 is unsupported. | 21 is unsupported. |
| 22 """ | 22 """ |
| 23 (output, _) = bisect_utils.RunGit(['rev-parse', '--is-inside-work-tree']) | 23 (output, _) = bisect_utils.RunGit(['rev-parse', '--is-inside-work-tree']) |
| 24 | 24 |
| 25 if output.strip() == 'true': | 25 if output.strip() == 'true': |
| 26 return GitSourceControl(opts) | 26 return GitSourceControl(opts) |
| 27 | 27 |
| 28 return None | 28 return None |
| 29 | 29 |
| 30 | 30 |
| 31 # TODO(qyearsley): Almost all of the methods below could be top-level functions |
| 32 # (or class methods). Refactoring may make this simpler. |
| 33 # pylint: disable=R0201 |
| 31 class SourceControl(object): | 34 class SourceControl(object): |
| 32 """SourceControl is an abstraction over the source control system.""" | 35 """SourceControl is an abstraction over the source control system.""" |
| 33 | 36 |
| 34 def __init__(self): | 37 def __init__(self): |
| 35 super(SourceControl, self).__init__() | 38 super(SourceControl, self).__init__() |
| 36 | 39 |
| 37 def SyncToRevisionWithGClient(self, revision): | 40 def SyncToRevisionWithGClient(self, revision): |
| 38 """Uses gclient to sync to the specified revision. | 41 """Uses gclient to sync to the specified revision. |
| 39 | 42 |
| 40 This is like running gclient sync --revision <revision>. | 43 This is like running gclient sync --revision <revision>. |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 revision_end: End of revision range. | 301 revision_end: End of revision range. |
| 299 | 302 |
| 300 Returns: | 303 Returns: |
| 301 Returns a list of commits that touched this file. | 304 Returns a list of commits that touched this file. |
| 302 """ | 305 """ |
| 303 cmd = ['log', '--format=%H', '%s~1..%s' % (revision_start, revision_end), | 306 cmd = ['log', '--format=%H', '%s~1..%s' % (revision_start, revision_end), |
| 304 '--', filename] | 307 '--', filename] |
| 305 output = bisect_utils.CheckRunGit(cmd) | 308 output = bisect_utils.CheckRunGit(cmd) |
| 306 | 309 |
| 307 return [o for o in output.split('\n') if o] | 310 return [o for o in output.split('\n') if o] |
| OLD | NEW |