/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: Jelmer Vernooij
  • Date: 2008-06-29 19:07:23 UTC
  • mto: This revision was merged to the branch mainline in revision 515.
  • Revision ID: jelmer@samba.org-20080629190723-l8mzg9x4oec0lhsl
Return cleartext from seahorse module

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
 
        
118
 
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
119
109
 
120
110
        self._wt = wt
121
111
        # TODO: Do something with this value, it is used by Olive
640
630
            if self._commit_all_changes or record[2]:# [2] checkbox
641
631
                file_id = record[0] # [0] file_id
642
632
                path = record[1]    # [1] real path
643
 
                # [5] commit message
644
 
                file_message = _sanitize_and_decode_message(record[5])
 
633
                file_message = record[5] # [5] commit message
645
634
                files.append(path.decode('UTF-8'))
646
635
                if self._enable_per_file_commits and file_message:
647
636
                    # All of this needs to be utf-8 information
648
 
                    file_message = file_message.encode('UTF-8')
649
637
                    file_info.append({'path':path, 'file_id':file_id,
650
638
                                     'message':file_message})
651
639
        file_info.sort(key=lambda x:(x['path'], x['file_id']))
665
653
        if message == '':
666
654
            response = self._question_dialog(
667
655
                _i18n('Commit with an empty message?'),
668
 
                _i18n('You can describe your commit intent in the message.'),
669
 
                parent=self)
 
656
                _i18n('You can describe your commit intent in the message.'))
670
657
            if response == gtk.RESPONSE_NO:
671
658
                # Kindly give focus to message area
672
659
                self._global_message_text_view.grab_focus()
686
673
        for path in self._wt.unknowns():
687
674
            response = self._question_dialog(
688
675
                _i18n("Commit with unknowns?"),
689
 
                _i18n("Unknown files exist in the working tree. Commit anyway?"),
690
 
                parent=self)
691
 
                # Doesn't set a parent for the dialog..
 
676
                _i18n("Unknown files exist in the working tree. Commit anyway?"))
692
677
            if response == gtk.RESPONSE_NO:
693
678
                return
694
679
            break
708
693
            response = self._question_dialog(
709
694
                _i18n('Commit with no changes?'),
710
695
                _i18n('There are no changes in the working tree.'
711
 
                      ' Do you want to commit anyway?'),
712
 
                parent=self)
 
696
                      ' Do you want to commit anyway?'))
713
697
            if response == gtk.RESPONSE_YES:
714
698
                rev_id = self._wt.commit(message,
715
699
                               allow_pointless=True,
723
707
    def _get_global_commit_message(self):
724
708
        buf = self._global_message_text_view.get_buffer()
725
709
        start, end = buf.get_bounds()
726
 
        text = buf.get_text(start, end)
727
 
        return _sanitize_and_decode_message(text)
 
710
        return buf.get_text(start, end).decode('utf-8')
728
711
 
729
712
    def _set_global_commit_message(self, message):
730
713
        """Just a helper for the test suite."""