/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to initialize.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2007-04-06 17:48:23 UTC
  • mto: (188.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 190.
  • Revision ID: szilveszter.farkas@gmail.com-20070406174823-bclt7vsgn2nkcas2
Implemented init functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import gtk
24
24
 
 
25
import os
 
26
 
 
27
from dialog import error_dialog
25
28
from errors import show_bzr_error
26
29
 
 
30
from bzrlib import bzrdir
 
31
from bzrlib import transport
 
32
import bzrlib.errors as errors
 
33
 
27
34
class InitDialog(gtk.Dialog):
28
35
    """ Initialize dialog. """
29
36
    def __init__(self, path, parent=None):
66
73
    
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()
72
79
        else:
73
80
            self._entry_custom.set_sensitive(False)
74
81
    
 
82
    @show_bzr_error
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."))
 
87
            return
 
88
        
 
89
        if self._radio_current.get_active():
 
90
            location = self.path
 
91
        else:
 
92
            location = self.path + os.sep + self._entry_custom.get_text()
 
93
        
 
94
        format = bzrdir.format_registry.make_bzrdir('default')        
 
95
        to_transport = transport.get_transport(location)
 
96
        
 
97
        try:
 
98
            to_transport.mkdir('.')
 
99
        except errors.FileExists:
 
100
            pass
 
101
                    
 
102
        try:
 
103
            existing_bzrdir = bzrdir.BzrDir.open(location)
 
104
        except errors.NotBranchError:
 
105
            branch = bzrdir.BzrDir.create_branch_convenience(to_transport.base,
 
106
                                                             format=format)
 
107
        else:
 
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)
 
114
            else:
 
115
                branch = existing_bzrdir.create_branch()
 
116
                existing_bzrdir.create_workingtree()
 
117
        
76
118
        self.response(gtk.RESPONSE_OK)