28
29
import bzrlib.errors as errors
29
30
from bzrlib import osutils
31
32
from dialog import error_dialog, question_dialog
32
33
from errors import show_bzr_error
33
from guifiles import GLADEFILENAME
35
42
class CommitDialog(gtk.Dialog):
36
43
""" New implementation of the Commit dialog. """
80
87
# Create the widgets
81
88
self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
83
self._check_local = gtk.CheckButton(_("_Local only commit (works in checkouts)"),
85
self._check_strict = gtk.CheckButton(_("_Strict commit (fails if unknown files are present)"),
87
self._expander_files = gtk.Expander(_("Please select the file(s) to commit"))
89
self._expander_files = gtk.Expander(_("File(s) to commit"))
88
90
self._vpaned_main = gtk.VPaned()
89
91
self._scrolledwindow_files = gtk.ScrolledWindow()
90
92
self._scrolledwindow_message = gtk.ScrolledWindow()
91
93
self._treeview_files = gtk.TreeView()
92
94
self._vbox_message = gtk.VBox()
93
self._label_message = gtk.Label(_("Please specify a commit message:"))
95
self._label_message = gtk.Label(_("Commit message:"))
94
96
self._textview_message = gtk.TextView()
96
98
if self._is_pending:
111
113
self._textview_message.modify_font(pango.FontDescription("Monospace"))
112
114
self.set_default_size(500, 500)
113
115
self._vpaned_main.set_position(200)
116
self._button_commit.set_flags(gtk.CAN_DEFAULT)
115
118
if self._is_pending:
116
119
self._scrolledwindow_merges.set_policy(gtk.POLICY_AUTOMATIC,
140
143
self._vpaned_main.add2(self._vbox_message)
142
145
self.vbox.pack_start(self._vpaned_main, True, True)
143
if self._is_checkout:
146
if self._is_checkout:
147
self._check_local = gtk.CheckButton(_("_Only commit locally"),
144
149
self.vbox.pack_start(self._check_local, False, False)
145
self.vbox.pack_start(self._check_strict, False, False)
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')
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)
147
164
# Create the file list
148
165
self._create_file_view()
149
166
# Create the pending merges
159
176
self.vbox.show_all()
178
# Default to Commit button
179
self._button_commit.grab_default()
161
181
def _on_treeview_files_row_activated(self, treeview, path, view_column):
162
182
# FIXME: the diff window freezes for some reason
164
184
(model, iter) = treeselection.get_selected()
166
186
if iter is not None:
167
from olive import DiffWindow
187
from diff import DiffWindow
169
189
_selected = model.get_value(iter, 1)
171
191
diff = DiffWindow()
192
diff.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
172
194
parent_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
173
195
diff.set_diff(self.wt.branch.nick, self.wt, parent_tree)
201
223
local = self._check_local.get_active()
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:
206
234
self.wt.commit(message,
207
235
allow_pointless=False,
208
strict=self._check_strict.get_active(),
210
238
specific_files=specific_files)
211
239
except errors.PointlessCommit:
214
242
if response == gtk.RESPONSE_YES:
215
243
self.wt.commit(message,
216
244
allow_pointless=True,
217
strict=self._check_strict.get_active(),
219
247
specific_files=specific_files)
220
248
self.response(gtk.RESPONSE_OK)
302
330
for path, id, kind in self.delta.added:
303
331
marker = osutils.kind_marker(kind)
304
self._file_store.append([ True, path+marker, _('added'), path ])
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 ])
336
self._file_store.append([ False, path+marker, _('added'), path ])
338
self._file_store.append([ True, path+marker, _('added'), path ])
306
340
for path, id, kind in self.delta.removed:
307
341
marker = osutils.kind_marker(kind)
308
self._file_store.append([ True, path+marker, _('removed'), path ])
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 ])
346
self._file_store.append([ False, path+marker, _('removed'), path ])
348
self._file_store.append([ True, path+marker, _('removed'), path ])
310
350
for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
311
351
marker = osutils.kind_marker(kind)
313
353
changes = _('renamed and modified')
315
355
changes = _('renamed')
316
self._file_store.append([ True,
317
oldpath+marker + ' => ' + newpath+marker,
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,
364
self._file_store.append([ False,
365
oldpath+marker + ' => ' + newpath+marker,
370
self._file_store.append([ True,
371
oldpath+marker + ' => ' + newpath+marker,
322
376
for path, id, kind, text_modified, meta_modified in self.delta.modified:
323
377
marker = osutils.kind_marker(kind)
324
self._file_store.append([ True, path+marker, _('modified'), path ])
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 ])
382
self._file_store.append([ False, path+marker, _('modified'), path ])
384
self._file_store.append([ True, path+marker, _('modified'), path ])
326
386
def _create_pending_merges(self):
327
387
if not self.pending: