/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-11 17:14:12 UTC
  • Revision ID: jelmer@samba.org-20111211171412-cgcn0yas3zlcahzg
StartĀ onĀ 0.104.0.

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