summaryrefslogtreecommitdiff
path: root/morphlib/plugins/branch_and_merge_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/plugins/branch_and_merge_plugin.py')
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py9
1 files changed, 7 insertions, 2 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)