29
28
import bzrlib.errors as errors
30
29
from bzrlib import osutils
32
31
from dialog import error_dialog, question_dialog
33
32
from errors import show_bzr_error
33
from guifiles import GLADEFILENAME
42
35
class CommitDialog(gtk.Dialog):
43
36
""" New implementation of the Commit dialog. """
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"))
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"))
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()
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)
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)
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"),
143
if self._is_checkout:
149
144
self.vbox.pack_start(self._check_local, 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)
145
self.vbox.pack_start(self._check_strict, False, False)
164
147
# Create the file list
165
148
self._create_file_view()
166
149
# Create the pending merges
176
159
self.vbox.show_all()
178
# Default to Commit button
179
self._button_commit.grab_default()
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()
186
166
if iter is not None:
187
from diff import DiffWindow
167
from olive import DiffWindow
189
169
_selected = model.get_value(iter, 1)
191
171
diff = DiffWindow()
192
diff.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
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)
223
201
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:
234
206
self.wt.commit(message,
235
207
allow_pointless=False,
208
strict=self._check_strict.get_active(),
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,
217
strict=self._check_strict.get_active(),
247
219
specific_files=specific_files)
248
220
self.response(gtk.RESPONSE_OK)
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 ])
336
self._file_store.append([ False, path+marker, _('added'), path ])
338
self._file_store.append([ True, path+marker, _('added'), path ])
304
self._file_store.append([ True, path+marker, _('added'), path ])
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 ])
346
self._file_store.append([ False, path+marker, _('removed'), path ])
348
self._file_store.append([ True, path+marker, _('removed'), path ])
308
self._file_store.append([ True, path+marker, _('removed'), path ])
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')
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,
364
self._file_store.append([ False,
365
oldpath+marker + ' => ' + newpath+marker,
370
self._file_store.append([ True,
371
oldpath+marker + ' => ' + newpath+marker,
316
self._file_store.append([ True,
317
oldpath+marker + ' => ' + newpath+marker,
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 ])
382
self._file_store.append([ False, path+marker, _('modified'), path ])
384
self._file_store.append([ True, path+marker, _('modified'), path ])
324
self._file_store.append([ True, path+marker, _('modified'), path ])
386
326
def _create_pending_merges(self):
387
327
if not self.pending: