/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: 2011-12-20 16:16:57 UTC
  • Revision ID: jelmer@canonical.com-20111220161657-zjn6rqjrw8ouehf8
Drop support for old bencode location.

Show diffs side-by-side

added added

removed removed

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