/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-02 17:34:18 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-20071002173418-m7sabp62wnth76k3
Beginning to support actual commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
class CommitDialog(gtk.Dialog):
99
99
    """Implementation of Commit."""
100
100
 
 
101
    _question_dialog = question_dialog
 
102
 
101
103
    def __init__(self, wt, selected=None, parent=None):
102
104
        gtk.Dialog.__init__(self, title="Commit - Olive",
103
105
                                  parent=parent,
105
107
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
106
108
        self._wt = wt
107
109
        self._selected = selected
 
110
        self.committed_revision_id = None # Nothing has been committed yet
108
111
 
109
112
        self.setup_params()
110
113
        self.construct()
249
252
 
250
253
        self._construct_left_pane()
251
254
        self._construct_right_pane()
 
255
        self._construct_action_pane()
252
256
 
253
257
        self.vbox.pack_start(self._hpane)
254
258
        self._hpane.show()
296
300
        self._right_pane_table.show()
297
301
        self._hpane.pack2(self._right_pane_table, resize=True, shrink=True)
298
302
 
 
303
    def _construct_action_pane(self):
 
304
        self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
 
305
        self._button_commit.connect('clicked', self._on_commit_clicked)
 
306
        self._button_commit.set_flags(gtk.CAN_DEFAULT)
 
307
        self.action_area.pack_end(self._button_commit)
 
308
 
299
309
    def _add_to_right_table(self, widget, weight, expanding=False):
300
310
        """Add another widget to the table
301
311
 
503
513
            text_buffer.set_text(message)
504
514
            self._last_selected_file = self._files_store.get_path(selection)
505
515
 
 
516
    @show_bzr_error
 
517
    def _on_commit_clicked(self, button):
 
518
        """ Commit button clicked handler. """
 
519
        self._do_commit()
 
520
 
 
521
    def _do_commit(self):
 
522
        buf = self._global_message_text_view.get_buffer()
 
523
        start, end = buf.get_bounds()
 
524
        message = buf.get_text(start, end).decode('utf-8')
 
525
 
 
526
        if message == '':
 
527
            response = self._question_dialog(
 
528
                            _('Commit with an empty message?'),
 
529
                            _('You can describe your commit intent in the message.'))
 
530
            if response == gtk.RESPONSE_NO:
 
531
                # Kindly give focus to message area
 
532
                self._global_message_text_view.grab_focus()
 
533
                return
 
534
 
 
535
        # if not self.pending:
 
536
        #     specific_files = self._get_specific_files()
 
537
        # else:
 
538
        #     specific_files = None
 
539
 
 
540
        # if self._is_checkout:
 
541
        #     local = self._check_local.get_active()
 
542
        # else:
 
543
        #     local = False
 
544
 
 
545
        # if list(self._wt.unknowns()) != []:
 
546
        #     response = question_dialog(_("Commit with unknowns?"),
 
547
        #        _("Unknown files exist in the working tree. Commit anyway?"))
 
548
        #     if response == gtk.RESPONSE_NO:
 
549
        #         return
 
550
 
 
551
        local = False
 
552
        specific_files = None
 
553
        try:
 
554
            rev_id = self._wt.commit(message,
 
555
                       allow_pointless=False,
 
556
                       strict=False,
 
557
                       local=local,
 
558
                       specific_files=specific_files)
 
559
        except errors.PointlessCommit:
 
560
            response = question_dialog(_('Commit with no changes?'),
 
561
                                       _('There are no changes in the working tree.'))
 
562
            if response == gtk.RESPONSE_YES:
 
563
                rev_id = self._wt.commit(message,
 
564
                               allow_pointless=True,
 
565
                               strict=False,
 
566
                               local=local,
 
567
                               specific_files=specific_files)
 
568
        self.committed_revision_id = rev_id
 
569
        self.response(gtk.RESPONSE_OK)
 
570
 
506
571
    @staticmethod
507
572
    def _rev_to_pending_info(rev):
508
573
        """Get the information from a pending merge."""