Commit 617a1617 authored by szager@chromium.org's avatar szager@chromium.org

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
parent 301a7c3d
......@@ -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])
......
......@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment