| Index: gclient_scm.py
|
| diff --git a/gclient_scm.py b/gclient_scm.py
|
| index 0389f466203b86413e0253ab9095d4cd422fe8ad..fd4b23fa631dffeb5e3e5768c6fbf463f777fce0 100644
|
| --- a/gclient_scm.py
|
| +++ b/gclient_scm.py
|
| @@ -302,9 +302,7 @@ class GitWrapper(SCMWrapper):
|
| # hash is also a tag, only make a distinction at checkout
|
| rev_type = "hash"
|
|
|
| - if (not os.path.exists(self.checkout_path) or
|
| - (os.path.isdir(self.checkout_path) and
|
| - not os.path.exists(os.path.join(self.checkout_path, '.git')))):
|
| + if (not os.path.exists(self.checkout_path)):
|
| self._Clone(revision, url, options)
|
| self.UpdateSubmoduleConfig()
|
| if file_list is not None:
|
| @@ -323,12 +321,29 @@ class GitWrapper(SCMWrapper):
|
| return self._Capture(['rev-parse', '--verify', 'HEAD'])
|
|
|
| if not os.path.exists(os.path.join(self.checkout_path, '.git')):
|
| - raise gclient_utils.Error('\n____ %s%s\n'
|
| - '\tPath is not a git repo. No .git dir.\n'
|
| - '\tTo resolve:\n'
|
| - '\t\trm -rf %s\n'
|
| - '\tAnd run gclient sync again\n'
|
| - % (self.relpath, rev_str, self.relpath))
|
| + if options.force:
|
| + # Delete and re-sync.
|
| + print('_____ Conflicting directory found in %s. Removing.'
|
| + % self.checkout_path)
|
| + gclient_utils.rmtree(self.checkout_path)
|
| + self._Clone(revision, url, options)
|
| + self.UpdateSubmoduleConfig()
|
| + if file_list is not None:
|
| + files = self._Capture(['ls-files']).splitlines()
|
| + file_list.extend([os.path.join(self.checkout_path, f) for f in files])
|
| + if not verbose:
|
| + # Make the output a little prettier. It's nice to have some whitespace
|
| + # between projects when cloning.
|
| + print('')
|
| + return self._Capture(['rev-parse', '--verify', 'HEAD'])
|
| + else:
|
| + raise gclient_utils.Error('\n____ %s%s\n'
|
| + '\tPath is not a git repo. No .git dir.\n'
|
| + '\tTo resolve:\n'
|
| + '\t\trm -rf %s\n'
|
| + '\tAnd run gclient sync again\n'
|
| + '\tOr run with --force\n'
|
| + % (self.relpath, rev_str, self.relpath))
|
|
|
| # See if the url has changed (the unittests use git://foo for the url, let
|
| # that through).
|
| @@ -1104,12 +1119,7 @@ class SVNWrapper(SCMWrapper):
|
| Raises:
|
| Error: if can't get URL for relative path.
|
| """
|
| - # Only update if git or hg is not controlling the directory.
|
| - git_path = os.path.join(self.checkout_path, '.git')
|
| - if os.path.exists(git_path):
|
| - print('________ found .git directory; skipping %s' % self.relpath)
|
| - return
|
| -
|
| + # Only update if hg is not controlling the directory.
|
| hg_path = os.path.join(self.checkout_path, '.hg')
|
| if os.path.exists(hg_path):
|
| print('________ found .hg directory; skipping %s' % self.relpath)
|
| @@ -1140,9 +1150,29 @@ class SVNWrapper(SCMWrapper):
|
| forced_revision = False
|
| rev_str = ''
|
|
|
| - # Get the existing scm url and the revision number of the current checkout.
|
| exists = os.path.exists(self.checkout_path)
|
| if exists and managed:
|
| + # Git is only okay if it's a git-svn checkout of the right repo.
|
| + if scm.GIT.IsGit(self.checkout_path):
|
| + if scm.GIT.IsGitSvn(self.checkout_path):
|
| + remote_url = scm.GIT.Capture(['config', '--local', '--get',
|
| + 'svn-remote.svn.url'],
|
| + cwd=self.checkout_path).rstrip()
|
| + if remote_url == base_url:
|
| + print('\n_____ %s looks like a git-svn checkout. Skipping.'
|
| + % self.relpath)
|
| + return # TODO(borenet): Get the svn revision number?
|
| +
|
| + if not options.force and not options.reset:
|
| + raise gclient_utils.Error(
|
| + '%s contains a git checkout. Delete the directory and try again.'
|
| + % self.checkout_path)
|
| + else:
|
| + gclient_utils.rmtree(self.checkout_path)
|
| + exists = False
|
| +
|
| + # Get the existing scm url and the revision number of the current checkout.
|
| + if exists and managed:
|
| try:
|
| from_info = scm.SVN.CaptureLocalInfo(
|
| [], os.path.join(self.checkout_path, '.'))
|
|
|