/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: 2007-01-30 17:26:34 UTC
  • Revision ID: jelmer@samba.org-20070130172634-ov7ucauynnp5vso6
Warn about incompatible versions (taken from bzrtools, thanks Aaron).

Update version to 0.14.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pass
22
22
 
23
23
import gtk
 
24
import gtk.glade
24
25
import gobject
25
26
import pango
26
27
 
27
 
import os.path
28
 
 
29
28
import bzrlib.errors as errors
30
29
from bzrlib import osutils
31
30
 
32
31
from dialog import error_dialog, question_dialog
33
32
from errors import show_bzr_error
34
 
 
35
 
try:
36
 
    import dbus
37
 
    import dbus.glib
38
 
    have_dbus = True
39
 
except ImportError:
40
 
    have_dbus = False
 
33
from guifiles import GLADEFILENAME
41
34
 
42
35
class CommitDialog(gtk.Dialog):
43
36
    """ New implementation of the Commit dialog. """
86
79
        
87
80
        # Create the widgets
88
81
        self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
89
 
        self._expander_files = gtk.Expander(_("File(s) to commit"))
 
82
        if self._is_checkout:
 
83
            self._check_local = gtk.CheckButton(_("_Local only commit (works in checkouts)"),
 
84
                                                use_underline=True)
 
85
        self._check_strict = gtk.CheckButton(_("_Strict commit (fails if unknown files are present)"),
 
86
                                             use_underline=True)
 
87
        self._expander_files = gtk.Expander(_("Please select the file(s) to commit"))
90
88
        self._vpaned_main = gtk.VPaned()
91
89
        self._scrolledwindow_files = gtk.ScrolledWindow()
92
90
        self._scrolledwindow_message = gtk.ScrolledWindow()
93
91
        self._treeview_files = gtk.TreeView()
94
92
        self._vbox_message = gtk.VBox()
95
 
        self._label_message = gtk.Label(_("Commit message:"))
 
93
        self._label_message = gtk.Label(_("Please specify a commit message:"))
96
94
        self._textview_message = gtk.TextView()
97
95
        
98
96
        if self._is_pending:
113
111
        self._textview_message.modify_font(pango.FontDescription("Monospace"))
114
112
        self.set_default_size(500, 500)
115
113
        self._vpaned_main.set_position(200)
116
 
        self._button_commit.set_flags(gtk.CAN_DEFAULT)
117
114
 
118
115
        if self._is_pending:
119
116
            self._scrolledwindow_merges.set_policy(gtk.POLICY_AUTOMATIC,
143
140
        self._vpaned_main.add2(self._vbox_message)
144
141
        
145
142
        self.vbox.pack_start(self._vpaned_main, True, True)
146
 
        if self._is_checkout: 
147
 
            self._check_local = gtk.CheckButton(_("_Only commit locally"),
148
 
                                                use_underline=True)
 
143
        if self._is_checkout:
149
144
            self.vbox.pack_start(self._check_local, False, False)
150
 
            if have_dbus:
151
 
                bus = dbus.SystemBus()
152
 
                proxy_obj = bus.get_object('org.freedesktop.NetworkManager', 
153
 
                              '/org/freedesktop/NetworkManager')
154
 
                dbus_iface = dbus.Interface(
155
 
                        proxy_obj, 'org.freedesktop.NetworkManager')
156
 
                try:
157
 
                    # 3 is the enum value for STATE_CONNECTED
158
 
                    self._check_local.set_active(dbus_iface.state() != 3)
159
 
                except dbus.DBusException, e:
160
 
                    # Silently drop errors. While DBus may be 
161
 
                    # available, NetworkManager doesn't necessarily have to be
162
 
                    mutter("unable to get networkmanager state: %r" % e)
163
 
                
 
145
        self.vbox.pack_start(self._check_strict, False, False)
 
146
        
164
147
        # Create the file list
165
148
        self._create_file_view()
166
149
        # Create the pending merges
174
157
        
175
158
        # Display dialog
176
159
        self.vbox.show_all()
177
 
        
178
 
        # Default to Commit button
179
 
        self._button_commit.grab_default()
180
160
    
181
161
    def _on_treeview_files_row_activated(self, treeview, path, view_column):
182
162
        # FIXME: the diff window freezes for some reason
184
164
        (model, iter) = treeselection.get_selected()
185
165
        
186
166
        if iter is not None:
187
 
            from diff import DiffWindow
 
167
            from olive import DiffWindow
188
168
            
189
169
            _selected = model.get_value(iter, 1)
190
170
            
191
171
            diff = DiffWindow()
192
 
            diff.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
193
 
            diff.set_modal(True)
194
172
            parent_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
195
173
            diff.set_diff(self.wt.branch.nick, self.wt, parent_tree)
196
174
            try:
223
201
            local = self._check_local.get_active()
224
202
        else:
225
203
            local = False
226
 
 
227
 
        if list(self.wt.unknowns()) != []:
228
 
            response = question_dialog(_("Commit with unknowns?"),
229
 
               _("Unknown files exist in the working tree. Commit anyway?"))
230
 
            if response == gtk.RESPONSE_NO:
231
 
                return
232
204
        
233
205
        try:
234
206
            self.wt.commit(message,
235
207
                       allow_pointless=False,
236
 
                       strict=False,
 
208
                       strict=self._check_strict.get_active(),
237
209
                       local=local,
238
210
                       specific_files=specific_files)
239
211
        except errors.PointlessCommit:
242
214
            if response == gtk.RESPONSE_YES:
243
215
                self.wt.commit(message,
244
216
                               allow_pointless=True,
245
 
                               strict=False,
 
217
                               strict=self._check_strict.get_active(),
246
218
                               local=local,
247
219
                               specific_files=specific_files)
248
220
        self.response(gtk.RESPONSE_OK)
329
301
 
330
302
        for path, id, kind in self.delta.added:
331
303
            marker = osutils.kind_marker(kind)
332
 
            if self.selected is not None:
333
 
                if path == os.path.join(self.wtpath, self.selected):
334
 
                    self._file_store.append([ True, path+marker, _('added'), path ])
335
 
                else:
336
 
                    self._file_store.append([ False, path+marker, _('added'), path ])
337
 
            else:
338
 
                self._file_store.append([ True, path+marker, _('added'), path ])
 
304
            self._file_store.append([ True, path+marker, _('added'), path ])
339
305
 
340
306
        for path, id, kind in self.delta.removed:
341
307
            marker = osutils.kind_marker(kind)
342
 
            if self.selected is not None:
343
 
                if path == os.path.join(self.wtpath, self.selected):
344
 
                    self._file_store.append([ True, path+marker, _('removed'), path ])
345
 
                else:
346
 
                    self._file_store.append([ False, path+marker, _('removed'), path ])
347
 
            else:
348
 
                self._file_store.append([ True, path+marker, _('removed'), path ])
 
308
            self._file_store.append([ True, path+marker, _('removed'), path ])
349
309
 
350
310
        for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
351
311
            marker = osutils.kind_marker(kind)
353
313
                changes = _('renamed and modified')
354
314
            else:
355
315
                changes = _('renamed')
356
 
            if self.selected is not None:
357
 
                if newpath == os.path.join(self.wtpath, self.selected):
358
 
                    self._file_store.append([ True,
359
 
                                              oldpath+marker + '  =>  ' + newpath+marker,
360
 
                                              changes,
361
 
                                              newpath
362
 
                                            ])
363
 
                else:
364
 
                    self._file_store.append([ False,
365
 
                                              oldpath+marker + '  =>  ' + newpath+marker,
366
 
                                              changes,
367
 
                                              newpath
368
 
                                            ])
369
 
            else:
370
 
                self._file_store.append([ True,
371
 
                                          oldpath+marker + '  =>  ' + newpath+marker,
372
 
                                          changes,
373
 
                                          newpath
374
 
                                        ])
 
316
            self._file_store.append([ True,
 
317
                                      oldpath+marker + '  =>  ' + newpath+marker,
 
318
                                      changes,
 
319
                                      newpath
 
320
                                    ])
375
321
 
376
322
        for path, id, kind, text_modified, meta_modified in self.delta.modified:
377
323
            marker = osutils.kind_marker(kind)
378
 
            if self.selected is not None:
379
 
                if path == os.path.join(self.wtpath, self.selected):
380
 
                    self._file_store.append([ True, path+marker, _('modified'), path ])
381
 
                else:
382
 
                    self._file_store.append([ False, path+marker, _('modified'), path ])
383
 
            else:
384
 
                self._file_store.append([ True, path+marker, _('modified'), path ])
 
324
            self._file_store.append([ True, path+marker, _('modified'), path ])
385
325
    
386
326
    def _create_pending_merges(self):
387
327
        if not self.pending: