/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:18:34 UTC
  • mto: This revision was merged to the branch mainline in revision 515.
  • Revision ID: jelmer@samba.org-20080629191834-ha2ecpv5szt96nge
Make sure signed testament matches repository data.

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