diff options
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 9 | ||||
-rw-r--r-- | tests.branching/init-newdir.exit | 1 | ||||
-rwxr-xr-x | tests.branching/init-newdir.script | 6 | ||||
-rw-r--r-- | tests.branching/init-newdir.stderr | 1 | ||||
-rw-r--r-- | tests.branching/init-newdir.stdout | 2 |
5 files changed, 12 insertions, 7 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index e5c5fb44..670b3117 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -190,13 +190,18 @@ class BranchAndMergePlugin(cliapp.Plugin): dirname = args[0] + # verify the mine directory is empty (and thus, can be used) or + # create it if it doesn't exist yet if os.path.exists(dirname): if os.listdir(dirname) != []: raise cliapp.AppException('can only initialize empty ' 'directory: %s' % dirname) else: - raise cliapp.AppException('can only initialize an existing ' - 'empty directory: %s' % dirname) + try: + os.makedirs(dirname) + except: + raise cliapp.AppException('failed to create mine ' + 'directory: %s' % dirname) os.mkdir(os.path.join(dirname, '.morph')) self.app.status(msg='Initialized morph mine', chatty=True) diff --git a/tests.branching/init-newdir.exit b/tests.branching/init-newdir.exit deleted file mode 100644 index d00491fd..00000000 --- a/tests.branching/init-newdir.exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/tests.branching/init-newdir.script b/tests.branching/init-newdir.script index 3bb4a1ba..70c8bb87 100755 --- a/tests.branching/init-newdir.script +++ b/tests.branching/init-newdir.script @@ -17,8 +17,8 @@ set -eu -# Test that "morph init" gives an error when given the name of a -# directory that does not exist yet. +# Test that "morph init" works if given a directory that +# does not exist yet. "$SRCDIR/scripts/test-morph" init "$DATADIR/foo" - +"$SRCDIR/scripts/list-tree" "$DATADIR/foo" diff --git a/tests.branching/init-newdir.stderr b/tests.branching/init-newdir.stderr deleted file mode 100644 index 066d69c0..00000000 --- a/tests.branching/init-newdir.stderr +++ /dev/null @@ -1 +0,0 @@ -ERROR: can only initialize an existing empty directory: TMP/foo diff --git a/tests.branching/init-newdir.stdout b/tests.branching/init-newdir.stdout new file mode 100644 index 00000000..e7922ee1 --- /dev/null +++ b/tests.branching/init-newdir.stdout @@ -0,0 +1,2 @@ +d . +d ./.morph |