From 668667c0b9274adf93808def41665da52acef642 Mon Sep 17 00:00:00 2001 From: "thomasvl@chromium.org" Date: Thu, 24 Mar 2011 18:27:24 +0000 Subject: [PATCH] Move where the check is to handle things not being checked out yet. Review URL: http://codereview.chromium.org/6676119 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79301 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index 0bb3644013..bd4eb731ed 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -186,23 +186,6 @@ class GitWrapper(SCMWrapper): verbose = ['--verbose'] printed_path = True - # See if the url has changed - current_url = self._Capture(['config', 'remote.origin.url']) - if current_url != url: - print('_____ switching %s to a new upstream' % self.relpath) - # Make sure it's clean - self._CheckClean(rev_str) - # Switch over to the new upstream - self._Run(['remote', 'set-url', 'origin', url], options) - quiet = [] - if not options.verbose: - quiet = ['--quiet'] - self._Run(['fetch', 'origin', '--prune'] + quiet, options) - self._Run(['reset', '--hard', 'origin/master'] + quiet, options) - files = self._Capture(['ls-files']).splitlines() - file_list.extend([os.path.join(self.checkout_path, f) for f in files]) - return - if revision.startswith('refs/heads/'): rev_type = "branch" elif revision.startswith('origin/'): @@ -231,6 +214,23 @@ class GitWrapper(SCMWrapper): '\tAnd run gclient sync again\n' % (self.relpath, rev_str, self.relpath)) + # See if the url has changed + current_url = self._Capture(['config', 'remote.origin.url']) + if current_url != url: + print('_____ switching %s to a new upstream' % self.relpath) + # Make sure it's clean + self._CheckClean(rev_str) + # Switch over to the new upstream + self._Run(['remote', 'set-url', 'origin', url], options) + quiet = [] + if not options.verbose: + quiet = ['--quiet'] + self._Run(['fetch', 'origin', '--prune'] + quiet, options) + self._Run(['reset', '--hard', 'origin/master'] + quiet, options) + files = self._Capture(['ls-files']).splitlines() + file_list.extend([os.path.join(self.checkout_path, f) for f in files]) + return + cur_branch = self._GetCurrentBranch() # Cases: