From 050e4fd591537811e6e62b2e9ba1ce83e520e550 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 3 Jun 2009 14:16:14 -0700 Subject: [PATCH] manifest: Only display XML help on XML manifest Some of the help text is only related to the XML formatted manifest, so only display that text if that is the current format. Signed-off-by: Shawn O. Pearce --- .../{manifest-format.txt => manifest_xml.txt} | 0 subcmds/manifest.py | 21 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) rename docs/{manifest-format.txt => manifest_xml.txt} (100%) diff --git a/docs/manifest-format.txt b/docs/manifest_xml.txt similarity index 100% rename from docs/manifest-format.txt rename to docs/manifest_xml.txt diff --git a/subcmds/manifest.py b/subcmds/manifest.py index 4374a9d..4415b99 100644 --- a/subcmds/manifest.py +++ b/subcmds/manifest.py @@ -18,13 +18,22 @@ import sys from command import PagedCommand +def _doc(name): + r = os.path.dirname(__file__) + r = os.path.dirname(r) + fd = open(os.path.join(r, 'docs', 'manifest_xml.txt')) + try: + return fd.read() + finally: + fd.close() + class Manifest(PagedCommand): common = False helpSummary = "Manifest inspection utility" helpUsage = """ %prog [-o {-|NAME.xml} [-r]] """ - _helpDescription = """ + _xmlHelp = """ With the -o option, exports the current manifest for inspection. The manifest and (if present) local_manifest.xml are combined @@ -35,13 +44,9 @@ in a Git repository for use during future 'repo init' invocations. @property def helpDescription(self): - help = self._helpDescription + '\n' - r = os.path.dirname(__file__) - r = os.path.dirname(r) - fd = open(os.path.join(r, 'docs', 'manifest-format.txt')) - for line in fd: - help += line - fd.close() + help = '' + if isinstance(self.manifest, XmlManifest): + help += self._xmlHelp + '\n' + _doc('manifest_xml.txt') return help def _Options(self, p):