def fetch(self): if self.stage.expanded: tty.msg("Already fetched %s" % self.stage.source_path) return args = [] if self.revision: args.append('at revision %s' % self.revision) tty.msg("Cloning mercurial repository:", self.url, *args) args = ['clone'] if not spack.config.get('config:verify_ssl'): args.append('--insecure') if self.revision: args.extend(['-r', self.revision]) args.extend([self.url]) with temp_cwd(): self.hg(*args) repo_name = get_single_file('.') self.stage.srcdir = repo_name shutil.move(repo_name, self.stage.source_path)
def fetch(self): if self.stage.expanded: tty.msg("Already fetched %s" % self.stage.source_path) return tty.msg("Checking out subversion repository: %s" % self.url) args = ['checkout', '--force', '--quiet'] if self.revision: args += ['-r', self.revision] args.extend([self.url]) with temp_cwd(): self.svn(*args) repo_name = get_single_file('.') self.stage.srcdir = repo_name shutil.move(repo_name, self.stage.source_path)
def fetch(self): if self.stage.expanded: tty.msg("Already fetched {0}".format(self.stage.source_path)) return tty.msg("Cloning git repository: {0}".format(self._repo_info())) git = self.git if self.commit: # Need to do a regular clone and check out everything if # they asked for a particular commit. debug = spack.config.get('config:debug') clone_args = ['clone', self.url] if not debug: clone_args.insert(1, '--quiet') with temp_cwd(): git(*clone_args) repo_name = get_single_file('.') self.stage.srcdir = repo_name shutil.move(repo_name, self.stage.source_path) with working_dir(self.stage.source_path): checkout_args = ['checkout', self.commit] if not debug: checkout_args.insert(1, '--quiet') git(*checkout_args) else: # Can be more efficient if not checking out a specific commit. args = ['clone'] if not spack.config.get('config:debug'): args.append('--quiet') # If we want a particular branch ask for it. if self.branch: args.extend(['--branch', self.branch]) elif self.tag and self.git_version >= ver('1.8.5.2'): args.extend(['--branch', self.tag]) # Try to be efficient if we're using a new enough git. # This checks out only one branch's history if self.git_version >= ver('1.7.10'): if self.get_full_repo: args.append('--no-single-branch') else: args.append('--single-branch') with temp_cwd(): # Yet more efficiency: only download a 1-commit deep # tree, if the in-use git and protocol permit it. if (not self.get_full_repo) and \ self.git_version >= ver('1.7.1') and \ self.protocol_supports_shallow_clone(): args.extend(['--depth', '1']) args.extend([self.url]) git(*args) repo_name = get_single_file('.') self.stage.srcdir = repo_name shutil.move(repo_name, self.stage.source_path) with working_dir(self.stage.source_path): # For tags, be conservative and check them out AFTER # cloning. Later git versions can do this with clone # --branch, but older ones fail. if self.tag and self.git_version < ver('1.8.5.2'): # pull --tags returns a "special" error code of 1 in # older versions that we have to ignore. # see: https://github.com/git/git/commit/19d122b pull_args = ['pull', '--tags'] co_args = ['checkout', self.tag] if not spack.config.get('config:debug'): pull_args.insert(1, '--quiet') co_args.insert(1, '--quiet') git(*pull_args, ignore_errors=1) git(*co_args) # Init submodules if the user asked for them. if self.submodules: with working_dir(self.stage.source_path): args = ['submodule', 'update', '--init', '--recursive'] if not spack.config.get('config:debug'): args.insert(1, '--quiet') git(*args)