OLD | NEW |
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2009 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 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 def _CheckMinVersion(self, min_version): | 567 def _CheckMinVersion(self, min_version): |
568 (ok, current_version) = scm.GIT.AssertVersion(min_version) | 568 (ok, current_version) = scm.GIT.AssertVersion(min_version) |
569 if not ok: | 569 if not ok: |
570 raise gclient_utils.Error('git version %s < minimum required %s' % | 570 raise gclient_utils.Error('git version %s < minimum required %s' % |
571 (current_version, min_version)) | 571 (current_version, min_version)) |
572 | 572 |
573 def _GetCurrentBranch(self): | 573 def _GetCurrentBranch(self): |
574 # Returns name of current branch | 574 # Returns name of current branch |
575 # Returns None if inside a (no branch) | 575 # Returns None if inside a (no branch) |
576 tokens = self._Run(['branch']).split() | 576 tokens = self._Run(['branch']).split() |
| 577 if not '*' in tokens: |
| 578 return None |
577 branch = tokens[tokens.index('*') + 1] | 579 branch = tokens[tokens.index('*') + 1] |
578 if branch == '(no': | 580 if branch == '(no': |
579 return None | 581 return None |
580 return branch | 582 return branch |
581 | 583 |
582 def _Run(self, args, cwd=None, redirect_stdout=True): | 584 def _Run(self, args, cwd=None, redirect_stdout=True): |
583 # TODO(maruel): Merge with Capture or better gclient_utils.CheckCall(). | 585 # TODO(maruel): Merge with Capture or better gclient_utils.CheckCall(). |
584 if cwd is None: | 586 if cwd is None: |
585 cwd = self.checkout_path | 587 cwd = self.checkout_path |
586 stdout = None | 588 stdout = None |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " | 861 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " |
860 "does not exist." | 862 "does not exist." |
861 % (' '.join(command), path)) | 863 % (' '.join(command), path)) |
862 # There's no file list to retrieve. | 864 # There's no file list to retrieve. |
863 else: | 865 else: |
864 scm.SVN.RunAndGetFileList(options, command, path, file_list) | 866 scm.SVN.RunAndGetFileList(options, command, path, file_list) |
865 | 867 |
866 def FullUrlForRelativeUrl(self, url): | 868 def FullUrlForRelativeUrl(self, url): |
867 # Find the forth '/' and strip from there. A bit hackish. | 869 # Find the forth '/' and strip from there. A bit hackish. |
868 return '/'.join(self.url.split('/')[:4]) + url | 870 return '/'.join(self.url.split('/')[:4]) + url |
OLD | NEW |