27
from dialog import error_dialog
25
28
from errors import show_bzr_error
30
from bzrlib import bzrdir
31
from bzrlib import transport
32
import bzrlib.errors as errors
27
34
class InitDialog(gtk.Dialog):
28
35
""" Initialize dialog. """
29
36
def __init__(self, path, parent=None):
67
74
def _on_custom_toggled(self, widget):
68
75
""" Occurs if the Custom radiobutton is toggled. """
69
if self._radio_custom.get_active() == True:
76
if self._radio_custom.get_active():
70
77
self._entry_custom.set_sensitive(True)
71
78
self._entry_custom.grab_focus()
73
80
self._entry_custom.set_sensitive(False)
75
83
def _on_init_clicked(self, widget):
84
if self._radio_custom.get_active() and len(self._entry_custom.get_text()) == 0:
85
error_dialog(_("Directory name not specified"),
86
_("You should specify a new directory name."))
89
if self._radio_current.get_active():
92
location = self.path + os.sep + self._entry_custom.get_text()
94
format = bzrdir.format_registry.make_bzrdir('default')
95
to_transport = transport.get_transport(location)
98
to_transport.mkdir('.')
99
except errors.FileExists:
103
existing_bzrdir = bzrdir.BzrDir.open(location)
104
except errors.NotBranchError:
105
branch = bzrdir.BzrDir.create_branch_convenience(to_transport.base,
108
from bzrlib.transport.local import LocalTransport
109
if existing_bzrdir.has_branch():
110
if (isinstance(to_transport, LocalTransport)
111
and not existing_bzrdir.has_workingtree()):
112
raise errors.BranchExistsWithoutWorkingTree(location)
113
raise errors.AlreadyBranchError(location)
115
branch = existing_bzrdir.create_branch()
116
existing_bzrdir.create_workingtree()
76
118
self.response(gtk.RESPONSE_OK)