mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Allow callers to request a specific type of manifest
If the caller knows exactly what the manifest type must be we can now ask the loader to directly construct that type, rather than guessing it from the working directory. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
parent
cc6c79643e
commit
abb7a3dfec
@ -62,8 +62,10 @@ class Command(object):
|
|||||||
def manifest(self):
|
def manifest(self):
|
||||||
return self.GetManifest()
|
return self.GetManifest()
|
||||||
|
|
||||||
def GetManifest(self, reparse=False):
|
def GetManifest(self, reparse=False, type=None):
|
||||||
return manifest_loader.GetManifest(self.repodir, reparse)
|
return manifest_loader.GetManifest(self.repodir,
|
||||||
|
reparse=reparse,
|
||||||
|
type=type)
|
||||||
|
|
||||||
def GetProjects(self, args, missing_ok=False):
|
def GetProjects(self, args, missing_ok=False):
|
||||||
"""A list of projects that match the arguments.
|
"""A list of projects that match the arguments.
|
||||||
|
@ -15,13 +15,17 @@
|
|||||||
|
|
||||||
from manifest_xml import XmlManifest
|
from manifest_xml import XmlManifest
|
||||||
|
|
||||||
def ParseManifest(repodir):
|
def ParseManifest(repodir, type=None):
|
||||||
|
if type:
|
||||||
|
return type(repodir)
|
||||||
return XmlManifest(repodir)
|
return XmlManifest(repodir)
|
||||||
|
|
||||||
_manifest = None
|
_manifest = None
|
||||||
|
|
||||||
def GetManifest(repodir, reparse=False):
|
def GetManifest(repodir, reparse=False, type=None):
|
||||||
global _manifest
|
global _manifest
|
||||||
if _manifest is None or reparse:
|
if _manifest is None \
|
||||||
_manifest = ParseManifest(repodir)
|
or reparse \
|
||||||
|
or (type and _manifest.__class__ != type):
|
||||||
|
_manifest = ParseManifest(repodir, type=type)
|
||||||
return _manifest
|
return _manifest
|
||||||
|
Loading…
Reference in New Issue
Block a user