/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 olive/commit.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-28 06:35:56 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060928063556-62ec354cb06ba38c
Update TODO
integrate the handle and communicator functions into a main class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
try:
25
 
    import gtk
26
 
    import gtk.glade
27
 
    import gobject
28
 
    import pango
29
 
except:
30
 
    sys.exit(1)
 
24
import gtk
 
25
import gtk.glade
 
26
import gobject
 
27
import pango
31
28
 
32
29
from bzrlib import version_info
33
30
 
34
 
if version_info < (0, 9):
35
 
    # function deprecated after 0.9
36
 
    from bzrlib.delta import compare_trees
37
 
 
38
31
import bzrlib.errors as errors
39
32
from bzrlib.workingtree import WorkingTree
40
33
 
 
34
from dialog import error_dialog
 
35
from olive import gladefile
 
36
 
41
37
class OliveCommit:
42
38
    """ Display Commit dialog and perform the needed actions. """
43
 
    def __init__(self, gladefile, comm, dialog):
 
39
    def __init__(self, wt, wtpath):
44
40
        """ Initialize the Commit dialog. """
45
 
        self.gladefile = gladefile
46
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
47
 
        
48
 
        # Communication object
49
 
        self.comm = comm
50
 
        # Dialog object
51
 
        self.dialog = dialog
52
 
        
 
41
        self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
 
42
        
 
43
        self.wt = wt
 
44
        self.wtpath = wtpath
 
45
 
53
46
        # Get some important widgets
54
47
        self.window = self.glade.get_widget('window_commit')
55
48
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
56
49
        self.textview = self.glade.get_widget('textview_commit')
57
50
        self.file_view = self.glade.get_widget('treeview_commit_select')
58
51
 
59
 
        # Check if current location is a branch
60
 
        try:
61
 
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
62
 
            branch = self.wt.branch
63
 
        except errors.NotBranchError:
64
 
            self.notbranch = True
65
 
            return
66
 
        except:
67
 
            raise
68
 
 
69
 
        file_id = self.wt.path2id(path)
 
52
        file_id = self.wt.path2id(wtpath)
70
53
 
71
54
        self.notbranch = False
72
55
        if file_id is None:
75
58
        
76
59
        # Set the delta
77
60
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
78
 
        if version_info < (0, 9):
79
 
            self.delta = compare_trees(self.old_tree, self.wt)
80
 
        else:
81
 
            self.delta = self.wt.changes_from(self.old_tree)
 
61
        self.delta = self.wt.changes_from(self.old_tree)
82
62
        
83
63
        # Dictionary for signal_autoconnect
84
64
        dic = { "on_button_commit_commit_clicked": self.commit,
93
73
    def display(self):
94
74
        """ Display the Push dialog. """
95
75
        if self.notbranch:
96
 
            self.dialog.error_dialog(_('Directory is not a branch'),
 
76
            error_dialog(_('Directory is not a branch'),
97
77
                                     _('You can perform this action only in a branch.'))
98
78
            self.close()
99
79
        else:
100
 
            from olive.backend.info import is_checkout
101
 
            if is_checkout(self.comm.get_path()):
 
80
            if self.wt.branch.get_bound_location() is not None:
102
81
                # we have a checkout, so the local commit checkbox must appear
103
82
                self.checkbutton_local.show()
104
83
            
106
85
            self.window.show()
107
86
            
108
87
    
109
 
    # This code is from Jelmer Vernooij's bzr-gtk branch
110
88
    def _create_file_view(self):
111
89
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
112
90
                                        gobject.TYPE_STRING,
143
121
            it = self.file_store.iter_next(it)
144
122
 
145
123
        return ret
146
 
    # end of bzr-gtk code
147
124
    
148
125
    def _toggle_commit(self, cell, path, model):
149
126
        model[path][0] = not model[path][0]
159
136
        
160
137
        specific_files = self._get_specific_files()
161
138
        
162
 
        self.comm.set_busy(self.window)
163
 
        # merged from Jelmer Vernooij's olive integration branch
164
139
        try:
165
140
            self.wt.commit(message, 
166
141
                           allow_pointless=checkbutton_force.get_active(),
168
143
                           local=self.checkbutton_local.get_active(),
169
144
                           specific_files=specific_files)
170
145
        except errors.NotBranchError:
171
 
            self.dialog.error_dialog(_('Directory is not a branch'),
 
146
            error_dialog(_('Directory is not a branch'),
172
147
                                     _('You can perform this action only in a branch.'))
173
 
            self.comm.set_busy(self.window, False)
174
148
            return
175
149
        except errors.LocalRequiresBoundBranch:
176
 
            self.dialog.error_dialog(_('Directory is not a checkout'),
 
150
            error_dialog(_('Directory is not a checkout'),
177
151
                                     _('You can perform local commit only on checkouts.'))
178
 
            self.comm.set_busy(self.window, False)
179
152
            return
180
153
        except errors.PointlessCommit:
181
 
            self.dialog.error_dialog(_('No changes to commit'),
 
154
            error_dialog(_('No changes to commit'),
182
155
                                     _('Try force commit if you want to commit anyway.'))
183
 
            self.comm.set_busy(self.window, False)
184
156
            return
185
157
        except errors.ConflictsInTree:
186
 
            self.dialog.error_dialog(_('Conflicts in tree'),
 
158
            error_dialog(_('Conflicts in tree'),
187
159
                                     _('You need to resolve the conflicts before committing.'))
188
 
            self.comm.set_busy(self.window, False)
189
160
            return
190
161
        except errors.StrictCommitFailed:
191
 
            self.dialog.error_dialog(_('Strict commit failed'),
 
162
            error_dialog(_('Strict commit failed'),
192
163
                                     _('There are unknown files in the working tree.\nPlease add or delete them.'))
193
 
            self.comm.set_busy(self.window, False)
194
164
            return
195
165
        except errors.BoundBranchOutOfDate, errmsg:
196
 
            self.dialog.error_dialog(_('Bound branch is out of date'),
 
166
            error_dialog(_('Bound branch is out of date'),
197
167
                                     _('%s') % errmsg)
198
 
            self.comm.set_busy(self.window, False)
199
 
            return
200
 
        except:
201
 
            raise
 
168
            return
 
169
        except errors.BzrError, msg:
 
170
            error_dialog(_('Unknown bzr error'), str(msg))
 
171
            return
 
172
        except Exception, msg:
 
173
            error_dialog(_('Unknown error'), str(msg))
 
174
            return
202
175
        
203
176
        self.close()
204
 
        self.comm.refresh_right()
205
177
        
206
178
    def close(self, widget=None):
207
179
        self.window.destroy()