From a2ff20dd209fe3eb091cdf1bddd4672f86b76bd8 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 7 Apr 2022 16:49:06 +0000 Subject: 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 Reviewed-by: Raman Tenneti Tested-by: LaMont Jones --- manifest_xml.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'manifest_xml.py') 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): if os.path.exists(mp.gitdir) and mp.use_worktree: mp.use_git_worktrees = True - self._Unload() + self.Unload() def Override(self, name, load_local_manifests=True): """Use a different manifest, just for the current instantiation. @@ -399,7 +399,7 @@ class XmlManifest(object): try: self._load_local_manifests = load_local_manifests self.manifestFile = path - self._Unload() + self.Unload() self._Load() finally: self.manifestFile = old @@ -970,7 +970,13 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md groups = self.GetDefaultGroupsStr() return groups - def _Unload(self): + def Unload(self): + """Unload the manifest. + + If the manifest files have been changed since Load() was called, this will + cause the new/updated manifest to be used. + + """ self._loaded = False self._projects = {} self._paths = {} @@ -984,6 +990,11 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md self.branch = None self._manifest_server = None + def Load(self): + """Read the manifest into memory.""" + # Do not expose internal arguments. + self._Load() + def _Load(self, initial_client=None, submanifest_depth=0): if submanifest_depth > MAX_SUBMANIFEST_DEPTH: raise ManifestParseError('maximum submanifest depth %d exceeded.' % @@ -1030,7 +1041,7 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md except ManifestParseError as e: # There was a problem parsing, unload ourselves in case they catch # this error and try again later, we will show the correct error - self._Unload() + self.Unload() raise e if self.IsMirror: -- cgit v1.2.3-54-g00ecf