From ceba2ddc1333dbd53b559bde2b79d09d2082f3dc Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Mon, 22 Feb 2021 16:54:56 -0800 Subject: sync: superproject - support for switching hosts and switching branches. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + superproject will be fetched into a directory with the name “-superproject.git” instead of the current “superproject.git” folder. + Deleted _Clone method and added _Init method. + _Init method will do “git init --bare -superproject.git”. It will create the folder and set up a bare repository in -superproject.git folder. + _Fetch method, will pass , arguments. Moved the --filter argument from “git clone” to “git fetch”. _Fetch method will execute the following command to fetch superproject. Added --no-tags argument. master: git fetch --force --no-tags --filter blob:none branch: git fetch --force --no-tags --filter blob:none \ : + Performance improvements for aosp-master ++ repo init performance improved from 35 seconds to 17 seconds. ++ repo init --use-superproject is around 5 to 7 secsonds slower. ++ repo sync --use-superproject is around 3 to 4 minutes faster. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL. $ time repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject ... real 0m20.648s user 0m8.046s sys 0m3.271s + Without superproject $ time repo init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main real 0m13.078s user 0m9.783s sys 0m2.528s $ time repo_dev sync -c -j32 --use-superproject ... real 15m7.072s user 110m7.216s sys 20m17.559s + Without superproject $ time repo sync -c -j32 ... real 19m25.644s user 91m56.331s sys 20m59.170s Bug: [google internal] b/180492484 Bug: [google internal] b/179470886 Bug: [google internal] b/180124069 Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Change-Id: Ib04bd7f1e25ceb75532643e58ad0129300ba3299 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297702 Reviewed-by: Mike Frysinger Tested-by: Raman Tenneti --- tests/test_git_superproject.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'tests/test_git_superproject.py') diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index d2ee9f4f..07b9a7db 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -97,17 +97,17 @@ class SuperprojectTestCase(unittest.TestCase): with mock.patch.object(self._superproject, '_GetBranch', return_value='junk'): self.assertFalse(superproject.Sync()) - def test_superproject_get_superproject_mock_clone(self): - """Test with _Clone failing.""" - with mock.patch.object(self._superproject, '_Clone', return_value=False): + def test_superproject_get_superproject_mock_init(self): + """Test with _Init failing.""" + with mock.patch.object(self._superproject, '_Init', return_value=False): self.assertFalse(self._superproject.Sync()) def test_superproject_get_superproject_mock_fetch(self): - """Test with _Fetch failing and _clone being called.""" - with mock.patch.object(self._superproject, '_Clone', return_value=True): + """Test with _Fetch failing.""" + with mock.patch.object(self._superproject, '_Init', return_value=True): os.mkdir(self._superproject._superproject_path) with mock.patch.object(self._superproject, '_Fetch', return_value=False): - self.assertTrue(self._superproject.Sync()) + self.assertFalse(self._superproject.Sync()) def test_superproject_get_all_project_commit_ids_mock_ls_tree(self): """Test with LsTree being a mock.""" @@ -116,14 +116,15 @@ class SuperprojectTestCase(unittest.TestCase): '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00' '120000 blob acc2cbdf438f9d2141f0ae424cec1d8fc4b5d97f\tbootstrap.bash\x00' '160000 commit ade9b7a0d874e25fff4bf2552488825c6f111928\tbuild/bazel\x00') - with mock.patch.object(self._superproject, '_Clone', return_value=True): - with mock.patch.object(self._superproject, '_LsTree', return_value=data): - commit_ids = self._superproject._GetAllProjectsCommitIds() - self.assertEqual(commit_ids, { - 'art': '2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea', - 'bootable/recovery': 'e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06', - 'build/bazel': 'ade9b7a0d874e25fff4bf2552488825c6f111928' - }) + with mock.patch.object(self._superproject, '_Init', return_value=True): + with mock.patch.object(self._superproject, '_Fetch', return_value=True): + with mock.patch.object(self._superproject, '_LsTree', return_value=data): + commit_ids = self._superproject._GetAllProjectsCommitIds() + self.assertEqual(commit_ids, { + 'art': '2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea', + 'bootable/recovery': 'e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06', + 'build/bazel': 'ade9b7a0d874e25fff4bf2552488825c6f111928' + }) def test_superproject_write_manifest_file(self): """Test with writing manifest to a file after setting revisionId.""" @@ -151,7 +152,7 @@ class SuperprojectTestCase(unittest.TestCase): projects = self._superproject._manifest.projects data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00') - with mock.patch.object(self._superproject, '_Clone', return_value=True): + with mock.patch.object(self._superproject, '_Init', return_value=True): with mock.patch.object(self._superproject, '_Fetch', return_value=True): with mock.patch.object(self._superproject, '_LsTree', -- cgit v1.2.3-54-g00ecf