summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2022-04-07 16:49:06 +0000
committerLaMont Jones <lamontjones@google.com>2022-04-08 19:52:04 +0000
commita2ff20dd209fe3eb091cdf1bddd4672f86b76bd8 (patch)
treebbddbe26a54504a9cc97d3dd67c7efedcacff2ca
parent55ee304304a0d83bfa23984c45e46eebdd184124 (diff)
downloadgit-repo-a2ff20dd209fe3eb091cdf1bddd4672f86b76bd8.tar.gz
manifest_xml: Add Load and Unload methods
- do not call the internal method from subcmds/sync.py. - use the correct default groups for submanifests. - only sync the superproject when we are told to. Change-Id: I81e4025058f1ee564732b9e17aecc522f6b5f626 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/334639 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: LaMont Jones <lamontjones@google.com>
-rw-r--r--manifest_xml.py19
-rw-r--r--project.py27
-rw-r--r--subcmds/sync.py4
3 files changed, 31 insertions, 19 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 02f09db9..8718dc54 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -376,7 +376,7 @@ class XmlManifest(object):
376 if os.path.exists(mp.gitdir) and mp.use_worktree: 376 if os.path.exists(mp.gitdir) and mp.use_worktree:
377 mp.use_git_worktrees = True 377 mp.use_git_worktrees = True
378 378
379 self._Unload() 379 self.Unload()
380 380
381 def Override(self, name, load_local_manifests=True): 381 def Override(self, name, load_local_manifests=True):
382 """Use a different manifest, just for the current instantiation. 382 """Use a different manifest, just for the current instantiation.
@@ -399,7 +399,7 @@ class XmlManifest(object):
399 try: 399 try:
400 self._load_local_manifests = load_local_manifests 400 self._load_local_manifests = load_local_manifests
401 self.manifestFile = path 401 self.manifestFile = path
402 self._Unload() 402 self.Unload()
403 self._Load() 403 self._Load()
404 finally: 404 finally:
405 self.manifestFile = old 405 self.manifestFile = old
@@ -970,7 +970,13 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
970 groups = self.GetDefaultGroupsStr() 970 groups = self.GetDefaultGroupsStr()
971 return groups 971 return groups
972 972
973 def _Unload(self): 973 def Unload(self):
974 """Unload the manifest.
975
976 If the manifest files have been changed since Load() was called, this will
977 cause the new/updated manifest to be used.
978
979 """
974 self._loaded = False 980 self._loaded = False
975 self._projects = {} 981 self._projects = {}
976 self._paths = {} 982 self._paths = {}
@@ -984,6 +990,11 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
984 self.branch = None 990 self.branch = None
985 self._manifest_server = None 991 self._manifest_server = None
986 992
993 def Load(self):
994 """Read the manifest into memory."""
995 # Do not expose internal arguments.
996 self._Load()
997
987 def _Load(self, initial_client=None, submanifest_depth=0): 998 def _Load(self, initial_client=None, submanifest_depth=0):
988 if submanifest_depth > MAX_SUBMANIFEST_DEPTH: 999 if submanifest_depth > MAX_SUBMANIFEST_DEPTH:
989 raise ManifestParseError('maximum submanifest depth %d exceeded.' % 1000 raise ManifestParseError('maximum submanifest depth %d exceeded.' %
@@ -1030,7 +1041,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
1030 except ManifestParseError as e: 1041 except ManifestParseError as e:
1031 # There was a problem parsing, unload ourselves in case they catch 1042 # There was a problem parsing, unload ourselves in case they catch
1032 # this error and try again later, we will show the correct error 1043 # this error and try again later, we will show the correct error
1033 self._Unload() 1044 self.Unload()
1034 raise e 1045 raise e
1035 1046
1036 if self.IsMirror: 1047 if self.IsMirror:
diff --git a/project.py b/project.py
index a60a8582..b8d834aa 100644
--- a/project.py
+++ b/project.py
@@ -3491,6 +3491,8 @@ class ManifestProject(MetaProject):
3491 """ 3491 """
3492 assert _kwargs_only == (), 'Sync only accepts keyword arguments.' 3492 assert _kwargs_only == (), 'Sync only accepts keyword arguments.'
3493 3493
3494 groups = groups or 'default'
3495 platform = platform or 'auto'
3494 git_event_log = git_event_log or EventLog() 3496 git_event_log = git_event_log or EventLog()
3495 if outer_manifest and self.manifest.is_submanifest: 3497 if outer_manifest and self.manifest.is_submanifest:
3496 # In a multi-manifest checkout, use the outer manifest unless we are told 3498 # In a multi-manifest checkout, use the outer manifest unless we are told
@@ -3783,19 +3785,18 @@ class ManifestProject(MetaProject):
3783 ) 3785 )
3784 3786
3785 # Lastly, clone the superproject(s). 3787 # Lastly, clone the superproject(s).
3786 if outer_manifest and not self.manifest.is_submanifest: 3788 if self.manifest.manifestProject.use_superproject:
3787 for m in self.manifest.all_manifests: 3789 sync_result = Superproject(
3788 sync_result = Superproject( 3790 self.manifest, self.manifest.repodir, git_event_log, quiet=not verbose).Sync()
3789 m, m.repodir, git_event_log, quiet=not verbose).Sync() 3791 if not sync_result.success:
3790 if not sync_result.success: 3792 print('warning: git update of superproject for '
3791 print(f'warning: git update of superproject for {m.path_prefix} failed, ' 3793 f'{self.manifest.path_prefix} failed, repo sync will not use '
3792 'repo sync will not ' 3794 'superproject to fetch source; while this error is not fatal, '
3793 'use superproject to fetch source; while this error is not fatal, ' 3795 'and you can continue to run repo sync, please run repo init '
3794 'and you can continue to run repo sync, please run repo init with ' 3796 'with the --no-use-superproject option to stop seeing this '
3795 'the --no-use-superproject option to stop seeing this warning', 3797 'warning', file=sys.stderr)
3796 file=sys.stderr) 3798 if sync_result.fatal and use_superproject is not None:
3797 if sync_result.fatal and use_superproject is not None: 3799 return False
3798 return False
3799 3800
3800 return True 3801 return True
3801 3802
diff --git a/subcmds/sync.py b/subcmds/sync.py
index c1655159..baee6b23 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -694,10 +694,10 @@ later is required to fix a server side protocol bug.
694 load_local_manifests: Whether to load local manifests. 694 load_local_manifests: Whether to load local manifests.
695 """ 695 """
696 if manifest_name: 696 if manifest_name:
697 # Override calls _Unload already 697 # Override calls Unload already
698 self.manifest.Override(manifest_name, load_local_manifests=load_local_manifests) 698 self.manifest.Override(manifest_name, load_local_manifests=load_local_manifests)
699 else: 699 else:
700 self.manifest._Unload() 700 self.manifest.Unload()
701 701
702 def UpdateProjectList(self, opt): 702 def UpdateProjectList(self, opt):
703 new_project_paths = [] 703 new_project_paths = []