From 617a1617cff80653d989ffbba597d843d3728a35 Mon Sep 17 00:00:00 2001 From: "szager@chromium.org" Date: Mon, 16 Jun 2014 23:12:28 +0000 Subject: [PATCH] If managed=False, don't fetch. This is an issue when bot_update.py is used, and a top-level solution takes a long time to fetch. Without this change, it will be fetched twice. managed=False really means 'hands off my checkout', so gclient should honor that. R=hinoka@chromium.org,agable@chromium.org BUG= Review URL: https://codereview.chromium.org/334343002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@277565 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 12 +++++--- tests/gclient_scm_test.py | 65 +++++++++++++++------------------------ 2 files changed, 32 insertions(+), 45 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index 26d96585c..1b50abee9 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -356,6 +356,13 @@ class GitWrapper(SCMWrapper): verbose = ['--verbose'] printed_path = True + if not managed: + self.Print('________ unmanaged solution; skipping %s' % self.relpath) + try: + return self._Capture(['rev-parse', '--verify', 'HEAD']) + except subprocess2.CalledProcessError: + return None + url = self._CreateOrUpdateCache(url, options) if revision.startswith('refs/'): @@ -389,11 +396,6 @@ class GitWrapper(SCMWrapper): self.Print('') return self._Capture(['rev-parse', '--verify', 'HEAD']) - if not managed: - self._UpdateBranchHeads(options, fetch=False) - self.Print('________ unmanaged solution; skipping %s' % self.relpath) - return self._Capture(['rev-parse', '--verify', 'HEAD']) - # 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]) diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 0341229c3..f2d35eacb 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -1413,19 +1413,17 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): root_dir=self.root_dir, relpath=self.relpath) - expected_file_list = [join(self.base_path, "a"), - join(self.base_path, "b")] file_list = [] options.revision = 'unmanaged' scm.update(options, (), file_list) - self.assertEquals(file_list, expected_file_list) - self.assertEquals(scm.revinfo(options, (), None), - '069c602044c5388d2d15c3f875b057c852003458') + self.assertEquals(file_list, []) + self.assertRaises(subprocess2.CalledProcessError, + scm.revinfo, options, (), None) + # indicates detached HEAD - self.assertEquals(self.getCurrentBranch(), None) - self.checkInStdout( - 'Checked out refs/remotes/origin/master to a detached HEAD') + self.assertRaises(subprocess2.CalledProcessError, self.getCurrentBranch) + self.checkInStdout('unmanaged solution; skipping') rmtree(origin_root_dir) @@ -1445,19 +1443,16 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): root_dir=self.root_dir, relpath=self.relpath) - expected_file_list = [join(self.base_path, "a"), - join(self.base_path, "b")] file_list = [] options.revision = 'unmanaged' scm.update(options, (), file_list) - self.assertEquals(file_list, expected_file_list) - self.assertEquals(scm.revinfo(options, (), None), - 'a7142dc9f0009350b96a11f372b6ea658592aa95') + self.assertEquals(file_list, []) + self.assertRaises(subprocess2.CalledProcessError, + scm.revinfo, options, (), None) # indicates detached HEAD - self.assertEquals(self.getCurrentBranch(), None) - self.checkInStdout( - 'Checked out a7142dc9f0009350b96a11f372b6ea658592aa95 to a detached HEAD') + self.assertRaises(subprocess2.CalledProcessError, self.getCurrentBranch) + self.checkInStdout('unmanaged solution; skipping') rmtree(origin_root_dir) @@ -1476,17 +1471,14 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): root_dir=self.root_dir, relpath=self.relpath) - expected_file_list = [join(self.base_path, "a"), - join(self.base_path, "b"), - join(self.base_path, "c")] file_list = [] options.revision = 'unmanaged' scm.update(options, (), file_list) - self.assertEquals(file_list, expected_file_list) - self.assertEquals(scm.revinfo(options, (), None), - '9a51244740b25fa2ded5252ca00a3178d3f665a9') - self.assertEquals(self.getCurrentBranch(), 'feature') + self.assertEquals(file_list, []) + self.assertRaises(subprocess2.CalledProcessError, + scm.revinfo, options, (), None) + self.assertRaises(subprocess2.CalledProcessError, self.getCurrentBranch) self.checkNotInStdout('Checked out feature to a detached HEAD') rmtree(origin_root_dir) @@ -1506,20 +1498,16 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): root_dir=self.root_dir, relpath=self.relpath) - expected_file_list = [join(self.base_path, "a"), - join(self.base_path, "b"), - join(self.base_path, "c")] file_list = [] options.revision = 'unmanaged' - scm.update(options, (), file_list) + scm.update(options, (), []) - self.assertEquals(file_list, expected_file_list) - self.assertEquals(scm.revinfo(options, (), None), - '9a51244740b25fa2ded5252ca00a3178d3f665a9') + self.assertEquals(file_list, []) + self.assertRaises(subprocess2.CalledProcessError, + scm.revinfo, options, (), None) # indicates detached HEAD - self.assertEquals(self.getCurrentBranch(), None) - self.checkInStdout( - 'Checked out refs/remotes/origin/feature to a detached HEAD') + self.assertRaises(subprocess2.CalledProcessError, self.getCurrentBranch) + self.checkInStdout('unmanaged solution; skipping') rmtree(origin_root_dir) @@ -1538,17 +1526,14 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): root_dir=self.root_dir, relpath=self.relpath) - expected_file_list = [join(self.base_path, "a"), - join(self.base_path, "b"), - join(self.base_path, "c")] file_list = [] options.revision = 'unmanaged' scm.update(options, (), file_list) - self.assertEquals(file_list, expected_file_list) - self.assertEquals(scm.revinfo(options, (), None), - '9a51244740b25fa2ded5252ca00a3178d3f665a9') - self.assertEquals(self.getCurrentBranch(), 'feature') + self.assertEquals(file_list, []) + self.assertRaises(subprocess2.CalledProcessError, + scm.revinfo, options, (), None) + self.assertRaises(subprocess2.CalledProcessError, self.getCurrentBranch) self.checkNotInStdout( 'Checked out refs/heads/feature to a detached HEAD')