Chromium Code Reviews| Index: gclient_scm.py |
| diff --git a/gclient_scm.py b/gclient_scm.py |
| index 0389f466203b86413e0253ab9095d4cd422fe8ad..59154ae10e7bda5d8cf70ded761053095c0bfd0d 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). |
| @@ -339,7 +354,7 @@ class GitWrapper(SCMWrapper): |
| # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set. |
| # This allows devs to use experimental repos which have a different url |
| # but whose branch(s) are the same as official repos. |
| - if (current_url != url and |
| + if (current_url.rstrip('/') != url.rstrip('/') and |
|
borenet
2014/02/28 21:54:23
The smoketest was behaving incorrectly because of
|
| url != 'git://foo' and |
| subprocess2.capture( |
| ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote], |
| @@ -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): |
|
szager1
2014/02/28 22:17:52
Isn't the scm.GIT.IsGit check redundant? Can't yo
borenet
2014/03/03 18:31:11
Not quite. As written, the checkout is deleted if
szager1
2014/03/03 18:50:40
But wouldn't the next stanza take care of the pure
szager1
2014/03/03 18:54:20
Ah, I see... the next stanza relies on options.res
borenet
2014/03/03 19:14:22
Okay, I can remove everything but the early return
borenet
2014/03/03 21:09:05
Done.
|
| + 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.rstrip('/') == base_url.rstrip('/'): |
| + 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, '.')) |
| @@ -1277,7 +1307,7 @@ class SVNWrapper(SCMWrapper): |
| revision = str(from_info_live['Revision']) |
| rev_str = ' at %s' % revision |
| - if from_info['URL'] != base_url: |
| + if from_info['URL'].rstrip('/') != base_url.rstrip('/'): |
| # The repository url changed, need to switch. |
| try: |
| to_info = scm.SVN.CaptureRemoteInfo(url) |