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

  • Committer: John Arbash Meinel
  • Date: 2007-10-12 17:26:02 UTC
  • mto: (322.1.1 trunk) (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: john@arbash-meinel.com-20071012172602-vdlj2cdrkczwyoqu
Cleanup, we are still ignoring the 'selected' property, and the 'wtpath'

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
        self._question_dialog = question_dialog
108
108
 
109
109
        self._wt = wt
 
110
        # TODO: Do something with this value, it is used by Olive
 
111
        #       It used to set all changes but this one to False
110
112
        self._selected = selected
111
113
        self._enable_per_file_commits = True
112
114
        self.committed_revision_id = None # Nothing has been committed yet
672
674
                                       show_offset=False)
673
675
        rev_dict['revision_id'] = rev.revision_id
674
676
        return rev_dict
675
 
 
676
 
 
677
 
# class CommitDialog(gtk.Dialog):
678
 
#     """ New implementation of the Commit dialog. """
679
 
#     def __init__(self, wt, wtpath, notbranch, selected=None, parent=None):
680
 
#         """ Initialize the Commit Dialog. """
681
 
#         gtk.Dialog.__init__(self, title="Commit - Olive",
682
 
#                                   parent=parent,
683
 
#                                   flags=0,
684
 
#                                   buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
685
 
#         
686
 
#         # Get arguments
687
 
#         self.wt = wt
688
 
#         self.wtpath = wtpath
689
 
#         self.notbranch = notbranch
690
 
#         self.selected = selected
691
 
#         
692
 
#         # Set the delta
693
 
#         self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
694
 
#         self.delta = self.wt.changes_from(self.old_tree)
695
 
#         
696
 
#         # Get pending merges
697
 
#         self.pending = self._pending_merges(self.wt)
698
 
#         
699
 
#         # Do some preliminary checks
700
 
#         self._is_checkout = False
701
 
#         self._is_pending = False
702
 
#         if self.wt is None and not self.notbranch:
703
 
#             error_dialog(_('Directory does not have a working tree'),
704
 
#                          _('Operation aborted.'))
705
 
#             self.close()
706
 
#             return
707
 
708
 
#         if self.notbranch:
709
 
#             error_dialog(_('Directory is not a branch'),
710
 
#                          _('You can perform this action only in a branch.'))
711
 
#             self.close()
712
 
#             return
713
 
#         else:
714
 
#             if self.wt.branch.get_bound_location() is not None:
715
 
#                 # we have a checkout, so the local commit checkbox must appear
716
 
#                 self._is_checkout = True
717
 
#             
718
 
#             if self.pending:
719
 
#                 # There are pending merges, file selection not supported
720
 
#                 self._is_pending = True
721
 
#         
722
 
#         # Create the widgets
723
 
#         # This is the main horizontal box, which is used to separate the commit
724
 
#         # info from the diff window.
725
 
#         self._hpane = gtk.HPaned()
726
 
#         self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
727
 
#         self._expander_files = gtk.Expander(_("File(s) to commit"))
728
 
#         self._vpaned_main = gtk.VPaned()
729
 
#         self._scrolledwindow_files = gtk.ScrolledWindow()
730
 
#         self._scrolledwindow_message = gtk.ScrolledWindow()
731
 
#         self._treeview_files = gtk.TreeView()
732
 
#         self._vbox_message = gtk.VBox()
733
 
#         self._label_message = gtk.Label(_("Commit message:"))
734
 
#         self._textview_message = gtk.TextView()
735
 
#         
736
 
#         if self._is_pending:
737
 
#             self._expander_merges = gtk.Expander(_("Pending merges"))
738
 
#             self._vpaned_list = gtk.VPaned()
739
 
#             self._scrolledwindow_merges = gtk.ScrolledWindow()
740
 
#             self._treeview_merges = gtk.TreeView()
741
 
742
 
#         # Set callbacks
743
 
#         self._button_commit.connect('clicked', self._on_commit_clicked)
744
 
#         self._treeview_files.connect('cursor-changed', self._on_treeview_files_cursor_changed)
745
 
#         self._treeview_files.connect('row-activated', self._on_treeview_files_row_activated)
746
 
#         
747
 
#         # Set properties
748
 
#         self._scrolledwindow_files.set_policy(gtk.POLICY_AUTOMATIC,
749
 
#                                               gtk.POLICY_AUTOMATIC)
750
 
#         self._scrolledwindow_message.set_policy(gtk.POLICY_AUTOMATIC,
751
 
#                                                 gtk.POLICY_AUTOMATIC)
752
 
#         self._textview_message.modify_font(pango.FontDescription("Monospace"))
753
 
#         self.set_default_size(500, 500)
754
 
#         self._vpaned_main.set_position(200)
755
 
#         self._button_commit.set_flags(gtk.CAN_DEFAULT)
756
 
757
 
#         if self._is_pending:
758
 
#             self._scrolledwindow_merges.set_policy(gtk.POLICY_AUTOMATIC,
759
 
#                                                    gtk.POLICY_AUTOMATIC)
760
 
#             self._treeview_files.set_sensitive(False)
761
 
#         
762
 
#         # Construct the dialog
763
 
#         self.action_area.pack_end(self._button_commit)
764
 
#         
765
 
#         self._scrolledwindow_files.add(self._treeview_files)
766
 
#         self._scrolledwindow_message.add(self._textview_message)
767
 
#         
768
 
#         self._expander_files.add(self._scrolledwindow_files)
769
 
#         
770
 
#         self._vbox_message.pack_start(self._label_message, False, False)
771
 
#         self._vbox_message.pack_start(self._scrolledwindow_message, True, True)
772
 
#         
773
 
#         if self._is_pending:        
774
 
#             self._expander_merges.add(self._scrolledwindow_merges)
775
 
#             self._scrolledwindow_merges.add(self._treeview_merges)
776
 
#             self._vpaned_list.add1(self._expander_files)
777
 
#             self._vpaned_list.add2(self._expander_merges)
778
 
#             self._vpaned_main.add1(self._vpaned_list)
779
 
#         else:
780
 
#             self._vpaned_main.add1(self._expander_files)
781
 
782
 
#         self._vpaned_main.add2(self._vbox_message)
783
 
#         
784
 
#         self._hpane.pack1(self._vpaned_main)
785
 
#         self.vbox.pack_start(self._hpane, expand=True, fill=True)
786
 
#         if self._is_checkout: 
787
 
#             self._check_local = gtk.CheckButton(_("_Only commit locally"),
788
 
#                                                 use_underline=True)
789
 
#             self.vbox.pack_start(self._check_local, False, False)
790
 
#             if have_dbus:
791
 
#                 bus = dbus.SystemBus()
792
 
#                 proxy_obj = bus.get_object('org.freedesktop.NetworkManager', 
793
 
#                               '/org/freedesktop/NetworkManager')
794
 
#                 dbus_iface = dbus.Interface(
795
 
#                         proxy_obj, 'org.freedesktop.NetworkManager')
796
 
#                 try:
797
 
#                     # 3 is the enum value for STATE_CONNECTED
798
 
#                     self._check_local.set_active(dbus_iface.state() != 3)
799
 
#                 except dbus.DBusException, e:
800
 
#                     # Silently drop errors. While DBus may be 
801
 
#                     # available, NetworkManager doesn't necessarily have to be
802
 
#                     mutter("unable to get networkmanager state: %r" % e)
803
 
#                 
804
 
#         # Create the file list
805
 
#         self._create_file_view()
806
 
#         # Create the pending merges
807
 
#         self._create_pending_merges()
808
 
#         self._create_diff_view()
809
 
#         
810
 
#         # Expand the corresponding expander
811
 
#         if self._is_pending:
812
 
#             self._expander_merges.set_expanded(True)
813
 
#         else:
814
 
#             self._expander_files.set_expanded(True)
815
 
#         
816
 
#         # Display dialog
817
 
#         self.vbox.show_all()
818
 
#         
819
 
#         # Default to Commit button
820
 
#         self._button_commit.grab_default()
821
 
#     
822
 
#     def _show_diff_view(self, treeview):
823
 
#         # FIXME: the diff window freezes for some reason
824
 
#         treeselection = treeview.get_selection()
825
 
#         (model, iter) = treeselection.get_selected()
826
 
827
 
#         if iter is not None:
828
 
#             selected = model.get_value(iter, 3) # Get the real_path attribute
829
 
#             self._diff_display.show_diff([selected])
830
 
831
 
#     def _on_treeview_files_cursor_changed(self, treeview):
832
 
#         self._show_diff_view(treeview)
833
 
#         
834
 
#     def _on_treeview_files_row_activated(self, treeview, path, view_column):
835
 
#         self._show_diff_view(treeview)
836
 
#     
837
 
#     @show_bzr_error
838
 
#     def _on_commit_clicked(self, button):
839
 
#         """ Commit button clicked handler. """
840
 
#         textbuffer = self._textview_message.get_buffer()
841
 
#         start, end = textbuffer.get_bounds()
842
 
#         message = textbuffer.get_text(start, end).decode('utf-8')
843
 
#         
844
 
#         if not self.pending:
845
 
#             specific_files = self._get_specific_files()
846
 
#         else:
847
 
#             specific_files = None
848
 
849
 
#         if message == '':
850
 
#             response = question_dialog(_('Commit with an empty message?'),
851
 
#                                        _('You can describe your commit intent in the message.'))
852
 
#             if response == gtk.RESPONSE_NO:
853
 
#                 # Kindly give focus to message area
854
 
#                 self._textview_message.grab_focus()
855
 
#                 return
856
 
857
 
#         if self._is_checkout:
858
 
#             local = self._check_local.get_active()
859
 
#         else:
860
 
#             local = False
861
 
862
 
#         if list(self.wt.unknowns()) != []:
863
 
#             response = question_dialog(_("Commit with unknowns?"),
864
 
#                _("Unknown files exist in the working tree. Commit anyway?"))
865
 
#             if response == gtk.RESPONSE_NO:
866
 
#                 return
867
 
#         
868
 
#         try:
869
 
#             self.wt.commit(message,
870
 
#                        allow_pointless=False,
871
 
#                        strict=False,
872
 
#                        local=local,
873
 
#                        specific_files=specific_files)
874
 
#         except errors.PointlessCommit:
875
 
#             response = question_dialog(_('Commit with no changes?'),
876
 
#                                        _('There are no changes in the working tree.'))
877
 
#             if response == gtk.RESPONSE_YES:
878
 
#                 self.wt.commit(message,
879
 
#                                allow_pointless=True,
880
 
#                                strict=False,
881
 
#                                local=local,
882
 
#                                specific_files=specific_files)
883
 
#         self.response(gtk.RESPONSE_OK)
884
 
885
 
#     def _pending_merges(self, wt):
886
 
#         """ Return a list of pending merges or None if there are none of them. """
887
 
#         parents = wt.get_parent_ids()
888
 
#         if len(parents) < 2:
889
 
#             return None
890
 
#         
891
 
#         import re
892
 
#         from bzrlib.osutils import format_date
893
 
#         
894
 
#         pending = parents[1:]
895
 
#         branch = wt.branch
896
 
#         last_revision = parents[0]
897
 
#         
898
 
#         if last_revision is not None:
899
 
#             try:
900
 
#                 ignore = set(branch.repository.get_ancestry(last_revision))
901
 
#             except errors.NoSuchRevision:
902
 
#                 # the last revision is a ghost : assume everything is new 
903
 
#                 # except for it
904
 
#                 ignore = set([None, last_revision])
905
 
#         else:
906
 
#             ignore = set([None])
907
 
#         
908
 
#         pm = []
909
 
#         for merge in pending:
910
 
#             ignore.add(merge)
911
 
#             try:
912
 
#                 m_revision = branch.repository.get_revision(merge)
913
 
#                 
914
 
#                 rev = {}
915
 
#                 rev['committer'] = re.sub('<.*@.*>', '', m_revision.committer).strip(' ')
916
 
#                 rev['summary'] = m_revision.get_summary()
917
 
#                 rev['date'] = format_date(m_revision.timestamp,
918
 
#                                           m_revision.timezone or 0, 
919
 
#                                           'original', date_fmt="%Y-%m-%d",
920
 
#                                           show_offset=False)
921
 
#                 
922
 
#                 pm.append(rev)
923
 
#                 
924
 
#                 inner_merges = branch.repository.get_ancestry(merge)
925
 
#                 assert inner_merges[0] is None
926
 
#                 inner_merges.pop(0)
927
 
#                 inner_merges.reverse()
928
 
#                 for mmerge in inner_merges:
929
 
#                     if mmerge in ignore:
930
 
#                         continue
931
 
#                     mm_revision = branch.repository.get_revision(mmerge)
932
 
#                     
933
 
#                     rev = {}
934
 
#                     rev['committer'] = re.sub('<.*@.*>', '', mm_revision.committer).strip(' ')
935
 
#                     rev['summary'] = mm_revision.get_summary()
936
 
#                     rev['date'] = format_date(mm_revision.timestamp,
937
 
#                                               mm_revision.timezone or 0, 
938
 
#                                               'original', date_fmt="%Y-%m-%d",
939
 
#                                               show_offset=False)
940
 
#                 
941
 
#                     pm.append(rev)
942
 
#                     
943
 
#                     ignore.add(mmerge)
944
 
#             except errors.NoSuchRevision:
945
 
#                 print "DEBUG: NoSuchRevision:", merge
946
 
#         
947
 
#         return pm
948
 
949
 
#     def _create_file_view(self):
950
 
#         self._file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,   # [0] checkbox
951
 
#                                          gobject.TYPE_STRING,    # [1] path to display
952
 
#                                          gobject.TYPE_STRING,    # [2] changes type
953
 
#                                          gobject.TYPE_STRING)    # [3] real path
954
 
#         self._treeview_files.set_model(self._file_store)
955
 
#         crt = gtk.CellRendererToggle()
956
 
#         crt.set_property("activatable", True)
957
 
#         crt.connect("toggled", self._toggle_commit, self._file_store)
958
 
#         self._treeview_files.append_column(gtk.TreeViewColumn(_('Commit'),
959
 
#                                      crt, active=0))
960
 
#         self._treeview_files.append_column(gtk.TreeViewColumn(_('Path'),
961
 
#                                      gtk.CellRendererText(), text=1))
962
 
#         self._treeview_files.append_column(gtk.TreeViewColumn(_('Type'),
963
 
#                                      gtk.CellRendererText(), text=2))
964
 
965
 
#         for path, id, kind in self.delta.added:
966
 
#             marker = osutils.kind_marker(kind)
967
 
#             if self.selected is not None:
968
 
#                 if path == os.path.join(self.wtpath, self.selected):
969
 
#                     self._file_store.append([ True, path+marker, _('added'), path ])
970
 
#                 else:
971
 
#                     self._file_store.append([ False, path+marker, _('added'), path ])
972
 
#             else:
973
 
#                 self._file_store.append([ True, path+marker, _('added'), path ])
974
 
975
 
#         for path, id, kind in self.delta.removed:
976
 
#             marker = osutils.kind_marker(kind)
977
 
#             if self.selected is not None:
978
 
#                 if path == os.path.join(self.wtpath, self.selected):
979
 
#                     self._file_store.append([ True, path+marker, _('removed'), path ])
980
 
#                 else:
981
 
#                     self._file_store.append([ False, path+marker, _('removed'), path ])
982
 
#             else:
983
 
#                 self._file_store.append([ True, path+marker, _('removed'), path ])
984
 
985
 
#         for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
986
 
#             marker = osutils.kind_marker(kind)
987
 
#             if text_modified or meta_modified:
988
 
#                 changes = _('renamed and modified')
989
 
#             else:
990
 
#                 changes = _('renamed')
991
 
#             if self.selected is not None:
992
 
#                 if newpath == os.path.join(self.wtpath, self.selected):
993
 
#                     self._file_store.append([ True,
994
 
#                                               oldpath+marker + '  =>  ' + newpath+marker,
995
 
#                                               changes,
996
 
#                                               newpath
997
 
#                                             ])
998
 
#                 else:
999
 
#                     self._file_store.append([ False,
1000
 
#                                               oldpath+marker + '  =>  ' + newpath+marker,
1001
 
#                                               changes,
1002
 
#                                               newpath
1003
 
#                                             ])
1004
 
#             else:
1005
 
#                 self._file_store.append([ True,
1006
 
#                                           oldpath+marker + '  =>  ' + newpath+marker,
1007
 
#                                           changes,
1008
 
#                                           newpath
1009
 
#                                         ])
1010
 
1011
 
#         for path, id, kind, text_modified, meta_modified in self.delta.modified:
1012
 
#             marker = osutils.kind_marker(kind)
1013
 
#             if self.selected is not None:
1014
 
#                 if path == os.path.join(self.wtpath, self.selected):
1015
 
#                     self._file_store.append([ True, path+marker, _('modified'), path ])
1016
 
#                 else:
1017
 
#                     self._file_store.append([ False, path+marker, _('modified'), path ])
1018
 
#             else:
1019
 
#                 self._file_store.append([ True, path+marker, _('modified'), path ])
1020
 
#     
1021
 
#     def _create_pending_merges(self):
1022
 
#         if not self.pending:
1023
 
#             return
1024
 
#         
1025
 
#         liststore = gtk.ListStore(gobject.TYPE_STRING,
1026
 
#                                   gobject.TYPE_STRING,
1027
 
#                                   gobject.TYPE_STRING)
1028
 
#         self._treeview_merges.set_model(liststore)
1029
 
#         
1030
 
#         self._treeview_merges.append_column(gtk.TreeViewColumn(_('Date'),
1031
 
#                                             gtk.CellRendererText(), text=0))
1032
 
#         self._treeview_merges.append_column(gtk.TreeViewColumn(_('Committer'),
1033
 
#                                             gtk.CellRendererText(), text=1))
1034
 
#         self._treeview_merges.append_column(gtk.TreeViewColumn(_('Summary'),
1035
 
#                                             gtk.CellRendererText(), text=2))
1036
 
#         
1037
 
#         for item in self.pending:
1038
 
#             liststore.append([ item['date'],
1039
 
#                                item['committer'],
1040
 
#                                item['summary'] ])
1041
 
#     
1042
 
1043
 
#     def _create_diff_view(self):
1044
 
#         from diff import DiffView
1045
 
1046
 
#         self._diff_display = DiffView()
1047
 
#         self._diff_display.set_trees(self.wt, self.wt.basis_tree())
1048
 
#         self._diff_display.show_diff(None)
1049
 
#         self._diff_display.show()
1050
 
#         self._hpane.pack2(self._diff_display)
1051
 
1052
 
#     def _get_specific_files(self):
1053
 
#         ret = []
1054
 
#         it = self._file_store.get_iter_first()
1055
 
#         while it:
1056
 
#             if self._file_store.get_value(it, 0):
1057
 
#                 # get real path from hidden column 3
1058
 
#                 ret.append(self._file_store.get_value(it, 3))
1059
 
#             it = self._file_store.iter_next(it)
1060
 
1061
 
#         return ret
1062
 
#     
1063
 
#     def _toggle_commit(self, cell, path, model):
1064
 
#         model[path][0] = not model[path][0]
1065
 
#         return