summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-08-29 14:46:35 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-08-29 18:49:31 +0100
commitb657fbcab062073ff4dd1c69a72b252e4992e152 (patch)
tree6739bceee440567f10aaead17974b5eeaa7e8fb6 /morphlib
parentce83a0afe0a51c9b8ab75e89d23f45c3ebf2be93 (diff)
downloadmorph-b657fbcab062073ff4dd1c69a72b252e4992e152.tar.gz
Add mandatory repository parameter to "morph branch"
This is complementary to adding a repository parameter to the "morph checkout" command. It allows to branch off arbitrary repositories rather than always branching off baserock:morphs. All affected tests are updated to provide and work with this new parameter.
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index 74069200..78005668 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -26,9 +26,6 @@ import morphlib
class BranchAndMergePlugin(cliapp.Plugin):
- system_repo_base = 'morphs'
- system_repo_name = 'baserock:%s' % system_repo_base
-
def enable(self):
self.app.add_subcommand('petrify', self.petrify,
arg_synopsis='STRATUM...')
@@ -259,12 +256,13 @@ class BranchAndMergePlugin(cliapp.Plugin):
def branch(self, args):
'''Branch the whole system.'''
- if len(args) not in [1, 2]:
+ if len(args) not in [2, 3]:
raise cliapp.AppException('morph branch needs name of branch '
'as parameter')
- new_branch = args[0]
- commit = 'master' if len(args) == 1 else args[1]
+ repo = args[0]
+ new_branch = args[1]
+ commit = 'master' if len(args) == 2 else args[2]
# Create the system branch directory.
os.makedirs(new_branch)
@@ -274,16 +272,15 @@ class BranchAndMergePlugin(cliapp.Plugin):
os.mkdir(os.path.join(new_branch, '.morph-system-branch'))
# Remember the repository we branched off from.
- self.write_branch_root(new_branch, self.system_repo_base)
+ self.write_branch_root(new_branch, repo)
# Clone into system branch directory.
- new_repo = os.path.join(new_branch, self.system_repo_base)
- self.clone_to_directory(self.app, new_repo, self.system_repo_name,
- commit)
+ repo_dir = os.path.join(new_branch, self._convert_uri_to_path(repo))
+ self.clone_to_directory(self.app, repo_dir, repo, commit)
# Create a new branch in the local morphs repository.
self.app.runcmd(['git', 'checkout', '-b', new_branch, commit],
- cwd=new_repo)
+ cwd=repo_dir)
def _convert_uri_to_path(self, uri):
parts = urlparse.urlparse(uri)