diff options
-rw-r--r-- | morphlib/workspace.py | 15 | ||||
-rw-r--r-- | morphlib/workspace_tests.py | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/morphlib/workspace.py b/morphlib/workspace.py index 3a2269c8..e21581c6 100644 --- a/morphlib/workspace.py +++ b/morphlib/workspace.py @@ -53,6 +53,21 @@ class Workspace(object): def __init__(self, root_directory): self.root = root_directory + def get_default_system_branch_directory_name(self, system_branch_name): + '''Determine directory where a system branch would be checked out. + + Return the fully qualified pathname to the directory where + a system branch would be checked out. The directory may or may + not exist already. + + If the system branch is checked out, but into a directory of + a different name (which is allowed), that is ignored: this method + only computed the default name. + + ''' + + return os.path.join(self.root, system_branch_name) + def open(dirname): '''Open an existing workspace. diff --git a/morphlib/workspace_tests.py b/morphlib/workspace_tests.py index 7837481a..b9c4957a 100644 --- a/morphlib/workspace_tests.py +++ b/morphlib/workspace_tests.py @@ -83,3 +83,11 @@ class WorkspaceTests(unittest.TestCase): morphlib.workspace.NotInWorkspace, morphlib.workspace.open, self.tempdir) + def test_invents_appropriate_name_for_system_branch_directory(self): + self.create_it() + ws = morphlib.workspace.open(self.workspace_dir) + branch = 'foo/bar' + self.assertEqual( + ws.get_default_system_branch_directory_name(branch), + os.path.join(self.workspace_dir, branch)) + |