Commit f237063d authored by msb@chromium.org's avatar msb@chromium.org

gclient: handle case for upstream has rebased

gclient sync will potentially fail if the upstream git tree has been rebased.
This CL fixes this by using rebase --onto to only rebase our local changes.

Review URL: http://codereview.chromium.org/432017

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@33011 0039d316-1c4b-4281-b951-d872f2087c98
parent 3884d769
......@@ -135,13 +135,16 @@ class GitWrapper(SCMWrapper, scm.GIT):
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
return
self._Run(['remote', 'update'], redirect_stdout=False)
new_base = 'origin'
if revision:
new_base = revision
cur_branch = self._Run(['symbolic-ref', 'HEAD']).split('/')[-1]
merge_base = self._Run(['merge-base', 'HEAD', new_base])
self._Run(['remote', 'update'], redirect_stdout=False)
files = self._Run(['diff', new_base, '--name-only']).split()
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
self._Run(['rebase', '-v', new_base], redirect_stdout=False)
self._Run(['rebase', '-v', '--onto', new_base, merge_base, cur_branch],
redirect_stdout=False)
print "Checked out revision %s." % self.revinfo(options, (), None)
def revert(self, options, args, file_list):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment