| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 if not os.path.exists(self.checkout_path): | 181 if not os.path.exists(self.checkout_path): |
| 182 self._Run(['clone', url, self.checkout_path], | 182 self._Run(['clone', url, self.checkout_path], |
| 183 cwd=self._root_dir, redirect_stdout=False) | 183 cwd=self._root_dir, redirect_stdout=False) |
| 184 if revision: | 184 if revision: |
| 185 self._Run(['reset', '--hard', revision], redirect_stdout=False) | 185 self._Run(['reset', '--hard', revision], redirect_stdout=False) |
| 186 files = self._Run(['ls-files']).split() | 186 files = self._Run(['ls-files']).split() |
| 187 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 187 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 188 return | 188 return |
| 189 | 189 |
| 190 if not os.path.exists(os.path.join(self.checkout_path, '.git')): |
| 191 raise gclient_utils.Error('\n____ %s%s\n' |
| 192 '\tPath is not a git repo. No .git dir.\n' |
| 193 '\tTo resolve:\n' |
| 194 '\t\trm -rf %s\n' |
| 195 '\tAnd run gclient sync again\n' |
| 196 % (self.relpath, rev_str, self.relpath)) |
| 197 |
| 190 new_base = 'origin' | 198 new_base = 'origin' |
| 191 if revision: | 199 if revision: |
| 192 new_base = revision | 200 new_base = revision |
| 193 cur_branch = self._GetCurrentBranch() | 201 cur_branch = self._GetCurrentBranch() |
| 194 | 202 |
| 195 # Check if we are in a rebase conflict | 203 # Check if we are in a rebase conflict |
| 196 if cur_branch is None: | 204 if cur_branch is None: |
| 197 raise gclient_utils.Error('\n____ %s%s\n' | 205 raise gclient_utils.Error('\n____ %s%s\n' |
| 198 '\tAlready in a conflict, i.e. (no branch).\n' | 206 '\tAlready in a conflict, i.e. (no branch).\n' |
| 199 '\tFix the conflict and run gclient again.\n' | 207 '\tFix the conflict and run gclient again.\n' |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " | 547 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " |
| 540 "does not exist." | 548 "does not exist." |
| 541 % (' '.join(command), path)) | 549 % (' '.join(command), path)) |
| 542 # There's no file list to retrieve. | 550 # There's no file list to retrieve. |
| 543 else: | 551 else: |
| 544 self.RunAndGetFileList(options, command, path, file_list) | 552 self.RunAndGetFileList(options, command, path, file_list) |
| 545 | 553 |
| 546 def FullUrlForRelativeUrl(self, url): | 554 def FullUrlForRelativeUrl(self, url): |
| 547 # Find the forth '/' and strip from there. A bit hackish. | 555 # Find the forth '/' and strip from there. A bit hackish. |
| 548 return '/'.join(self.url.split('/')[:4]) + url | 556 return '/'.join(self.url.split('/')[:4]) + url |
| OLD | NEW |