/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: Curtis Hovey
  • Date: 2012-02-03 18:59:38 UTC
  • mto: This revision was merged to the branch mainline in revision 773.
  • Revision ID: sinzui.is@verizon.net-20120203185938-ra0jl3b1rn69gmmz
Verify the menu and its items are created.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from gi.repository import GObject
22
22
from gi.repository import Pango
23
23
 
24
 
try:
25
 
    from bzrlib import bencode
26
 
except ImportError:
27
 
    from bzrlib.util import bencode
28
 
 
29
24
from bzrlib import (
 
25
    bencode,
30
26
    errors,
 
27
    osutils,
31
28
    trace,
32
29
    )
33
30
from bzrlib.plugins.gtk.dialog import question_dialog
96
93
def _sanitize_and_decode_message(utf8_message):
97
94
    """Turn a utf-8 message into a sanitized Unicode message."""
98
95
    fixed_newline = _newline_variants_re.sub('\n', utf8_message)
99
 
    return fixed_newline.decode('utf-8')
 
96
    return osutils.safe_unicode(fixed_newline)
100
97
 
101
98
 
102
99
class CommitDialog(Gtk.Dialog):
117
114
        self._enable_per_file_commits = True
118
115
        self._commit_all_changes = True
119
116
        self.committed_revision_id = None # Nothing has been committed yet
 
117
        self._last_selected_file = None
120
118
        self._saved_commit_messages_manager = SavedCommitMessagesManager(
121
119
            self._wt, self._wt.branch)
122
120
 
190
188
 
191
189
        all_enabled = (self._selected is None)
192
190
        # The first entry is always the 'whole tree'
193
 
        all_iter = store.append([None, None, all_enabled, 'All Files', '', ''])
 
191
        all_iter = store.append(["", "", all_enabled, 'All Files', '', ''])
194
192
        initial_cursor = store.get_path(all_iter)
195
193
        # should we pass specific_files?
196
194
        self._wt.lock_read()
447
445
                                     self._on_treeview_files_cursor_changed)
448
446
 
449
447
    def _toggle_commit(self, cell, path, model):
450
 
        if model[path][0] is None: # No file_id means 'All Files'
 
448
        if model[path][0] == "": # No file_id means 'All Files'
451
449
            new_val = not model[path][2]
452
450
            for node in model:
453
451
                node[2] = new_val
570
568
 
571
569
    def _on_treeview_files_cursor_changed(self, treeview):
572
570
        treeselection = treeview.get_selection()
 
571
        if treeselection is None:
 
572
            # The treeview was probably destroyed as the dialog closes.
 
573
            return
573
574
        (model, selection) = treeselection.get_selected()
574
575
 
575
576
        if selection is not None:
576
577
            path, display_path = model.get(selection, 1, 3)
577
578
            self._diff_label.set_text(_i18n('Diff for ') + display_path)
578
 
            if path is None:
 
579
            if path == "":
579
580
                self._diff_view.show_diff(None)
580
581
            else:
581
 
                self._diff_view.show_diff([path.decode('UTF-8')])
 
582
                self._diff_view.show_diff([osutils.safe_unicode(path)])
582
583
            self._update_per_file_info(selection)
583
584
 
584
585
    def _on_accel_next(self, accel_group, window, keyval, modifier):
596
597
            # selected. Either way, select All Files, and jump to the global
597
598
            # commit message.
598
599
            self._treeview_files.set_cursor(
599
 
                Gtk.TreePath(path=0), None, False)
 
600
                Gtk.TreePath(path=0), "", False)
600
601
            self._global_message_text_view.grab_focus()
601
602
        else:
602
603
            # Set the cursor to this entry, and jump to the per-file commit
621
622
        self._save_current_file_message()
622
623
        text_buffer = self._file_message_text_view.get_buffer()
623
624
        file_id, display_path, message = self._files_store.get(selection, 0, 3, 5)
624
 
        if file_id is None: # Whole tree
 
625
        if file_id == "": # Whole tree
625
626
            self._file_message_expander.set_label(_i18n('File commit message'))
626
627
            self._file_message_expander.set_expanded(False)
627
628
            self._file_message_expander.set_sensitive(False)
644
645
        files = []
645
646
        records = iter(self._files_store)
646
647
        rec = records.next() # Skip the All Files record
647
 
        assert rec[0] is None, "Are we skipping the wrong record?"
 
648
        assert rec[0] == "", "Are we skipping the wrong record?"
648
649
 
649
650
        file_info = []
650
651
        for record in records:
651
652
            if self._commit_all_changes or record[2]:# [2] checkbox
652
 
                file_id = record[0] # [0] file_id
653
 
                path = record[1]    # [1] real path
 
653
                file_id = osutils.safe_utf8(record[0]) # [0] file_id
 
654
                path = osutils.safe_utf8(record[1])    # [1] real path
654
655
                # [5] commit message
655
656
                file_message = _sanitize_and_decode_message(record[5])
656
657
                files.append(path.decode('UTF-8'))