166
166
def on_menuitem_branch_initialize_activate(self, widget):
167
167
""" Initialize current directory. """
168
import olive.backend.init as init
171
init.init(self.comm.get_path())
169
location = self.comm.get_path()
170
from bzrlib.builtins import get_format_type
172
format = get_format_type('default')
174
if not os.path.exists(location):
178
existing_bzrdir = bzrdir.BzrDir.open(location)
179
except NotBranchError:
180
bzrdir.BzrDir.create_branch_convenience(location, format=format)
182
if existing_bzrdir.has_branch():
183
if existing_bzrdir.has_workingtree():
184
raise AlreadyBranchError(location)
186
raise BranchExistsWithoutWorkingTree(location)
188
existing_bzrdir.create_branch()
189
existing_bzrdir.create_workingtree()
172
190
except errors.AlreadyBranchError, errmsg:
173
191
self.dialog.error_dialog(_('Directory is already a branch'),
174
192
_('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
175
193
except errors.BranchExistsWithoutWorkingTree, errmsg:
176
194
self.dialog.error_dialog(_('Branch without a working tree'),
177
195
_('The current directory (%s)\nis a branch without a working tree.') % errmsg)
181
self.dialog.info_dialog(_('Ininialize successful'),
197
self.dialog.info_dialog(_('Initialize successful'),
182
198
_('Directory successfully initialized.'))
183
199
self.comm.refresh_right()