From ddb490714f43119441aabdd492d09520c73e3448 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 1 Aug 2013 11:57:15 +0000 Subject: Add Workspace.create_system_branch_directory method --- morphlib/workspace.py | 19 +++++++++++++++++++ morphlib/workspace_tests.py | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/morphlib/workspace.py b/morphlib/workspace.py index e21581c6..93f699e6 100644 --- a/morphlib/workspace.py +++ b/morphlib/workspace.py @@ -68,6 +68,25 @@ class Workspace(object): return os.path.join(self.root, system_branch_name) + def create_system_branch_directory(self, + root_repository_url, system_branch_name): + '''Create a directory for a system branch. + + Return a SystemBranchDirectory object that represents the + directory. The directory must not already exist. The directory + gets created and initialised (the .morph-system-branch/config + file gets created and populated). The root repository of the + system branch does NOT get checked out, the caller needs to + do that. + + ''' + + dirname = self.get_default_system_branch_directory_name( + system_branch_name) + sb = morphlib.sysbranchdir.create( + dirname, root_repository_url, system_branch_name) + return sb + def open(dirname): '''Open an existing workspace. diff --git a/morphlib/workspace_tests.py b/morphlib/workspace_tests.py index b9c4957a..83b5e54f 100644 --- a/morphlib/workspace_tests.py +++ b/morphlib/workspace_tests.py @@ -91,3 +91,11 @@ class WorkspaceTests(unittest.TestCase): ws.get_default_system_branch_directory_name(branch), os.path.join(self.workspace_dir, branch)) + def test_creates_system_branch_directory(self): + self.create_it() + ws = morphlib.workspace.open(self.workspace_dir) + url = 'test:morphs' + branch = 'my/new/thing' + sb = ws.create_system_branch_directory(url, branch) + self.assertTrue(type(sb), morphlib.sysbranchdir.SystemBranchDirectory) + -- cgit v1.2.1