diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-09-27 00:04:50 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-10-03 16:57:32 -0700 |
commit | 0fa1c5b0a54c2b64dfc431449b1ba4491b9981c0 (patch) | |
tree | dfb37aab3aeca8bc838258ad5bf90fee910a62e8 /lib | |
parent | 727d313c3052d117ec3268ccc8d3f34f1c443b1c (diff) | |
download | spack-0fa1c5b0a54c2b64dfc431449b1ba4491b9981c0.tar.gz spack-0fa1c5b0a54c2b64dfc431449b1ba4491b9981c0.tar.bz2 spack-0fa1c5b0a54c2b64dfc431449b1ba4491b9981c0.tar.xz spack-0fa1c5b0a54c2b64dfc431449b1ba4491b9981c0.zip |
Add Mercurial fetch strategy and lwm2.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/fetch_strategy.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index 411c8cc276..ad9af43c96 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -421,6 +421,76 @@ class SvnFetchStrategy(VCSFetchStrategy): self.svn('revert', '.', '-R') +class HgFetchStrategy(VCSFetchStrategy): + """Fetch strategy that gets source code from a Mercurial repository. + Use like this in a package: + + version('name', hg='https://jay.grs.rwth-aachen.de/hg/lwm2') + + Optionally, you can provide a branch, or revision to check out, e.g.: + + version('torus', hg='https://jay.grs.rwth-aachen.de/hg/lwm2', branch='torus') + + You can use these three optional attributes in addition to ``hg``: + + * ``branch``: Particular branch to build from (default is 'default') + * ``tag``: Particular tag to check out + * ``revision``: Particular revision hash in the repo + """ + enabled = True + required_attributes = ['hg'] + + def __init__(self, **kwargs): + super(HgFetchStrategy, self).__init__( + 'hg', 'tag', 'branch', 'revision', **kwargs) + self._hg = None + + # For git fetch branches and tags the same way. + if not self.revision: + self.revision = self.branch + if not self.revision: + self.revision = self.tag + + + @property + def hg(self): + if not self._hg: + self._hg = which('hg', required=True) + return self._hg + + + def fetch(self): + assert(self.stage) + self.stage.chdir() + + if self.stage.source_path: + tty.msg("Already fetched %s." % self.stage.source_path) + return + + tty.msg("Trying to clone Mercurial repository: %s" % self.url) + + args = ['clone', self.url] + if self.revision: + args += ['-r', self.revision] + + self.hg(*args) + + + def reset(self): + assert(self.stage) + self.stage.chdir() + + scrubbed = "scrubbed-source-tmp" + args = ['clone'] + if self.revision: + args += ['-r', self.revision] + args += [self.stage.source_path, scrubbed] + + self.hg(*args) + shutil.rmtree(self.stage.source_path, ignore_errors=True) + shutil.move(scrubbed, self.stage.source_path) + + def from_url(url): """Given a URL, find an appropriate fetch strategy for it. Currently just gives you a URLFetchStrategy that uses curl. |