summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-07-03 16:16:18 -0700
committerShawn O. Pearce <sop@google.com>2009-07-03 20:03:38 -0700
commitabb7a3dfecdfe98b30594219f24c5c3d5e11e990 (patch)
treeeeec9afdd3f3b42101d436d21e1e802b419c5e74
parentcc6c79643e1cafad565424caabe581e7b548bf6f (diff)
downloadgit-repo-abb7a3dfecdfe98b30594219f24c5c3d5e11e990.tar.gz
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>
-rw-r--r--command.py6
-rw-r--r--manifest_loader.py12
2 files changed, 12 insertions, 6 deletions
diff --git a/command.py b/command.py
index 5ca43f20..9e970e80 100644
--- a/command.py
+++ b/command.py
@@ -62,8 +62,10 @@ class Command(object):
62 def manifest(self): 62 def manifest(self):
63 return self.GetManifest() 63 return self.GetManifest()
64 64
65 def GetManifest(self, reparse=False): 65 def GetManifest(self, reparse=False, type=None):
66 return manifest_loader.GetManifest(self.repodir, reparse) 66 return manifest_loader.GetManifest(self.repodir,
67 reparse=reparse,
68 type=type)
67 69
68 def GetProjects(self, args, missing_ok=False): 70 def GetProjects(self, args, missing_ok=False):
69 """A list of projects that match the arguments. 71 """A list of projects that match the arguments.
diff --git a/manifest_loader.py b/manifest_loader.py
index 85ad3ea1..1ce1c1f3 100644
--- a/manifest_loader.py
+++ b/manifest_loader.py
@@ -15,13 +15,17 @@
15 15
16from manifest_xml import XmlManifest 16from manifest_xml import XmlManifest
17 17
18def ParseManifest(repodir): 18def ParseManifest(repodir, type=None):
19 if type:
20 return type(repodir)
19 return XmlManifest(repodir) 21 return XmlManifest(repodir)
20 22
21_manifest = None 23_manifest = None
22 24
23def GetManifest(repodir, reparse=False): 25def GetManifest(repodir, reparse=False, type=None):
24 global _manifest 26 global _manifest
25 if _manifest is None or reparse: 27 if _manifest is None \
26 _manifest = ParseManifest(repodir) 28 or reparse \
29 or (type and _manifest.__class__ != type):
30 _manifest = ParseManifest(repodir, type=type)
27 return _manifest 31 return _manifest