From 341a8cc6b0ed0488bb4d6a1e50f16800a14f0a8a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 2 May 2012 17:30:36 +0100 Subject: Convert _clone_to_directory to use new APIs --- morph | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'morph') diff --git a/morph b/morph index 6f073b2e..2f95a283 100755 --- a/morph +++ b/morph @@ -693,29 +693,35 @@ class Morph(cliapp.Application): raise cliapp.AppException("Can't find the mine directory") self.output.write('%s\n' % dirname) - def _clone_to_directory(self, dirname, repo, ref): + def _clone_to_directory(self, dirname, reponame, ref): '''Clone a repository below a directory. As a side effect, clone it into the morph repository. ''' - # Get the repository into the cache. - tempdir = morphlib.tempdir.Tempdir(self.settings['tempdir']) - morph_loader = MorphologyLoader(self.settings) - source_manager = morphlib.sourcemanager.SourceManager(self, - update=not self.settings['no-git-update']) - treeish = source_manager.get_treeish(repo, ref) + # Setup. + if not os.path.exists(self.settings['cachedir']): + os.mkdir(self.settings['cachedir']) + cachedir = os.path.join(self.settings['cachedir'], 'gits') + baseurls = self.settings['git-base-url'] + bundle_base_url = self.settings['bundle-server'] + cache = morphlib.localrepocache.LocalRepoCache( + cachedir, baseurls, bundle_base_url) + + # Get the repository into the cache; make sure it is up to date. + repo = cache.cache_repo(reponame) + repo.update() # Clone it from cache to target directory. - morphlib.git.clone(dirname, treeish.repo, self.msg) + morphlib.git.clone(dirname, repo.path, self.msg) # Set the origin to point at the original repository. - morphlib.git.set_remote(dirname, 'origin', treeish.original_repo) + morphlib.git.set_remote(dirname, 'origin', repo.url) # Update remotes. self.runcmd(['git', 'remote', 'update'], cwd=dirname) - + def cmd_branch(self, args): '''Branch the whole system.''' -- cgit v1.2.1