/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: Aaron Bentley
  • Date: 2008-05-22 02:33:40 UTC
  • mfrom: (487.2.8 save-patch)
  • Revision ID: aaron@aaronbentley.com-20080522023340-3x585s8593j6a409
Allow saving from patch window, refactoring, testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import os.path
18
 
import re
19
 
 
20
17
try:
21
18
    import pygtk
22
19
    pygtk.require("2.0")
27
24
import gobject
28
25
import pango
29
26
 
 
27
import os.path
 
28
import re
 
29
 
30
30
from bzrlib import errors, osutils
31
31
from bzrlib.trace import mutter
32
32
from bzrlib.util import bencode
33
33
 
34
34
from bzrlib.plugins.gtk import _i18n
35
 
from bzrlib.plugins.gtk.dialog import question_dialog
36
 
from bzrlib.plugins.gtk.errors import show_bzr_error
 
35
from dialog import error_dialog, question_dialog
 
36
from errors import show_bzr_error
37
37
 
38
38
try:
39
39
    import dbus
97
97
    return pm
98
98
 
99
99
 
100
 
_newline_variants_re = re.compile(r'\r\n?')
101
 
def _sanitize_and_decode_message(utf8_message):
102
 
    """Turn a utf-8 message into a sanitized Unicode message."""
103
 
    fixed_newline = _newline_variants_re.sub('\n', utf8_message)
104
 
    return fixed_newline.decode('utf-8')
105
 
 
106
 
 
107
100
class CommitDialog(gtk.Dialog):
108
101
    """Implementation of Commit."""
109
102
 
110
103
    def __init__(self, wt, selected=None, parent=None):
111
 
        gtk.Dialog.__init__(self, title="Commit to %s" % wt.basedir,
 
104
        gtk.Dialog.__init__(self, title="Commit - Olive",
112
105
                                  parent=parent,
113
106
                                  flags=0,
114
 
                                  buttons=(gtk.STOCK_CANCEL,
115
 
                                           gtk.RESPONSE_CANCEL))
 
107
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
116
108
        self._question_dialog = question_dialog
117
109
 
118
110
        self._wt = wt
311
303
                            gtk.gdk.CONTROL_MASK, 0, self._on_accel_next)
312
304
        self.add_accel_group(group)
313
305
 
314
 
        # ignore the escape key (avoid closing the window)
315
 
        self.connect_object('close', self.emit_stop_by_name, 'close')
316
 
 
317
306
    def _construct_left_pane(self):
318
307
        self._left_pane_box = gtk.VBox(homogeneous=False, spacing=5)
319
308
        self._construct_file_list()
638
627
            if self._commit_all_changes or record[2]:# [2] checkbox
639
628
                file_id = record[0] # [0] file_id
640
629
                path = record[1]    # [1] real path
641
 
                # [5] commit message
642
 
                file_message = _sanitize_and_decode_message(record[5])
 
630
                file_message = record[5] # [5] commit message
643
631
                files.append(path.decode('UTF-8'))
644
632
                if self._enable_per_file_commits and file_message:
645
633
                    # All of this needs to be utf-8 information
646
 
                    file_message = file_message.encode('UTF-8')
647
634
                    file_info.append({'path':path, 'file_id':file_id,
648
635
                                     'message':file_message})
649
636
        file_info.sort(key=lambda x:(x['path'], x['file_id']))
663
650
        if message == '':
664
651
            response = self._question_dialog(
665
652
                _i18n('Commit with an empty message?'),
666
 
                _i18n('You can describe your commit intent in the message.'),
667
 
                parent=self)
 
653
                _i18n('You can describe your commit intent in the message.'))
668
654
            if response == gtk.RESPONSE_NO:
669
655
                # Kindly give focus to message area
670
656
                self._global_message_text_view.grab_focus()
684
670
        for path in self._wt.unknowns():
685
671
            response = self._question_dialog(
686
672
                _i18n("Commit with unknowns?"),
687
 
                _i18n("Unknown files exist in the working tree. Commit anyway?"),
688
 
                parent=self)
689
 
                # Doesn't set a parent for the dialog..
 
673
                _i18n("Unknown files exist in the working tree. Commit anyway?"))
690
674
            if response == gtk.RESPONSE_NO:
691
675
                return
692
676
            break
706
690
            response = self._question_dialog(
707
691
                _i18n('Commit with no changes?'),
708
692
                _i18n('There are no changes in the working tree.'
709
 
                      ' Do you want to commit anyway?'),
710
 
                parent=self)
 
693
                      ' Do you want to commit anyway?'))
711
694
            if response == gtk.RESPONSE_YES:
712
695
                rev_id = self._wt.commit(message,
713
696
                               allow_pointless=True,
721
704
    def _get_global_commit_message(self):
722
705
        buf = self._global_message_text_view.get_buffer()
723
706
        start, end = buf.get_bounds()
724
 
        text = buf.get_text(start, end)
725
 
        return _sanitize_and_decode_message(text)
 
707
        return buf.get_text(start, end).decode('utf-8')
726
708
 
727
709
    def _set_global_commit_message(self, message):
728
710
        """Just a helper for the test suite."""