diff options
| author | Raman Tenneti <rtenneti@google.com> | 2021-05-02 19:47:29 -0700 |
|---|---|---|
| committer | Raman Tenneti <rtenneti@google.com> | 2021-05-03 05:13:23 +0000 |
| commit | feb28914bd17aacc2d251516e504a33f991f86c4 (patch) | |
| tree | 66865f9cb25d6134acb02e63502636c366a963cd /subcmds | |
| parent | d1f3e149df4482ee24feee038c88df32fbc77380 (diff) | |
| download | git-repo-feb28914bd17aacc2d251516e504a33f991f86c4.tar.gz | |
superproject: Don't update the commit ids of projects if remote is different.
1) Skip setting the revision id (commit id) for the projects whose
remote doesn't match superproject's remote.
2) exp-superproject/superproject_override.xml includes local_manfiest's
projects. When we load this XML, don't reload projects from local.xml
(otherwise we will get duplicate projects errors).
Tested the code with the following commands.
$ ./run_tests -v
+ Test with local.xml
$ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --use-superproject --partial-clone --clone-filter=blob:limit=10M && mkdir -p .repo/local_manifests && (gcertstatus -quiet=true || gcert) && ln -s /google/src/head/depot/google3/wireless/android/build_tools/aosp/manifests/mirror-aosp-master-with-vendor/local.xml .repo/local_manifests/local.xml
$ repo_dev sync -c -j8
+ Test without local.xml
$ 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
$ repo_dev sync -c -j8
Bug: [google internal] b/186395810
Change-Id: I4e9d4ac2d94a9fc0cef0ccd787b6310758009e86
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/304882
Tested-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 0c386add..9f8de9e5 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -277,7 +277,7 @@ later is required to fix a server side protocol bug. | |||
| 277 | """Returns True if current-branch or use-superproject options are enabled.""" | 277 | """Returns True if current-branch or use-superproject options are enabled.""" |
| 278 | return opt.current_branch_only or self._UseSuperproject(opt) | 278 | return opt.current_branch_only or self._UseSuperproject(opt) |
| 279 | 279 | ||
| 280 | def _UpdateProjectsRevisionId(self, opt, args): | 280 | def _UpdateProjectsRevisionId(self, opt, args, load_local_manifests): |
| 281 | """Update revisionId of every project with the SHA from superproject. | 281 | """Update revisionId of every project with the SHA from superproject. |
| 282 | 282 | ||
| 283 | This function updates each project's revisionId with SHA from superproject. | 283 | This function updates each project's revisionId with SHA from superproject. |
| @@ -287,6 +287,7 @@ later is required to fix a server side protocol bug. | |||
| 287 | opt: Program options returned from optparse. See _Options(). | 287 | opt: Program options returned from optparse. See _Options(). |
| 288 | args: Arguments to pass to GetProjects. See the GetProjects | 288 | args: Arguments to pass to GetProjects. See the GetProjects |
| 289 | docstring for details. | 289 | docstring for details. |
| 290 | load_local_manifests: Whether to load local manifests. | ||
| 290 | 291 | ||
| 291 | Returns: | 292 | Returns: |
| 292 | Returns path to the overriding manifest file. | 293 | Returns path to the overriding manifest file. |
| @@ -302,7 +303,7 @@ later is required to fix a server side protocol bug. | |||
| 302 | print('error: Update of revsionId from superproject has failed', | 303 | print('error: Update of revsionId from superproject has failed', |
| 303 | file=sys.stderr) | 304 | file=sys.stderr) |
| 304 | sys.exit(1) | 305 | sys.exit(1) |
| 305 | self._ReloadManifest(manifest_path) | 306 | self._ReloadManifest(manifest_path, load_local_manifests) |
| 306 | return manifest_path | 307 | return manifest_path |
| 307 | 308 | ||
| 308 | def _FetchProjectList(self, opt, projects): | 309 | def _FetchProjectList(self, opt, projects): |
| @@ -565,10 +566,18 @@ later is required to fix a server side protocol bug. | |||
| 565 | t.join() | 566 | t.join() |
| 566 | pm.end() | 567 | pm.end() |
| 567 | 568 | ||
| 568 | def _ReloadManifest(self, manifest_name=None): | 569 | def _ReloadManifest(self, manifest_name=None, load_local_manifests=True): |
| 570 | """Reload the manfiest from the file specified by the |manifest_name|. | ||
| 571 | |||
| 572 | It unloads the manifest if |manifest_name| is None. | ||
| 573 | |||
| 574 | Args: | ||
| 575 | manifest_name: Manifest file to be reloaded. | ||
| 576 | load_local_manifests: Whether to load local manifests. | ||
| 577 | """ | ||
| 569 | if manifest_name: | 578 | if manifest_name: |
| 570 | # Override calls _Unload already | 579 | # Override calls _Unload already |
| 571 | self.manifest.Override(manifest_name) | 580 | self.manifest.Override(manifest_name, load_local_manifests=load_local_manifests) |
| 572 | else: | 581 | else: |
| 573 | self.manifest._Unload() | 582 | self.manifest._Unload() |
| 574 | 583 | ||
| @@ -857,8 +866,9 @@ later is required to fix a server side protocol bug. | |||
| 857 | else: | 866 | else: |
| 858 | self._UpdateManifestProject(opt, mp, manifest_name) | 867 | self._UpdateManifestProject(opt, mp, manifest_name) |
| 859 | 868 | ||
| 869 | load_local_manifests = not self.manifest.HasLocalManifests | ||
| 860 | if self._UseSuperproject(opt): | 870 | if self._UseSuperproject(opt): |
| 861 | manifest_name = self._UpdateProjectsRevisionId(opt, args) | 871 | manifest_name = self._UpdateProjectsRevisionId(opt, args, load_local_manifests) |
| 862 | 872 | ||
| 863 | if self.gitc_manifest: | 873 | if self.gitc_manifest: |
| 864 | gitc_manifest_projects = self.GetProjects(args, | 874 | gitc_manifest_projects = self.GetProjects(args, |
| @@ -926,7 +936,7 @@ later is required to fix a server side protocol bug. | |||
| 926 | # Iteratively fetch missing and/or nested unregistered submodules | 936 | # Iteratively fetch missing and/or nested unregistered submodules |
| 927 | previously_missing_set = set() | 937 | previously_missing_set = set() |
| 928 | while True: | 938 | while True: |
| 929 | self._ReloadManifest(manifest_name) | 939 | self._ReloadManifest(manifest_name, load_local_manifests) |
| 930 | all_projects = self.GetProjects(args, | 940 | all_projects = self.GetProjects(args, |
| 931 | missing_ok=True, | 941 | missing_ok=True, |
| 932 | submodules_ok=opt.fetch_submodules) | 942 | submodules_ok=opt.fetch_submodules) |
