summaryrefslogtreecommitdiff
path: root/morph
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-03-22 19:10:08 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-03-22 19:10:08 +0000
commitaab2c0fb0de5cd183bb9278a1e6b1c05231729e9 (patch)
tree6ed103afd65fb671eddb7acb4be0afb32c34a2be /morph
parent9049d3091c9aec0642388514ef5a3a01bfdde9b4 (diff)
downloadmorph-aab2c0fb0de5cd183bb9278a1e6b1c05231729e9.tar.gz
Implement "morph branch"
Diffstat (limited to 'morph')
-rwxr-xr-xmorph23
1 files changed, 21 insertions, 2 deletions
diff --git a/morph b/morph
index d3d09311..1013f065 100755
--- a/morph
+++ b/morph
@@ -397,8 +397,27 @@ class Morph(cliapp.Application):
raise cliapp.AppException('morph branch needs name of branch '
'as parameter')
- branch = args[0]
- os.makedirs(branch)
+ new_branch = args[0]
+ repo = 'morphs'
+ commit = 'master'
+
+ # Create the system branch directory.
+ os.makedirs(new_branch)
+
+ # Get the 'morphs' 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('morphs', commit)
+
+ # Clone it from cache to system branch directory.
+ new_repo = os.path.join(new_branch, os.path.basename(repo))
+ morphlib.git.clone(new_repo, treeish.repo, self.msg)
+
+ # Create a new branch in the local morphs repository.
+ self.runcmd(['git', 'checkout', '-b', new_branch, commit],
+ cwd=new_repo)
def msg(self, msg):
'''Show a message to the user about what is going on.'''