| 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 re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 if not os.path.exists(self.checkout_path): | 129 if not os.path.exists(self.checkout_path): |
| 130 self._Run(['clone', url, self.checkout_path], | 130 self._Run(['clone', url, self.checkout_path], |
| 131 cwd=self._root_dir, redirect_stdout=False) | 131 cwd=self._root_dir, redirect_stdout=False) |
| 132 if revision: | 132 if revision: |
| 133 self._Run(['reset', '--hard', revision], redirect_stdout=False) | 133 self._Run(['reset', '--hard', revision], redirect_stdout=False) |
| 134 files = self._Run(['ls-files']).split() | 134 files = self._Run(['ls-files']).split() |
| 135 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 135 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 136 return | 136 return |
| 137 | 137 |
| 138 self._Run(['remote', 'update'], redirect_stdout=False) | |
| 139 new_base = 'origin' | 138 new_base = 'origin' |
| 140 if revision: | 139 if revision: |
| 141 new_base = revision | 140 new_base = revision |
| 141 cur_branch = self._Run(['symbolic-ref', 'HEAD']).split('/')[-1] |
| 142 merge_base = self._Run(['merge-base', 'HEAD', new_base]) |
| 143 self._Run(['remote', 'update'], redirect_stdout=False) |
| 142 files = self._Run(['diff', new_base, '--name-only']).split() | 144 files = self._Run(['diff', new_base, '--name-only']).split() |
| 143 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 145 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 144 self._Run(['rebase', '-v', new_base], redirect_stdout=False) | 146 self._Run(['rebase', '-v', '--onto', new_base, merge_base, cur_branch], |
| 147 redirect_stdout=False) |
| 145 print "Checked out revision %s." % self.revinfo(options, (), None) | 148 print "Checked out revision %s." % self.revinfo(options, (), None) |
| 146 | 149 |
| 147 def revert(self, options, args, file_list): | 150 def revert(self, options, args, file_list): |
| 148 """Reverts local modifications. | 151 """Reverts local modifications. |
| 149 | 152 |
| 150 All reverted files will be appended to file_list. | 153 All reverted files will be appended to file_list. |
| 151 """ | 154 """ |
| 152 __pychecker__ = 'unusednames=args' | 155 __pychecker__ = 'unusednames=args' |
| 153 path = os.path.join(self._root_dir, self.relpath) | 156 path = os.path.join(self._root_dir, self.relpath) |
| 154 if not os.path.isdir(path): | 157 if not os.path.isdir(path): |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 self.ReplaceAndPrint(line) | 458 self.ReplaceAndPrint(line) |
| 456 else: | 459 else: |
| 457 if (line.startswith(self.original_prefix) or | 460 if (line.startswith(self.original_prefix) or |
| 458 line.startswith(self.working_prefix)): | 461 line.startswith(self.working_prefix)): |
| 459 self.ReplaceAndPrint(line) | 462 self.ReplaceAndPrint(line) |
| 460 else: | 463 else: |
| 461 print line | 464 print line |
| 462 | 465 |
| 463 filterer = DiffFilterer(self.relpath) | 466 filterer = DiffFilterer(self.relpath) |
| 464 self.RunAndFilterOutput(command, path, False, False, filterer.Filter) | 467 self.RunAndFilterOutput(command, path, False, False, filterer.Filter) |
| OLD | NEW |