160
154
self._pending_box.show()
162
156
def _fill_in_files(self):
163
# We should really use add a progress bar of some kind.
157
# We should really use _iter_changes, and then add a progress bar of
164
159
# While we fill in the view, hide the store
165
160
store = self._files_store
166
161
self._treeview_files.set_model(None)
168
added = _i18n('added')
169
removed = _i18n('removed')
170
renamed = _i18n('renamed')
171
renamed_and_modified = _i18n('renamed and modified')
172
modified = _i18n('modified')
173
kind_changed = _i18n('kind changed')
164
removed = _('removed')
165
renamed = _('renamed')
166
renamed_and_modified = _('renamed and modified')
167
modified = _('modified')
168
kind_changed = _('kind changed')
175
170
# The store holds:
176
171
# [file_id, real path, checkbox, display path, changes type, message]
177
# iter_changes returns:
172
# _iter_changes returns:
178
173
# (file_id, (path_in_source, path_in_target),
179
174
# changed_content, versioned, parent, name, kind,
182
all_enabled = (self._selected is None)
183
177
# The first entry is always the 'whole tree'
184
all_iter = store.append([None, None, all_enabled, 'All Files', '', ''])
185
initial_cursor = store.get_path(all_iter)
178
store.append([None, None, True, 'All Files', '', ''])
186
179
# should we pass specific_files?
187
180
self._wt.lock_read()
188
181
self._basis_tree.lock_read()
190
from diff import iter_changes_to_status
191
for (file_id, real_path, change_type, display_path
192
) in iter_changes_to_status(self._basis_tree, self._wt):
193
if self._selected and real_path != self._selected:
197
item_iter = store.append([
199
real_path.encode('UTF-8'),
201
display_path.encode('UTF-8'),
203
'', # Initial comment
205
if self._selected and enabled:
206
initial_cursor = store.get_path(item_iter)
183
for (file_id, paths, changed_content, versioned, parent_ids, names,
184
kinds, executables) in self._wt._iter_changes(self._basis_tree):
186
# Skip the root entry.
187
if parent_ids == (None, None):
194
source_marker = osutils.kind_marker(kinds[0])
196
assert kinds[0] is not None
197
marker = osutils.kind_marker(kinds[0])
199
marker = osutils.kind_marker(kinds[1])
202
if real_path is None:
204
assert real_path is not None
205
display_path = real_path + marker
207
present_source = versioned[0] and kinds[0] is not None
208
present_target = versioned[1] and kinds[1] is not None
210
if present_source != present_target:
214
change_type = removed
215
elif names[0] != names[1] or parent_ids[0] != parent_ids[1]:
217
if changed_content or executables[0] != executables[1]:
219
change_type = renamed_and_modified
221
change_type = renamed
222
display_path = (paths[0] + source_marker
223
+ ' => ' + paths[1] + marker)
224
elif kinds[0] != kinds[1]:
225
change_type = kind_changed
226
display_path = (paths[0] + source_marker
227
+ ' => ' + paths[1] + marker)
228
elif changed_content is True or executables[0] != executables[1]:
229
change_type = modified
231
assert False, "How did we get here?"
233
store.append([file_id, real_path, True, display_path,
208
236
self._basis_tree.unlock()
209
237
self._wt.unlock()
211
239
self._treeview_files.set_model(store)
212
240
self._last_selected_file = None
213
# This sets the cursor, which causes the expander to close, which
214
# causes the _file_message_text_view to never get realized. So we have
215
# to give it a little kick, or it warns when we try to grab the focus
216
self._treeview_files.set_cursor(initial_cursor)
218
def _realize_file_message_tree_view(*args):
219
self._file_message_text_view.realize()
220
self.connect_after('realize', _realize_file_message_tree_view)
241
self._treeview_files.set_cursor(0)
222
243
def _fill_in_diff(self):
223
244
self._diff_view.set_trees(self._wt, self._basis_tree)
482
438
self._pending_store = liststore
483
439
self._treeview_pending.set_model(liststore)
484
self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Date'),
440
self._treeview_pending.append_column(gtk.TreeViewColumn(_('Date'),
485
441
gtk.CellRendererText(), text=1))
486
self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Committer'),
442
self._treeview_pending.append_column(gtk.TreeViewColumn(_('Committer'),
487
443
gtk.CellRendererText(), text=2))
488
self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Summary'),
444
self._treeview_pending.append_column(gtk.TreeViewColumn(_('Summary'),
489
445
gtk.CellRendererText(), text=3))
491
447
def _construct_diff_view(self):
492
448
from diff import DiffView
494
# TODO: jam 2007-10-30 The diff label is currently disabled. If we
495
# decide that we really don't ever want to display it, we should
496
# actually remove it, and other references to it, along with the
497
# tests that it is set properly.
498
self._diff_label = gtk.Label(_i18n('Diff for whole tree'))
450
self._diff_label = gtk.Label(_('Diff for whole tree'))
499
451
self._diff_label.set_alignment(0, 0)
500
452
self._right_pane_table.set_row_spacing(self._right_pane_table_row, 0)
501
453
self._add_to_right_table(self._diff_label, 1, False)
502
# self._diff_label.show()
454
self._diff_label.show()
504
456
self._diff_view = DiffView()
505
457
self._add_to_right_table(self._diff_view, 4, True)
506
458
self._diff_view.show()
508
460
def _construct_file_message(self):
461
file_message_box = gtk.VBox()
509
462
scroller = gtk.ScrolledWindow()
510
463
scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
512
465
self._file_message_text_view = gtk.TextView()
513
466
scroller.add(self._file_message_text_view)
514
468
scroller.set_shadow_type(gtk.SHADOW_IN)
469
file_message_box.pack_start(scroller, expand=True, fill=True)
517
471
self._file_message_text_view.modify_font(pango.FontDescription("Monospace"))
518
472
self._file_message_text_view.set_wrap_mode(gtk.WRAP_WORD)
519
473
self._file_message_text_view.set_accepts_tab(False)
520
474
self._file_message_text_view.show()
522
self._file_message_expander = gtk.Expander(_i18n('File commit message'))
523
self._file_message_expander.set_expanded(True)
524
self._file_message_expander.add(scroller)
476
self._file_message_expander = gtk.Expander(_('File commit message'))
477
self._file_message_expander.add(file_message_box)
478
file_message_box.show()
525
479
self._add_to_right_table(self._file_message_expander, 1, False)
526
480
self._file_message_expander.show()
528
482
def _construct_global_message(self):
529
self._global_message_label = gtk.Label(_i18n('Global Commit Message'))
530
self._global_message_label.set_markup(
531
_i18n('<b>Global Commit Message</b>'))
483
self._global_message_label = gtk.Label(_('Global Commit Message'))
532
484
self._global_message_label.set_alignment(0, 0)
533
485
self._right_pane_table.set_row_spacing(self._right_pane_table_row, 0)
534
486
self._add_to_right_table(self._global_message_label, 1, False)
734
650
show_offset=False)
735
651
rev_dict['revision_id'] = rev.revision_id
655
# class CommitDialog(gtk.Dialog):
656
# """ New implementation of the Commit dialog. """
657
# def __init__(self, wt, wtpath, notbranch, selected=None, parent=None):
658
# """ Initialize the Commit Dialog. """
659
# gtk.Dialog.__init__(self, title="Commit - Olive",
662
# buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
666
# self.wtpath = wtpath
667
# self.notbranch = notbranch
668
# self.selected = selected
671
# self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
672
# self.delta = self.wt.changes_from(self.old_tree)
674
# # Get pending merges
675
# self.pending = self._pending_merges(self.wt)
677
# # Do some preliminary checks
678
# self._is_checkout = False
679
# self._is_pending = False
680
# if self.wt is None and not self.notbranch:
681
# error_dialog(_('Directory does not have a working tree'),
682
# _('Operation aborted.'))
687
# error_dialog(_('Directory is not a branch'),
688
# _('You can perform this action only in a branch.'))
692
# if self.wt.branch.get_bound_location() is not None:
693
# # we have a checkout, so the local commit checkbox must appear
694
# self._is_checkout = True
697
# # There are pending merges, file selection not supported
698
# self._is_pending = True
700
# # Create the widgets
701
# # This is the main horizontal box, which is used to separate the commit
702
# # info from the diff window.
703
# self._hpane = gtk.HPaned()
704
# self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
705
# self._expander_files = gtk.Expander(_("File(s) to commit"))
706
# self._vpaned_main = gtk.VPaned()
707
# self._scrolledwindow_files = gtk.ScrolledWindow()
708
# self._scrolledwindow_message = gtk.ScrolledWindow()
709
# self._treeview_files = gtk.TreeView()
710
# self._vbox_message = gtk.VBox()
711
# self._label_message = gtk.Label(_("Commit message:"))
712
# self._textview_message = gtk.TextView()
714
# if self._is_pending:
715
# self._expander_merges = gtk.Expander(_("Pending merges"))
716
# self._vpaned_list = gtk.VPaned()
717
# self._scrolledwindow_merges = gtk.ScrolledWindow()
718
# self._treeview_merges = gtk.TreeView()
721
# self._button_commit.connect('clicked', self._on_commit_clicked)
722
# self._treeview_files.connect('cursor-changed', self._on_treeview_files_cursor_changed)
723
# self._treeview_files.connect('row-activated', self._on_treeview_files_row_activated)
726
# self._scrolledwindow_files.set_policy(gtk.POLICY_AUTOMATIC,
727
# gtk.POLICY_AUTOMATIC)
728
# self._scrolledwindow_message.set_policy(gtk.POLICY_AUTOMATIC,
729
# gtk.POLICY_AUTOMATIC)
730
# self._textview_message.modify_font(pango.FontDescription("Monospace"))
731
# self.set_default_size(500, 500)
732
# self._vpaned_main.set_position(200)
733
# self._button_commit.set_flags(gtk.CAN_DEFAULT)
735
# if self._is_pending:
736
# self._scrolledwindow_merges.set_policy(gtk.POLICY_AUTOMATIC,
737
# gtk.POLICY_AUTOMATIC)
738
# self._treeview_files.set_sensitive(False)
740
# # Construct the dialog
741
# self.action_area.pack_end(self._button_commit)
743
# self._scrolledwindow_files.add(self._treeview_files)
744
# self._scrolledwindow_message.add(self._textview_message)
746
# self._expander_files.add(self._scrolledwindow_files)
748
# self._vbox_message.pack_start(self._label_message, False, False)
749
# self._vbox_message.pack_start(self._scrolledwindow_message, True, True)
751
# if self._is_pending:
752
# self._expander_merges.add(self._scrolledwindow_merges)
753
# self._scrolledwindow_merges.add(self._treeview_merges)
754
# self._vpaned_list.add1(self._expander_files)
755
# self._vpaned_list.add2(self._expander_merges)
756
# self._vpaned_main.add1(self._vpaned_list)
758
# self._vpaned_main.add1(self._expander_files)
760
# self._vpaned_main.add2(self._vbox_message)
762
# self._hpane.pack1(self._vpaned_main)
763
# self.vbox.pack_start(self._hpane, expand=True, fill=True)
764
# if self._is_checkout:
765
# self._check_local = gtk.CheckButton(_("_Only commit locally"),
766
# use_underline=True)
767
# self.vbox.pack_start(self._check_local, False, False)
769
# bus = dbus.SystemBus()
770
# proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
771
# '/org/freedesktop/NetworkManager')
772
# dbus_iface = dbus.Interface(
773
# proxy_obj, 'org.freedesktop.NetworkManager')
775
# # 3 is the enum value for STATE_CONNECTED
776
# self._check_local.set_active(dbus_iface.state() != 3)
777
# except dbus.DBusException, e:
778
# # Silently drop errors. While DBus may be
779
# # available, NetworkManager doesn't necessarily have to be
780
# mutter("unable to get networkmanager state: %r" % e)
782
# # Create the file list
783
# self._create_file_view()
784
# # Create the pending merges
785
# self._create_pending_merges()
786
# self._create_diff_view()
788
# # Expand the corresponding expander
789
# if self._is_pending:
790
# self._expander_merges.set_expanded(True)
792
# self._expander_files.set_expanded(True)
795
# self.vbox.show_all()
797
# # Default to Commit button
798
# self._button_commit.grab_default()
800
# def _show_diff_view(self, treeview):
801
# # FIXME: the diff window freezes for some reason
802
# treeselection = treeview.get_selection()
803
# (model, iter) = treeselection.get_selected()
805
# if iter is not None:
806
# selected = model.get_value(iter, 3) # Get the real_path attribute
807
# self._diff_display.show_diff([selected])
809
# def _on_treeview_files_cursor_changed(self, treeview):
810
# self._show_diff_view(treeview)
812
# def _on_treeview_files_row_activated(self, treeview, path, view_column):
813
# self._show_diff_view(treeview)
816
# def _on_commit_clicked(self, button):
817
# """ Commit button clicked handler. """
818
# textbuffer = self._textview_message.get_buffer()
819
# start, end = textbuffer.get_bounds()
820
# message = textbuffer.get_text(start, end).decode('utf-8')
822
# if not self.pending:
823
# specific_files = self._get_specific_files()
825
# specific_files = None
828
# response = question_dialog(_('Commit with an empty message?'),
829
# _('You can describe your commit intent in the message.'))
830
# if response == gtk.RESPONSE_NO:
831
# # Kindly give focus to message area
832
# self._textview_message.grab_focus()
835
# if self._is_checkout:
836
# local = self._check_local.get_active()
840
# if list(self.wt.unknowns()) != []:
841
# response = question_dialog(_("Commit with unknowns?"),
842
# _("Unknown files exist in the working tree. Commit anyway?"))
843
# if response == gtk.RESPONSE_NO:
847
# self.wt.commit(message,
848
# allow_pointless=False,
851
# specific_files=specific_files)
852
# except errors.PointlessCommit:
853
# response = question_dialog(_('Commit with no changes?'),
854
# _('There are no changes in the working tree.'))
855
# if response == gtk.RESPONSE_YES:
856
# self.wt.commit(message,
857
# allow_pointless=True,
860
# specific_files=specific_files)
861
# self.response(gtk.RESPONSE_OK)
863
# def _pending_merges(self, wt):
864
# """ Return a list of pending merges or None if there are none of them. """
865
# parents = wt.get_parent_ids()
866
# if len(parents) < 2:
870
# from bzrlib.osutils import format_date
872
# pending = parents[1:]
874
# last_revision = parents[0]
876
# if last_revision is not None:
878
# ignore = set(branch.repository.get_ancestry(last_revision))
879
# except errors.NoSuchRevision:
880
# # the last revision is a ghost : assume everything is new
882
# ignore = set([None, last_revision])
884
# ignore = set([None])
887
# for merge in pending:
890
# m_revision = branch.repository.get_revision(merge)
893
# rev['committer'] = re.sub('<.*@.*>', '', m_revision.committer).strip(' ')
894
# rev['summary'] = m_revision.get_summary()
895
# rev['date'] = format_date(m_revision.timestamp,
896
# m_revision.timezone or 0,
897
# 'original', date_fmt="%Y-%m-%d",
902
# inner_merges = branch.repository.get_ancestry(merge)
903
# assert inner_merges[0] is None
904
# inner_merges.pop(0)
905
# inner_merges.reverse()
906
# for mmerge in inner_merges:
907
# if mmerge in ignore:
909
# mm_revision = branch.repository.get_revision(mmerge)
912
# rev['committer'] = re.sub('<.*@.*>', '', mm_revision.committer).strip(' ')
913
# rev['summary'] = mm_revision.get_summary()
914
# rev['date'] = format_date(mm_revision.timestamp,
915
# mm_revision.timezone or 0,
916
# 'original', date_fmt="%Y-%m-%d",
922
# except errors.NoSuchRevision:
923
# print "DEBUG: NoSuchRevision:", merge
927
# def _create_file_view(self):
928
# self._file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, # [0] checkbox
929
# gobject.TYPE_STRING, # [1] path to display
930
# gobject.TYPE_STRING, # [2] changes type
931
# gobject.TYPE_STRING) # [3] real path
932
# self._treeview_files.set_model(self._file_store)
933
# crt = gtk.CellRendererToggle()
934
# crt.set_property("activatable", True)
935
# crt.connect("toggled", self._toggle_commit, self._file_store)
936
# self._treeview_files.append_column(gtk.TreeViewColumn(_('Commit'),
938
# self._treeview_files.append_column(gtk.TreeViewColumn(_('Path'),
939
# gtk.CellRendererText(), text=1))
940
# self._treeview_files.append_column(gtk.TreeViewColumn(_('Type'),
941
# gtk.CellRendererText(), text=2))
943
# for path, id, kind in self.delta.added:
944
# marker = osutils.kind_marker(kind)
945
# if self.selected is not None:
946
# if path == os.path.join(self.wtpath, self.selected):
947
# self._file_store.append([ True, path+marker, _('added'), path ])
949
# self._file_store.append([ False, path+marker, _('added'), path ])
951
# self._file_store.append([ True, path+marker, _('added'), path ])
953
# for path, id, kind in self.delta.removed:
954
# marker = osutils.kind_marker(kind)
955
# if self.selected is not None:
956
# if path == os.path.join(self.wtpath, self.selected):
957
# self._file_store.append([ True, path+marker, _('removed'), path ])
959
# self._file_store.append([ False, path+marker, _('removed'), path ])
961
# self._file_store.append([ True, path+marker, _('removed'), path ])
963
# for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
964
# marker = osutils.kind_marker(kind)
965
# if text_modified or meta_modified:
966
# changes = _('renamed and modified')
968
# changes = _('renamed')
969
# if self.selected is not None:
970
# if newpath == os.path.join(self.wtpath, self.selected):
971
# self._file_store.append([ True,
972
# oldpath+marker + ' => ' + newpath+marker,
977
# self._file_store.append([ False,
978
# oldpath+marker + ' => ' + newpath+marker,
983
# self._file_store.append([ True,
984
# oldpath+marker + ' => ' + newpath+marker,
989
# for path, id, kind, text_modified, meta_modified in self.delta.modified:
990
# marker = osutils.kind_marker(kind)
991
# if self.selected is not None:
992
# if path == os.path.join(self.wtpath, self.selected):
993
# self._file_store.append([ True, path+marker, _('modified'), path ])
995
# self._file_store.append([ False, path+marker, _('modified'), path ])
997
# self._file_store.append([ True, path+marker, _('modified'), path ])
999
# def _create_pending_merges(self):
1000
# if not self.pending:
1003
# liststore = gtk.ListStore(gobject.TYPE_STRING,
1004
# gobject.TYPE_STRING,
1005
# gobject.TYPE_STRING)
1006
# self._treeview_merges.set_model(liststore)
1008
# self._treeview_merges.append_column(gtk.TreeViewColumn(_('Date'),
1009
# gtk.CellRendererText(), text=0))
1010
# self._treeview_merges.append_column(gtk.TreeViewColumn(_('Committer'),
1011
# gtk.CellRendererText(), text=1))
1012
# self._treeview_merges.append_column(gtk.TreeViewColumn(_('Summary'),
1013
# gtk.CellRendererText(), text=2))
1015
# for item in self.pending:
1016
# liststore.append([ item['date'],
1017
# item['committer'],
1018
# item['summary'] ])
1021
# def _create_diff_view(self):
1022
# from diff import DiffView
1024
# self._diff_display = DiffView()
1025
# self._diff_display.set_trees(self.wt, self.wt.basis_tree())
1026
# self._diff_display.show_diff(None)
1027
# self._diff_display.show()
1028
# self._hpane.pack2(self._diff_display)
1030
# def _get_specific_files(self):
1032
# it = self._file_store.get_iter_first()
1034
# if self._file_store.get_value(it, 0):
1035
# # get real path from hidden column 3
1036
# ret.append(self._file_store.get_value(it, 3))
1037
# it = self._file_store.iter_next(it)
1041
# def _toggle_commit(self, cell, path, model):
1042
# model[path][0] = not model[path][0]