diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-09-17 14:29:43 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-09-17 14:34:04 +0000 |
commit | 4e6389c2f02c71cb2f2d3af738f421f8bbc5ea73 (patch) | |
tree | ab67dc4742b436aaa2f9e89b85345629022010f6 | |
parent | 0fc54dcc96b52f97c1e270f079fc7bf1bc0abd2b (diff) | |
download | morph-4e6389c2f02c71cb2f2d3af738f421f8bbc5ea73.tar.gz |
workspace: add method for listing system branches
-rw-r--r-- | morphlib/workspace.py | 5 | ||||
-rw-r--r-- | morphlib/workspace_tests.py | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/morphlib/workspace.py b/morphlib/workspace.py index 93f699e6..27ccbe65 100644 --- a/morphlib/workspace.py +++ b/morphlib/workspace.py @@ -87,6 +87,11 @@ class Workspace(object): dirname, root_repository_url, system_branch_name) return sb + def list_system_branches(self): + return (morphlib.sysbranchdir.open(dirname) + for dirname in + morphlib.util.find_leaves(self.root, '.morph-system-branch')) + def open(dirname): '''Open an existing workspace. diff --git a/morphlib/workspace_tests.py b/morphlib/workspace_tests.py index 83b5e54f..b25be35e 100644 --- a/morphlib/workspace_tests.py +++ b/morphlib/workspace_tests.py @@ -99,3 +99,13 @@ class WorkspaceTests(unittest.TestCase): sb = ws.create_system_branch_directory(url, branch) self.assertTrue(type(sb), morphlib.sysbranchdir.SystemBranchDirectory) + def test_lists_created_system_branches(self): + self.create_it() + ws = morphlib.workspace.open(self.workspace_dir) + + branches = ["branch/1", "branch/2"] + for branch in branches: + ws.create_system_branch_directory('test:morphs', branch) + self.assertEqual(sorted(sb.system_branch_name + for sb in ws.list_system_branches()), + branches) |