| Index: tests/gclient_scm_test.py
|
| diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
|
| index 741727e34f69c58b42145616866fff6377fae95c..22bf53e8f6c2eb0ac38dbb6c82560e40a1fb24b1 100755
|
| --- a/tests/gclient_scm_test.py
|
| +++ b/tests/gclient_scm_test.py
|
| @@ -161,7 +161,6 @@ class SVNWrapperTestCase(BaseTestCase):
|
|
|
| def testRunCommandException(self):
|
| options = self.Options(verbose=False)
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
|
|
| self.mox.ReplayAll()
|
| @@ -182,7 +181,6 @@ class SVNWrapperTestCase(BaseTestCase):
|
| gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
|
| ).AndReturn('1.5.1')
|
| # It'll to a checkout instead.
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| # Checkout.
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(False)
|
| @@ -214,7 +212,6 @@ class SVNWrapperTestCase(BaseTestCase):
|
| gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False)
|
| # Checkout.
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(False)
|
| parent = gclient_scm.os.path.dirname(self.base_path)
|
| @@ -340,7 +337,6 @@ class SVNWrapperTestCase(BaseTestCase):
|
| file_info.url = self.url
|
| file_info.uuid = 'ABC'
|
| file_info.revision = 42
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| # Checkout.
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(False)
|
| @@ -373,8 +369,9 @@ class SVNWrapperTestCase(BaseTestCase):
|
| 'UUID': 'ABC',
|
| 'Revision': 42,
|
| }
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(False)
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
|
|
| # Checkout or update.
|
| @@ -419,8 +416,9 @@ class SVNWrapperTestCase(BaseTestCase):
|
| 'UUID': 'ABC',
|
| 'Revision': 42,
|
| }
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(False)
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
|
|
| # Checkout or update.
|
| @@ -455,8 +453,9 @@ class SVNWrapperTestCase(BaseTestCase):
|
| 'UUID': 'ABC',
|
| 'Revision': 42,
|
| }
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(False)
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
|
|
| # Checkout or update.
|
| @@ -521,8 +520,9 @@ class SVNWrapperTestCase(BaseTestCase):
|
| file_list=files_list)
|
|
|
| # Now we fall back on scm.update().
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(False)
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
| gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info)
|
| gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None
|
| @@ -591,8 +591,9 @@ class SVNWrapperTestCase(BaseTestCase):
|
| file_list=files_list)
|
|
|
| # Now we fall back on scm.update().
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(False)
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
| gclient_scm.scm.SVN._CaptureInfo(
|
| [], join(self.base_path, ".")).AndReturn(file_info)
|
| @@ -627,8 +628,9 @@ class SVNWrapperTestCase(BaseTestCase):
|
|
|
| # Now we fall back on scm.update().
|
| files_list = self.mox.CreateMockAnything()
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(False)
|
| gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
| gclient_scm.scm.SVN._CaptureInfo(
|
| [], join(self.base_path, '.')).AndReturn(file_info)
|
| @@ -646,20 +648,73 @@ class SVNWrapperTestCase(BaseTestCase):
|
|
|
| def testUpdateGit(self):
|
| options = self.Options(verbose=True)
|
| - file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
|
| - gclient_scm.os.path.exists(file_path).AndReturn(True)
|
| + file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg')
|
| + gclient_scm.os.path.exists(file_path).AndReturn(False)
|
| + gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(True)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
|
| + gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
|
| +
|
| + self.mox.ReplayAll()
|
| + scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
|
| + relpath=self.relpath)
|
| + error = ('%s contains a git checkout. Delete the directory and try again.'
|
| + % self.base_path)
|
| + self.assertRaisesError(error, scm.update, options, None, [])
|
| +
|
| + def testUpdateGitForce(self):
|
| + options = self.Options(verbose=True, force=True)
|
| + file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg')
|
| + gclient_scm.os.path.exists(file_path).AndReturn(False)
|
| + gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(True)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
|
| + gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
|
| + gclient_scm.gclient_utils.rmtree(self.base_path)
|
| + gclient_scm.os.path.exists(self.root_dir).AndReturn(True)
|
| + gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
|
| + ).AndReturn('1.5.1')
|
| + gclient_scm.scm.SVN.RunAndGetFileList(
|
| + options.verbose,
|
| + ['checkout', self.url, self.base_path, '--force', '--ignore-externals'],
|
| + cwd=self.root_dir,
|
| + file_list=[])
|
| + gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.'
|
| + ).AndReturn({'Revision': 100})
|
|
|
| self.mox.ReplayAll()
|
| scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
|
| relpath=self.relpath)
|
| file_list = []
|
| - scm.update(options, self.args, file_list)
|
| + scm.update(options, None, file_list)
|
| +
|
| + def testUpdateGitSvn(self):
|
| + options = self.Options(verbose=True)
|
| + file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg')
|
| + gclient_scm.os.path.exists(file_path).AndReturn(False)
|
| + gclient_scm.os.path.exists(self.base_path).AndReturn(True)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGit', True)
|
| + gclient_scm.scm.GIT.IsGit(self.base_path).AndReturn(True)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
|
| + gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(True)
|
| + self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True)
|
| + gclient_scm.scm.GIT.Capture(['config', '--local', '--get',
|
| + 'svn-remote.svn.url'],
|
| + cwd=self.base_path).AndReturn(self.url)
|
| +
|
| + self.mox.ReplayAll()
|
| + scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
|
| + relpath=self.relpath)
|
| + file_list = []
|
| + scm.update(options, [], file_list)
|
| self.checkstdout(
|
| - ('________ found .git directory; skipping %s\n' % self.relpath))
|
| + ('\n_____ %s looks like a git-svn checkout. Skipping.\n' % self.relpath)
|
| + )
|
|
|
| def testUpdateHg(self):
|
| options = self.Options(verbose=True)
|
| - gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
|
| gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True)
|
|
|
| self.mox.ReplayAll()
|
|
|