From d0b0a5b08cc40b7e90fe569b7d4631a31ac31aab Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Mon, 10 Mar 2014 19:30:21 +0000 Subject: [PATCH] Revert of Another attempt: gclient: delete mismatching checkouts (https://codereview.chromium.org/183283003/) Reason for revert: Broke `gclient sync` for me, failing with: Error: 1> Can't update/checkout /Volumes/MacintoshHD2/src/chrome-git/src if an unversioned directory is present. Delete the directory and try again. For someone else, it broke it with: % gclient sync ________ unmanaged solution; skipping src Error: Command svn info --xml returned non-zero exit status 1 in /Users/pawliger/chromium/src/. svn: E155007: '/Users/pawliger/chromium/src' is not a working copy Original issue's description: > Another attempt: gclient: delete mismatching checkouts > > Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=255930 TBR=iannucci@chromium.org,szager@chromium.org,maruel@chromium.org,mmoss@chromium.org,borenet@google.com NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/192323006 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@256005 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 54 ++++------- scm.py | 2 +- testing_support/fake_repos.py | 76 --------------- tests/gclient_scm_test.py | 144 +++-------------------------- tests/gclient_smoketest.py | 168 +--------------------------------- tests/scm_unittest.py | 12 --- 6 files changed, 36 insertions(+), 420 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index 151fe147b..af48b5f7f 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -300,21 +300,6 @@ class GitWrapper(SCMWrapper): 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 (os.path.isdir(self.checkout_path) and - not os.path.exists(os.path.join(self.checkout_path, '.git'))): - if options.force: - # Delete and re-sync. - print('_____ Conflicting directory found in %s. Removing.' - % self.checkout_path) - gclient_utils.rmtree(self.checkout_path) - 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)) self._Clone(revision, url, options) self.UpdateSubmoduleConfig() if file_list is not None: @@ -332,6 +317,14 @@ class GitWrapper(SCMWrapper): print ('________ unmanaged solution; skipping %s' % self.relpath) 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)) + # See if the url has changed (the unittests use git://foo for the url, let # that through). current_url = self._Capture(['config', 'remote.%s.url' % self.remote]) @@ -341,7 +334,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.rstrip('/') != url.rstrip('/') and + if (current_url != url and url != 'git://foo' and subprocess2.capture( ['git', 'config', 'remote.%s.gclient-auto-fix-url' % self.remote], @@ -1006,7 +999,12 @@ class SVNWrapper(SCMWrapper): Raises: Error: if can't get URL for relative path. """ - # Only update if hg is not controlling the directory. + # 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 + hg_path = os.path.join(self.checkout_path, '.hg') if os.path.exists(hg_path): print('________ found .hg directory; skipping %s' % self.relpath) @@ -1037,26 +1035,14 @@ class SVNWrapper(SCMWrapper): forced_revision = False rev_str = '' - 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.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? - # Get the existing scm url and the revision number of the current checkout. + exists = os.path.exists(self.checkout_path) if exists and managed: try: from_info = scm.SVN.CaptureLocalInfo( [], os.path.join(self.checkout_path, '.')) except (gclient_utils.Error, subprocess2.CalledProcessError): - if (options.force or - (options.reset and options.delete_unversioned_trees)): + if options.reset and options.delete_unversioned_trees: print 'Removing troublesome path %s' % self.checkout_path gclient_utils.rmtree(self.checkout_path) exists = False @@ -1143,9 +1129,7 @@ class SVNWrapper(SCMWrapper): if not managed: print ('________ unmanaged solution; skipping %s' % self.relpath) - if not scm.GIT.IsGitSvn(self.checkout_path): - return self.Svnversion() - return + return self.Svnversion() if 'URL' not in from_info: raise gclient_utils.Error( @@ -1188,7 +1172,7 @@ class SVNWrapper(SCMWrapper): revision = str(from_info_live['Revision']) rev_str = ' at %s' % revision - if from_info['URL'].rstrip('/') != base_url.rstrip('/'): + if from_info['URL'] != base_url: # The repository url changed, need to switch. try: to_info = scm.SVN.CaptureRemoteInfo(url) diff --git a/scm.py b/scm.py index 132958b6b..30bb3d17e 100644 --- a/scm.py +++ b/scm.py @@ -167,7 +167,7 @@ class GIT(object): @staticmethod def IsGitSvn(cwd): - """Returns True if this repo looks like it's using git-svn.""" + """Returns true if this repo looks like it's using git-svn.""" # If you have any "svn-remote.*" config keys, we think you're using svn. try: GIT.Capture(['config', '--local', '--get-regexp', r'^svn-remote\.'], diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py index 25e3a9be1..8a5cf6be0 100755 --- a/testing_support/fake_repos.py +++ b/testing_support/fake_repos.py @@ -752,82 +752,6 @@ class FakeRepoTransitive(FakeReposBase): pass -class FakeRepoSkiaDEPS(FakeReposBase): - """Simulates the Skia DEPS transition in Chrome.""" - - NB_GIT_REPOS = 5 - - DEPS_svn_pre = """deps = { - 'src/third_party/skia/gyp': '%(svn_base)sskia/gyp', - 'src/third_party/skia/include': '%(svn_base)sskia/include', - 'src/third_party/skia/src': '%(svn_base)sskia/src', -}""" - - DEPS_git_pre = """deps = { - 'src/third_party/skia/gyp': '%(git_base)srepo_3', - 'src/third_party/skia/include': '%(git_base)srepo_4', - 'src/third_party/skia/src': '%(git_base)srepo_5', -}""" - - DEPS_post = """deps = { - 'src/third_party/skia': '%(git_base)srepo_1', -}""" - - def populateSvn(self): - """Create revisions which simulate the Skia DEPS transition in Chrome.""" - subprocess2.check_call( - ['svn', 'checkout', self.svn_base, self.svn_checkout, - '-q', '--non-interactive', '--no-auth-cache', - '--username', self.USERS[0][0], '--password', self.USERS[0][1]]) - assert os.path.isdir(join(self.svn_checkout, '.svn')) - - # Skia repo. - self._commit_svn({ - 'skia/skia_base_file': 'root-level file.', - 'skia/gyp/gyp_file': 'file in the gyp directory', - 'skia/include/include_file': 'file in the include directory', - 'skia/src/src_file': 'file in the src directory', - }) - - # Chrome repo. - self._commit_svn({ - 'trunk/src/DEPS': self.DEPS_svn_pre % {'svn_base': self.svn_base}, - 'trunk/src/myfile': 'svn/trunk/src@1' - }) - self._commit_svn({ - 'trunk/src/DEPS': self.DEPS_post % {'git_base': self.git_base}, - 'trunk/src/myfile': 'svn/trunk/src@2' - }) - - def populateGit(self): - # Skia repo. - self._commit_git('repo_1', { - 'skia_base_file': 'root-level file.', - 'gyp/gyp_file': 'file in the gyp directory', - 'include/include_file': 'file in the include directory', - 'src/src_file': 'file in the src directory', - }) - self._commit_git('repo_3', { # skia/gyp - 'gyp_file': 'file in the gyp directory', - }) - self._commit_git('repo_4', { # skia/include - 'include_file': 'file in the include directory', - }) - self._commit_git('repo_5', { # skia/src - 'src_file': 'file in the src directory', - }) - - # Chrome repo. - self._commit_git('repo_2', { - 'DEPS': self.DEPS_git_pre % {'git_base': self.git_base}, - 'myfile': 'svn/trunk/src@1' - }) - self._commit_git('repo_2', { - 'DEPS': self.DEPS_post % {'git_base': self.git_base}, - 'myfile': 'svn/trunk/src@2' - }) - - class FakeReposTestBase(trial_dir.TestCase): """This is vaguely inspired by twisted.""" # Static FakeRepos instances. Lazy loaded. diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 1bb0efdcb..a0a08872e 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -135,6 +135,7 @@ 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() @@ -155,6 +156,7 @@ 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) @@ -186,6 +188,7 @@ 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) @@ -311,6 +314,7 @@ 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) @@ -343,9 +347,8 @@ 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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) gclient_scm.os.path.exists(self.base_path).AndReturn(True) # Checkout or update. @@ -390,9 +393,8 @@ 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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) gclient_scm.os.path.exists(self.base_path).AndReturn(True) # Checkout or update. @@ -427,9 +429,8 @@ 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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) gclient_scm.os.path.exists(self.base_path).AndReturn(True) # Checkout or update. @@ -494,9 +495,8 @@ 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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(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 @@ -565,9 +565,8 @@ 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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(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) @@ -602,9 +601,8 @@ 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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(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) @@ -622,75 +620,20 @@ class SVNWrapperTestCase(BaseTestCase): def testUpdateGit(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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) - error = gclient_scm.subprocess2.CalledProcessError( - 1, 'cmd', '/cwd', 'stdout', 'stderr') - gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.').AndRaise(error) - - self.mox.ReplayAll() - scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, - relpath=self.relpath) - error = ('Can\'t update/checkout %s if an unversioned directory is ' - 'present. 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, 'IsGitSvn', True) - gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) - error = gclient_scm.subprocess2.CalledProcessError( - 1, 'cmd', '/cwd', 'stdout', 'stderr') - gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.').AndRaise(error) - 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, None, file_list) - self.checkstdout('Removing troublesome path %s\n' % self.base_path) - - 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, '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) + file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') + gclient_scm.os.path.exists(file_path).AndReturn(True) 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) + scm.update(options, self.args, file_list) self.checkstdout( - ('\n_____ %s looks like a git-svn checkout. Skipping.\n' % self.relpath) - ) + ('________ found .git directory; skipping %s\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() @@ -1255,63 +1198,6 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): self.assertRaises(gclient_scm.gclient_utils.Error, git_svn_scm.GetUsableRev, too_big, options) - def testUpdateNoDotGit(self): - options = self.Options() - - gclient_scm.os.path.exists(self.base_path).AndReturn(True) - gclient_scm.os.path.isdir(self.base_path).AndReturn(True) - gclient_scm.os.path.exists(os.path.join(self.base_path, '.git') - ).AndReturn(False) - gclient_scm.os.path.isdir(self.base_path).AndReturn(True) - gclient_scm.os.path.exists(os.path.join(self.base_path, '.git') - ).AndReturn(False) - - self.mox.ReplayAll() - scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, - relpath=self.relpath) - error = ('\n____ %s at refs/remotes/origin/master\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, - self.relpath)) - self.assertRaisesError(error, scm.update, options, None, []) - - def testUpdateNoDotGitForce(self): - options = self.Options(force=True) - - gclient_scm.os.path.exists(self.base_path).AndReturn(True) - gclient_scm.os.path.isdir(self.base_path).AndReturn(True) - gclient_scm.os.path.exists(os.path.join(self.base_path, '.git') - ).AndReturn(False) - gclient_scm.os.path.isdir(self.base_path).AndReturn(True) - gclient_scm.os.path.exists(os.path.join(self.base_path, '.git') - ).AndReturn(False) - gclient_scm.gclient_utils.rmtree(self.base_path) - self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True) - # pylint: disable=E1120 - gclient_scm.GitWrapper._Clone('refs/remotes/origin/master', self.url, - options) - # pylint: disable=E1120 - self.mox.StubOutWithMock(gclient_scm.GitWrapper, 'UpdateSubmoduleConfig', - True) - gclient_scm.GitWrapper.UpdateSubmoduleConfig() - self.mox.StubOutWithMock(gclient_scm.subprocess2, 'check_output', True) - gclient_scm.subprocess2.check_output(['git', 'ls-files'], - cwd=self.base_path, - stderr=gclient_scm.subprocess2.VOID, - ).AndReturn('') - gclient_scm.subprocess2.check_output( - ['git', 'rev-parse', '--verify', 'HEAD'], - cwd=self.base_path, - stderr=gclient_scm.subprocess2.VOID, - ).AndReturn('') - - self.mox.ReplayAll() - scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, - relpath=self.relpath) - scm.update(options, None, []) - self.checkstdout('_____ Conflicting directory found in %s. Removing.\n\n' - % self.base_path) - class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): def testUpdateUpdate(self): diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index f57aaffe9..427699816 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -21,11 +21,9 @@ ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, ROOT_DIR) from testing_support.fake_repos import join, write -from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive, \ - FakeRepoSkiaDEPS +from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive import gclient_utils -import scm as gclient_scm import subprocess2 @@ -1399,170 +1397,6 @@ class GClientSmokeBoth(GClientSmokeBase): self.assertEquals(sorted(entries), sorted(expected)) -class SkiaDEPSTransitionSmokeTest(GClientSmokeBase): - """Simulate the behavior of bisect bots as they transition across the Skia - DEPS change.""" - - FAKE_REPOS_CLASS = FakeRepoSkiaDEPS - - def setUp(self): - super(SkiaDEPSTransitionSmokeTest, self).setUp() - self.enabled = self.FAKE_REPOS.set_up_git() and self.FAKE_REPOS.set_up_svn() - - def testSkiaDEPSChangeSVN(self): - if not self.enabled: - return - - # Create an initial checkout: - # - Single checkout at the root. - # - Multiple checkouts in a shared subdirectory. - self.gclient(['config', '--spec', - 'solutions=[' - '{"name": "src",' - ' "url": "' + self.svn_base + 'trunk/src/",' - '}]']) - - checkout_path = os.path.join(self.root_dir, 'src') - skia = os.path.join(checkout_path, 'third_party', 'skia') - skia_gyp = os.path.join(skia, 'gyp') - skia_include = os.path.join(skia, 'include') - skia_src = os.path.join(skia, 'src') - - gyp_svn_url = self.svn_base + 'skia/gyp' - include_svn_url = self.svn_base + 'skia/include' - src_svn_url = self.svn_base + 'skia/src' - skia_git_url = self.git_base + 'repo_1' - - # Initial sync. Verify that we get the expected checkout. - res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) - self.assertEqual(res[2], 0, 'Initial sync failed.') - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], - gyp_svn_url) - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], - include_svn_url) - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], - src_svn_url) - - # Try to sync the new DEPS. Verify that the sync fails without --force. - res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) - self.assertEquals(res[2], 1, 'New DEPS sync succeeded unexpectedly.') - - # Verify that the sync succeeds with --force. Verify that we have the - # expected merged checkout. - res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3', - '--force']) - self.assertEqual(res[2], 0, 'DEPS change sync failed with --force.') - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia), skia_git_url) - - # Sync again. Verify that we still have the expected merged checkout. - res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@3']) - self.assertEqual(res[2], 0, 'Subsequent sync failed.') - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia), skia_git_url) - - # Sync back to the original DEPS. Verify that we get the original structure. - res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2', - '--force']) - self.assertEqual(res[2], 0, 'Reverse sync failed.') - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], - gyp_svn_url) - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], - include_svn_url) - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], - src_svn_url) - - # Sync again. Verify that we still have the original structure. - res = self.gclient(['sync', '--deps', 'mac', '--revision', 'src@2']) - self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_gyp)['URL'], - gyp_svn_url) - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_include)['URL'], - include_svn_url) - self.assertEqual(gclient_scm.SVN.CaptureLocalInfo([], skia_src)['URL'], - src_svn_url) - - def testSkiaDEPSChangeGit(self): - if not self.enabled: - return - - # Create an initial checkout: - # - Single checkout at the root. - # - Multiple checkouts in a shared subdirectory. - self.gclient(['config', '--spec', - 'solutions=[' - '{"name": "src",' - ' "url": "' + self.git_base + 'repo_2",' - '}]']) - - checkout_path = os.path.join(self.root_dir, 'src') - skia = os.path.join(checkout_path, 'third_party', 'skia') - skia_gyp = os.path.join(skia, 'gyp') - skia_include = os.path.join(skia, 'include') - skia_src = os.path.join(skia, 'src') - - gyp_git_url = self.git_base + 'repo_3' - include_git_url = self.git_base + 'repo_4' - src_git_url = self.git_base + 'repo_5' - skia_git_url = self.FAKE_REPOS.git_base + 'repo_1' - - pre_hash = self.githash('repo_2', 1) - post_hash = self.githash('repo_2', 2) - - # Initial sync. Verify that we get the expected checkout. - res = self.gclient(['sync', '--deps', 'mac', '--revision', - 'src@%s' % pre_hash]) - self.assertEqual(res[2], 0, 'Initial sync failed.') - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_gyp), gyp_git_url) - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_include), include_git_url) - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_src), src_git_url) - - # Try to sync the new DEPS. Verify that the sync fails without --force. - res = self.gclient(['sync', '--deps', 'mac', '--revision', - 'src@%s' % post_hash]) - self.assertEquals(res[2], 1, 'New DEPS sync succeeded unexpectedly.') - - # Verify that the sync succeeds with --force. Verify that we have the - # expected merged checkout. - res = self.gclient(['sync', '--deps', 'mac', '--revision', - 'src@%s' % post_hash, '--force']) - self.assertEqual(res[2], 0, 'DEPS change sync failed with --force.') - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia), skia_git_url) - - # Sync again. Verify that we still have the expected merged checkout. - res = self.gclient(['sync', '--deps', 'mac', '--revision', - 'src@%s' % post_hash]) - self.assertEqual(res[2], 0, 'Subsequent sync failed.') - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia), skia_git_url) - - # Sync back to the original DEPS. Verify that we get the original structure. - res = self.gclient(['sync', '--deps', 'mac', '--revision', - 'src@%s' % pre_hash, '--force']) - self.assertEqual(res[2], 0, 'Reverse sync failed.') - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_gyp), gyp_git_url) - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_include), include_git_url) - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_src), src_git_url) - - # Sync again. Verify that we still have the original structure. - res = self.gclient(['sync', '--deps', 'mac', '--revision', - 'src@%s' % pre_hash]) - self.assertEqual(res[2], 0, 'Subsequent sync #2 failed.') - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_gyp), gyp_git_url) - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_include), include_git_url) - self.assertEqual(gclient_scm.GIT.Capture(['config', 'remote.origin.url'], - skia_src), src_git_url) - - class GClientSmokeFromCheckout(GClientSmokeBase): # WebKit abuses this. It has a .gclient and a DEPS from a checkout. def setUp(self): diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py index 2a1de5331..ff03c03e1 100755 --- a/tests/scm_unittest.py +++ b/tests/scm_unittest.py @@ -169,18 +169,6 @@ class RealGitSvnTest(fake_repos.FakeReposTestBase): self._capture(['reset', '--hard', 'HEAD^']) self.assertEquals(scm.GIT.GetGitSvnHeadRev(cwd=self.clone_dir), 1) - def testIsGitSvn(self): - if not self.enabled: - return - # Git-svn - self.assertTrue(scm.GIT.IsGitSvn(self.clone_dir)) - # Pure git - git_dir = scm.os.path.join(self.FAKE_REPOS.git_root, 'repo_1') - self.assertFalse(scm.GIT.IsGitSvn(git_dir)) - # Pure svn - svn_dir = scm.os.path.join(self.FAKE_REPOS.svn_checkout, 'trunk') - self.assertFalse(scm.GIT.IsGitSvn(svn_dir)) - def testParseGitSvnSha1(self): test_sha1 = 'a5c63ce8671922e5c59c0dea49ef4f9d4a3020c9' expected_output = test_sha1 + '\n'