From 525344aa85199d6ceb6a25af4b454a5096ae369e Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 27 Oct 2014 00:55:25 -0700 Subject: [PATCH] Make info command show VCS URLs properly. --- lib/spack/spack/cmd/info.py | 32 ++++++++++++++++--------------- lib/spack/spack/fetch_strategy.py | 19 ++++++++++++++---- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/lib/spack/spack/cmd/info.py b/lib/spack/spack/cmd/info.py index bb147b30f5..a1c35269be 100644 --- a/lib/spack/spack/cmd/info.py +++ b/lib/spack/spack/cmd/info.py @@ -26,6 +26,7 @@ import textwrap from llnl.util.tty.colify import colify import spack +import spack.fetch_strategy as fs description = "Get detailed information on a particular package" @@ -34,40 +35,41 @@ def setup_parser(subparser): def info(parser, args): - package = spack.db.get(args.name) - print "Package: ", package.name - print "Homepage: ", package.homepage + pkg = spack.db.get(args.name) + print "Package: ", pkg.name + print "Homepage: ", pkg.homepage print - print "Safe versions: " + print "Versions: " - if not package.versions: + if not pkg.versions: print("None.") else: - maxlen = max(len(str(v)) for v in package.versions) + maxlen = max(len(str(v)) for v in pkg.versions) fmt = "%%-%ss" % maxlen - for v in reversed(sorted(package.versions)): - print " " + (fmt % v) + " " + package.url_for_version(v) + for v in reversed(sorted(pkg.versions)): + f = fs.for_package_version(pkg, v) + print " " + (fmt % v) + " " + str(f) print print "Dependencies:" - if package.dependencies: - colify(package.dependencies, indent=4) + if pkg.dependencies: + colify(pkg.dependencies, indent=4) else: print " None" print - print "Virtual packages: " - if package.provided: - for spec, when in package.provided.items(): + print "Virtual pkgs: " + if pkg.provided: + for spec, when in pkg.provided.items(): print " %s provides %s" % (when, spec) else: print " None" print print "Description:" - if package.__doc__: - doc = re.sub(r'\s+', ' ', package.__doc__) + if pkg.__doc__: + doc = re.sub(r'\s+', ' ', pkg.__doc__) lines = textwrap.wrap(doc, 72) for line in lines: print " " + line diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index f79051c500..779cd76bae 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -240,7 +240,7 @@ def __str__(self): if self.url: return self.url else: - return "URLFetchStrategy" + return "[no url]" class VCSFetchStrategy(FetchStrategy): @@ -293,7 +293,7 @@ def archive(self, destination, **kwargs): def __str__(self): - return self.url + return "VCS: %s" % self.url def __repr__(self): @@ -396,6 +396,10 @@ def reset(self): self.git('clean', '-f') + def __str__(self): + return "[git] %s" % self.url + + class SvnFetchStrategy(VCSFetchStrategy): """Fetch strategy that gets source code from a subversion repository. Use like this in a package: @@ -469,6 +473,11 @@ def reset(self): self.svn('revert', '.', '-R') + def __str__(self): + return "[svn] %s" % self.url + + + class HgFetchStrategy(VCSFetchStrategy): """Fetch strategy that gets source code from a Mercurial repository. Use like this in a package: @@ -543,6 +552,10 @@ def reset(self): self.stage.chdir_to_source() + def __str__(self): + return "[hg] %s" % self.url + + def from_url(url): """Given a URL, find an appropriate fetch strategy for it. Currently just gives you a URLFetchStrategy that uses curl. @@ -630,5 +643,3 @@ class NoStageError(FetchError): def __init__(self, method): super(NoStageError, self).__init__( "Must call FetchStrategy.set_stage() before calling %s" % method.__name__) - -