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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 '\tAlready in a conflict, i.e. (no branch).\n' | 206 '\tAlready in a conflict, i.e. (no branch).\n' |
207 '\tFix the conflict and run gclient again.\n' | 207 '\tFix the conflict and run gclient again.\n' |
208 '\tOr to abort run:\n\t\tgit-rebase --abort\n' | 208 '\tOr to abort run:\n\t\tgit-rebase --abort\n' |
209 '\tSee man git-rebase for details.\n' | 209 '\tSee man git-rebase for details.\n' |
210 % (self.relpath, rev_str)) | 210 % (self.relpath, rev_str)) |
211 | 211 |
212 merge_base = self._Run(['merge-base', 'HEAD', new_base]) | 212 merge_base = self._Run(['merge-base', 'HEAD', new_base]) |
213 self._Run(['remote', 'update'], redirect_stdout=False) | 213 self._Run(['remote', 'update'], redirect_stdout=False) |
214 files = self._Run(['diff', new_base, '--name-only']).split() | 214 files = self._Run(['diff', new_base, '--name-only']).split() |
215 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 215 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 216 if options.force: |
| 217 self._Run(['reset', '--hard', merge_base], redirect_stdout=False) |
216 self._Run(['rebase', '-v', '--onto', new_base, merge_base, cur_branch], | 218 self._Run(['rebase', '-v', '--onto', new_base, merge_base, cur_branch], |
217 redirect_stdout=False, checkrc=False) | 219 redirect_stdout=False, checkrc=False) |
218 | 220 |
219 # If the rebase generated a conflict, abort and ask user to fix | 221 # If the rebase generated a conflict, abort and ask user to fix |
220 if self._GetCurrentBranch() is None: | 222 if self._GetCurrentBranch() is None: |
221 raise gclient_utils.Error('\n____ %s%s\n' | 223 raise gclient_utils.Error('\n____ %s%s\n' |
222 '\nConflict while rebasing this branch.\n' | 224 '\nConflict while rebasing this branch.\n' |
223 'Fix the conflict and run gclient again.\n' | 225 'Fix the conflict and run gclient again.\n' |
224 'See man git-rebase for details.\n' | 226 'See man git-rebase for details.\n' |
225 % (self.relpath, rev_str)) | 227 % (self.relpath, rev_str)) |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " | 549 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " |
548 "does not exist." | 550 "does not exist." |
549 % (' '.join(command), path)) | 551 % (' '.join(command), path)) |
550 # There's no file list to retrieve. | 552 # There's no file list to retrieve. |
551 else: | 553 else: |
552 self.RunAndGetFileList(options, command, path, file_list) | 554 self.RunAndGetFileList(options, command, path, file_list) |
553 | 555 |
554 def FullUrlForRelativeUrl(self, url): | 556 def FullUrlForRelativeUrl(self, url): |
555 # Find the forth '/' and strip from there. A bit hackish. | 557 # Find the forth '/' and strip from there. A bit hackish. |
556 return '/'.join(self.url.split('/')[:4]) + url | 558 return '/'.join(self.url.split('/')[:4]) + url |
OLD | NEW |