/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: Daniel Schierbeck
  • Date: 2008-01-13 14:12:49 UTC
  • mto: (423.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 429.
  • Revision ID: daniel.schierbeck@gmail.com-20080113141249-gd0i2lknr3yik55r
Moved branch view to its own package.

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
 
30
 
from bzrlib import (
31
 
    branch,
32
 
    errors,
33
 
    osutils,
34
 
    trace,
35
 
    )
 
27
import os.path
 
28
import re
 
29
 
 
30
from bzrlib import errors, osutils
 
31
from bzrlib.trace import mutter
36
32
from bzrlib.util import bencode
37
33
 
38
 
from bzrlib.plugins.gtk import _i18n
39
 
from bzrlib.plugins.gtk.dialog import question_dialog
40
 
from bzrlib.plugins.gtk.errors import show_bzr_error
 
34
from dialog import error_dialog, question_dialog
 
35
from errors import show_bzr_error
41
36
 
42
37
try:
43
38
    import dbus
101
96
    return pm
102
97
 
103
98
 
104
 
_newline_variants_re = re.compile(r'\r\n?')
105
 
def _sanitize_and_decode_message(utf8_message):
106
 
    """Turn a utf-8 message into a sanitized Unicode message."""
107
 
    fixed_newline = _newline_variants_re.sub('\n', utf8_message)
108
 
    return fixed_newline.decode('utf-8')
109
 
 
110
 
 
111
99
class CommitDialog(gtk.Dialog):
112
100
    """Implementation of Commit."""
113
101
 
114
102
    def __init__(self, wt, selected=None, parent=None):
115
 
        gtk.Dialog.__init__(self, title="Commit to %s" % wt.basedir,
116
 
                            parent=parent, flags=0,)
117
 
        self.connect('delete-event', self._on_delete_window)
 
103
        gtk.Dialog.__init__(self, title="Commit - Olive",
 
104
                                  parent=parent,
 
105
                                  flags=0,
 
106
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
118
107
        self._question_dialog = question_dialog
119
108
 
120
 
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
121
 
 
122
109
        self._wt = wt
123
110
        # TODO: Do something with this value, it is used by Olive
124
111
        #       It used to set all changes but this one to False
126
113
        self._enable_per_file_commits = True
127
114
        self._commit_all_changes = True
128
115
        self.committed_revision_id = None # Nothing has been committed yet
129
 
        self._saved_commit_messages_manager = SavedCommitMessagesManager(self._wt, self._wt.branch)
130
116
 
131
117
        self.setup_params()
132
118
        self.construct()
178
164
        store = self._files_store
179
165
        self._treeview_files.set_model(None)
180
166
 
181
 
        added = _i18n('added')
182
 
        removed = _i18n('removed')
183
 
        renamed = _i18n('renamed')
184
 
        renamed_and_modified = _i18n('renamed and modified')
185
 
        modified = _i18n('modified')
186
 
        kind_changed = _i18n('kind changed')
 
167
        added = _('added')
 
168
        removed = _('removed')
 
169
        renamed = _('renamed')
 
170
        renamed_and_modified = _('renamed and modified')
 
171
        modified = _('modified')
 
172
        kind_changed = _('kind changed')
187
173
 
188
174
        # The store holds:
189
175
        # [file_id, real path, checkbox, display path, changes type, message]
190
 
        # iter_changes returns:
 
176
        # _iter_changes returns:
191
177
        # (file_id, (path_in_source, path_in_target),
192
178
        #  changed_content, versioned, parent, name, kind,
193
179
        #  executable)
200
186
        self._wt.lock_read()
201
187
        self._basis_tree.lock_read()
202
188
        try:
203
 
            from diff import iter_changes_to_status
204
 
            saved_file_messages = self._saved_commit_messages_manager.get()[1]
 
189
            from diff import _iter_changes_to_status
205
190
            for (file_id, real_path, change_type, display_path
206
 
                ) in iter_changes_to_status(self._basis_tree, self._wt):
 
191
                ) in _iter_changes_to_status(self._basis_tree, self._wt):
207
192
                if self._selected and real_path != self._selected:
208
193
                    enabled = False
209
194
                else:
210
195
                    enabled = True
211
 
                try:
212
 
                    default_message = saved_file_messages[file_id]
213
 
                except KeyError:
214
 
                    default_message = ''
215
196
                item_iter = store.append([
216
197
                    file_id,
217
198
                    real_path.encode('UTF-8'),
218
199
                    enabled,
219
200
                    display_path.encode('UTF-8'),
220
201
                    change_type,
221
 
                    default_message, # Initial comment
 
202
                    '', # Initial comment
222
203
                    ])
223
204
                if self._selected and enabled:
224
205
                    initial_cursor = store.get_path(item_iter)
246
227
            return
247
228
        if have_dbus:
248
229
            bus = dbus.SystemBus()
249
 
            try:
250
 
                proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
251
 
                                           '/org/freedesktop/NetworkManager')
252
 
            except dbus.DBusException:
253
 
                trace.mutter("networkmanager not available.")
254
 
                self._check_local.show()
255
 
                return
256
 
            
 
230
            proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
 
231
                                       '/org/freedesktop/NetworkManager')
257
232
            dbus_iface = dbus.Interface(proxy_obj,
258
233
                                        'org.freedesktop.NetworkManager')
259
234
            try:
262
237
            except dbus.DBusException, e:
263
238
                # Silently drop errors. While DBus may be
264
239
                # available, NetworkManager doesn't necessarily have to be
265
 
                trace.mutter("unable to get networkmanager state: %r" % e)
 
240
                mutter("unable to get networkmanager state: %r" % e)
266
241
        self._check_local.show()
267
242
 
268
243
    def _fill_in_per_file_info(self):
276
251
            self._enable_per_file_commits = True
277
252
        if not self._enable_per_file_commits:
278
253
            self._file_message_expander.hide()
279
 
            self._global_message_label.set_markup(_i18n('<b>Commit Message</b>'))
 
254
            self._global_message_label.set_markup(_('<b>Commit Message</b>'))
280
255
 
281
256
    def _compute_delta(self):
282
257
        self._delta = self._wt.changes_from(self._basis_tree)
321
296
                            gtk.gdk.CONTROL_MASK, 0, self._on_accel_next)
322
297
        self.add_accel_group(group)
323
298
 
324
 
        # ignore the escape key (avoid closing the window)
325
 
        self.connect_object('close', self.emit_stop_by_name, 'close')
326
 
 
327
299
    def _construct_left_pane(self):
328
300
        self._left_pane_box = gtk.VBox(homogeneous=False, spacing=5)
329
301
        self._construct_file_list()
330
302
        self._construct_pending_list()
331
303
 
332
 
        self._check_local = gtk.CheckButton(_i18n("_Only commit locally"),
 
304
        self._check_local = gtk.CheckButton(_("_Only commit locally"),
333
305
                                            use_underline=True)
334
306
        self._left_pane_box.pack_end(self._check_local, False, False)
335
307
        self._check_local.set_active(False)
356
328
        self._hpane.pack2(self._right_pane_table, resize=True, shrink=True)
357
329
 
358
330
    def _construct_action_pane(self):
359
 
        self._button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
360
 
        self._button_cancel.connect('clicked', self._on_cancel_clicked)
361
 
        self._button_cancel.show()
362
 
        self.action_area.pack_end(self._button_cancel)
363
 
        self._button_commit = gtk.Button(_i18n("Comm_it"), use_underline=True)
 
331
        self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
364
332
        self._button_commit.connect('clicked', self._on_commit_clicked)
365
333
        self._button_commit.set_flags(gtk.CAN_DEFAULT)
366
334
        self._button_commit.show()
386
354
 
387
355
    def _construct_file_list(self):
388
356
        self._files_box = gtk.VBox(homogeneous=False, spacing=0)
389
 
        file_label = gtk.Label(_i18n('Files'))
 
357
        file_label = gtk.Label(_('Files'))
390
358
        # file_label.show()
391
359
        self._files_box.pack_start(file_label, expand=False)
392
360
 
393
361
        self._commit_all_files_radio = gtk.RadioButton(
394
 
            None, _i18n("Commit all changes"))
 
362
            None, _("Commit all changes"))
395
363
        self._files_box.pack_start(self._commit_all_files_radio, expand=False)
396
364
        self._commit_all_files_radio.show()
397
365
        self._commit_all_files_radio.connect('toggled',
398
366
            self._toggle_commit_selection)
399
367
        self._commit_selected_radio = gtk.RadioButton(
400
 
            self._commit_all_files_radio, _i18n("Only commit selected changes"))
 
368
            self._commit_all_files_radio, _("Only commit selected changes"))
401
369
        self._files_box.pack_start(self._commit_selected_radio, expand=False)
402
370
        self._commit_selected_radio.show()
403
371
        self._commit_selected_radio.connect('toggled',
404
372
            self._toggle_commit_selection)
405
373
        if self._pending:
406
 
            self._commit_all_files_radio.set_label(_i18n('Commit all changes*'))
 
374
            self._commit_all_files_radio.set_label(_('Commit all changes*'))
407
375
            self._commit_all_files_radio.set_sensitive(False)
408
376
            self._commit_selected_radio.set_sensitive(False)
409
377
 
436
404
        crt.set_property('activatable', not bool(self._pending))
437
405
        crt.connect("toggled", self._toggle_commit, self._files_store)
438
406
        if self._pending:
439
 
            name = _i18n('Commit*')
 
407
            name = _('Commit*')
440
408
        else:
441
 
            name = _i18n('Commit')
 
409
            name = _('Commit')
442
410
        commit_col = gtk.TreeViewColumn(name, crt, active=2)
443
411
        commit_col.set_visible(False)
444
412
        self._treeview_files.append_column(commit_col)
445
 
        self._treeview_files.append_column(gtk.TreeViewColumn(_i18n('Path'),
 
413
        self._treeview_files.append_column(gtk.TreeViewColumn(_('Path'),
446
414
                                           gtk.CellRendererText(), text=3))
447
 
        self._treeview_files.append_column(gtk.TreeViewColumn(_i18n('Type'),
 
415
        self._treeview_files.append_column(gtk.TreeViewColumn(_('Type'),
448
416
                                           gtk.CellRendererText(), text=4))
449
417
        self._treeview_files.connect('cursor-changed',
450
418
                                     self._on_treeview_files_cursor_changed)
477
445
 
478
446
        pending_message = gtk.Label()
479
447
        pending_message.set_markup(
480
 
            _i18n('<i>* Cannot select specific files when merging</i>'))
 
448
            _('<i>* Cannot select specific files when merging</i>'))
481
449
        self._pending_box.pack_start(pending_message, expand=False, padding=5)
482
450
        pending_message.show()
483
451
 
484
 
        pending_label = gtk.Label(_i18n('Pending Revisions'))
 
452
        pending_label = gtk.Label(_('Pending Revisions'))
485
453
        self._pending_box.pack_start(pending_label, expand=False, padding=0)
486
454
        pending_label.show()
487
455
 
503
471
                                 )
504
472
        self._pending_store = liststore
505
473
        self._treeview_pending.set_model(liststore)
506
 
        self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Date'),
 
474
        self._treeview_pending.append_column(gtk.TreeViewColumn(_('Date'),
507
475
                                             gtk.CellRendererText(), text=1))
508
 
        self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Committer'),
 
476
        self._treeview_pending.append_column(gtk.TreeViewColumn(_('Committer'),
509
477
                                             gtk.CellRendererText(), text=2))
510
 
        self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Summary'),
 
478
        self._treeview_pending.append_column(gtk.TreeViewColumn(_('Summary'),
511
479
                                             gtk.CellRendererText(), text=3))
512
480
 
513
481
    def _construct_diff_view(self):
517
485
        #       decide that we really don't ever want to display it, we should
518
486
        #       actually remove it, and other references to it, along with the
519
487
        #       tests that it is set properly.
520
 
        self._diff_label = gtk.Label(_i18n('Diff for whole tree'))
 
488
        self._diff_label = gtk.Label(_('Diff for whole tree'))
521
489
        self._diff_label.set_alignment(0, 0)
522
490
        self._right_pane_table.set_row_spacing(self._right_pane_table_row, 0)
523
491
        self._add_to_right_table(self._diff_label, 1, False)
541
509
        self._file_message_text_view.set_accepts_tab(False)
542
510
        self._file_message_text_view.show()
543
511
 
544
 
        self._file_message_expander = gtk.Expander(_i18n('File commit message'))
 
512
        self._file_message_expander = gtk.Expander(_('File commit message'))
545
513
        self._file_message_expander.set_expanded(True)
546
514
        self._file_message_expander.add(scroller)
547
515
        self._add_to_right_table(self._file_message_expander, 1, False)
548
516
        self._file_message_expander.show()
549
517
 
550
518
    def _construct_global_message(self):
551
 
        self._global_message_label = gtk.Label(_i18n('Global Commit Message'))
552
 
        self._global_message_label.set_markup(
553
 
            _i18n('<b>Global Commit Message</b>'))
 
519
        self._global_message_label = gtk.Label(_('Global Commit Message'))
 
520
        self._global_message_label.set_markup(_('<b>Global Commit Message</b>'))
554
521
        self._global_message_label.set_alignment(0, 0)
555
522
        self._right_pane_table.set_row_spacing(self._right_pane_table_row, 0)
556
523
        self._add_to_right_table(self._global_message_label, 1, False)
561
528
        scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
562
529
 
563
530
        self._global_message_text_view = gtk.TextView()
564
 
        self._set_global_commit_message(self._saved_commit_messages_manager.get()[0])
565
531
        self._global_message_text_view.modify_font(pango.FontDescription("Monospace"))
566
532
        scroller.add(self._global_message_text_view)
567
533
        scroller.set_shadow_type(gtk.SHADOW_IN)
577
543
 
578
544
        if selection is not None:
579
545
            path, display_path = model.get(selection, 1, 3)
580
 
            self._diff_label.set_text(_i18n('Diff for ') + display_path)
 
546
            self._diff_label.set_text(_('Diff for ') + display_path)
581
547
            if path is None:
582
548
                self._diff_view.show_diff(None)
583
549
            else:
624
590
        text_buffer = self._file_message_text_view.get_buffer()
625
591
        file_id, display_path, message = self._files_store.get(selection, 0, 3, 5)
626
592
        if file_id is None: # Whole tree
627
 
            self._file_message_expander.set_label(_i18n('File commit message'))
 
593
            self._file_message_expander.set_label(_('File commit message'))
628
594
            self._file_message_expander.set_expanded(False)
629
595
            self._file_message_expander.set_sensitive(False)
630
596
            text_buffer.set_text('')
631
597
            self._last_selected_file = None
632
598
        else:
633
 
            self._file_message_expander.set_label(_i18n('Commit message for ')
 
599
            self._file_message_expander.set_label(_('Commit message for ')
634
600
                                                  + display_path)
635
601
            self._file_message_expander.set_expanded(True)
636
602
            self._file_message_expander.set_sensitive(True)
653
619
            if self._commit_all_changes or record[2]:# [2] checkbox
654
620
                file_id = record[0] # [0] file_id
655
621
                path = record[1]    # [1] real path
656
 
                # [5] commit message
657
 
                file_message = _sanitize_and_decode_message(record[5])
 
622
                file_message = record[5] # [5] commit message
658
623
                files.append(path.decode('UTF-8'))
659
624
                if self._enable_per_file_commits and file_message:
660
625
                    # All of this needs to be utf-8 information
661
 
                    file_message = file_message.encode('UTF-8')
662
626
                    file_info.append({'path':path, 'file_id':file_id,
663
627
                                     'message':file_message})
664
628
        file_info.sort(key=lambda x:(x['path'], x['file_id']))
668
632
            return files, []
669
633
 
670
634
    @show_bzr_error
671
 
    def _on_cancel_clicked(self, button):
672
 
        """ Cancel button clicked handler. """
673
 
        self._do_cancel()
674
 
 
675
 
    @show_bzr_error
676
 
    def _on_delete_window(self, source, event):
677
 
        """ Delete window handler. """
678
 
        self._do_cancel()
679
 
 
680
 
    def _do_cancel(self):
681
 
        """If requested, saves commit messages when cancelling gcommit; they are re-used by a next gcommit"""
682
 
        mgr = SavedCommitMessagesManager()
683
 
        self._saved_commit_messages_manager = mgr
684
 
        mgr.insert(self._get_global_commit_message(),
685
 
                   self._get_specific_files()[1])
686
 
        if mgr.is_not_empty(): # maybe worth saving
687
 
            response = self._question_dialog(
688
 
                _i18n('Commit cancelled'),
689
 
                _i18n('Do you want to save your commit messages ?'),
690
 
                parent=self)
691
 
            if response == gtk.RESPONSE_NO:
692
 
                 # save nothing and destroy old comments if any
693
 
                mgr = SavedCommitMessagesManager()
694
 
        mgr.save(self._wt, self._wt.branch)
695
 
        self.response(gtk.RESPONSE_CANCEL) # close window
696
 
 
697
 
    @show_bzr_error
698
635
    def _on_commit_clicked(self, button):
699
636
        """ Commit button clicked handler. """
700
637
        self._do_commit()
704
641
 
705
642
        if message == '':
706
643
            response = self._question_dialog(
707
 
                _i18n('Commit with an empty message?'),
708
 
                _i18n('You can describe your commit intent in the message.'),
709
 
                parent=self)
 
644
                            _('Commit with an empty message?'),
 
645
                            _('You can describe your commit intent in the message.'))
710
646
            if response == gtk.RESPONSE_NO:
711
647
                # Kindly give focus to message area
712
648
                self._global_message_text_view.grab_focus()
725
661
        #       files at this point.
726
662
        for path in self._wt.unknowns():
727
663
            response = self._question_dialog(
728
 
                _i18n("Commit with unknowns?"),
729
 
                _i18n("Unknown files exist in the working tree. Commit anyway?"),
730
 
                parent=self)
731
 
                # Doesn't set a parent for the dialog..
 
664
                _("Commit with unknowns?"),
 
665
                _("Unknown files exist in the working tree. Commit anyway?"))
732
666
            if response == gtk.RESPONSE_NO:
733
667
                return
734
668
            break
746
680
                       revprops=revprops)
747
681
        except errors.PointlessCommit:
748
682
            response = self._question_dialog(
749
 
                _i18n('Commit with no changes?'),
750
 
                _i18n('There are no changes in the working tree.'
751
 
                      ' Do you want to commit anyway?'),
752
 
                parent=self)
 
683
                                _('Commit with no changes?'),
 
684
                                _('There are no changes in the working tree.'
 
685
                                  ' Do you want to commit anyway?'))
753
686
            if response == gtk.RESPONSE_YES:
754
687
                rev_id = self._wt.commit(message,
755
688
                               allow_pointless=True,
758
691
                               specific_files=specific_files,
759
692
                               revprops=revprops)
760
693
        self.committed_revision_id = rev_id
761
 
        # destroy old comments if any
762
 
        SavedCommitMessagesManager().save(self._wt, self._wt.branch)
763
694
        self.response(gtk.RESPONSE_OK)
764
695
 
765
696
    def _get_global_commit_message(self):
766
697
        buf = self._global_message_text_view.get_buffer()
767
698
        start, end = buf.get_bounds()
768
 
        text = buf.get_text(start, end)
769
 
        return _sanitize_and_decode_message(text)
 
699
        return buf.get_text(start, end).decode('utf-8')
770
700
 
771
701
    def _set_global_commit_message(self, message):
772
702
        """Just a helper for the test suite."""
793
723
                                       show_offset=False)
794
724
        rev_dict['revision_id'] = rev.revision_id
795
725
        return rev_dict
796
 
 
797
 
 
798
 
class SavedCommitMessagesManager:
799
 
    """Save glogal and per-file commit messages.
800
 
 
801
 
    Saves global commit message and utf-8 file_id->message dictionary
802
 
    of per-file commit messages on disk. Re-reads them later for re-using.
803
 
    """
804
 
 
805
 
    def __init__(self, tree=None, branch=None):
806
 
        """If branch is None, builds empty messages, otherwise reads them
807
 
        from branch's disk storage. 'tree' argument is for the future."""
808
 
        if branch is None:
809
 
            self.global_message = u''
810
 
            self.file_messages = {}
811
 
        else:
812
 
            config = branch.get_config()._get_branch_data_config()
813
 
            self.global_message = config.get_user_option(
814
 
                'gtk_global_commit_message')
815
 
            if self.global_message is None:
816
 
                self.global_message = u''
817
 
            file_messages = config.get_user_option('gtk_file_commit_messages')
818
 
            if file_messages: # unicode and B-encoded:
819
 
                self.file_messages = bencode.bdecode(
820
 
                    file_messages.encode('UTF-8'))
821
 
            else:
822
 
                self.file_messages = {}
823
 
 
824
 
    def get(self):
825
 
        return self.global_message, self.file_messages
826
 
 
827
 
    def is_not_empty(self):
828
 
        return bool(self.global_message or self.file_messages)
829
 
 
830
 
    def insert(self, global_message, file_info):
831
 
        """Formats per-file commit messages (list of dictionaries, one per file)
832
 
        into one utf-8 file_id->message dictionary and merges this with
833
 
        previously existing dictionary. Merges global commit message too."""
834
 
        file_messages = {}
835
 
        for fi in file_info:
836
 
            file_message = fi['message']
837
 
            if file_message:
838
 
                file_messages[fi['file_id']] = file_message # utf-8 strings
839
 
        for k,v in file_messages.iteritems():
840
 
            try:
841
 
                self.file_messages[k] = v + '\n******\n' + self.file_messages[k]
842
 
            except KeyError:
843
 
                self.file_messages[k] = v
844
 
        if self.global_message:
845
 
            self.global_message = global_message + '\n******\n' \
846
 
                + self.global_message
847
 
        else:
848
 
            self.global_message = global_message
849
 
 
850
 
    def save(self, tree, branch):
851
 
        # We store in branch's config, which can be a problem if two gcommit
852
 
        # are done in two checkouts of one single branch (comments overwrite
853
 
        # each other). Ideally should be in working tree. But uncommit does
854
 
        # not always have a working tree, though it always has a branch.
855
 
        # 'tree' argument is for the future
856
 
        config = branch.get_config()
857
 
        # should it be named "gtk_" or some more neutral name ("gui_" ?) to
858
 
        # be compatible with qbzr in the future?
859
 
        config.set_user_option('gtk_global_commit_message', self.global_message)
860
 
        # bencode() does not know unicode objects but set_user_option()
861
 
        # requires one:
862
 
        config.set_user_option(
863
 
            'gtk_file_commit_messages',
864
 
            bencode.bencode(self.file_messages).decode('UTF-8'))
865
 
 
866
 
 
867
 
def save_commit_messages(local, master, old_revno, old_revid,
868
 
                         new_revno, new_revid):
869
 
    b = local
870
 
    if b is None:
871
 
        b = master
872
 
    mgr = SavedCommitMessagesManager(None, b)
873
 
    revid_iterator = b.repository.iter_reverse_revision_history(old_revid)
874
 
    cur_revno = old_revno
875
 
    new_revision_id = old_revid
876
 
    graph = b.repository.get_graph()
877
 
    for rev_id in revid_iterator:
878
 
        if cur_revno == new_revno:
879
 
            break
880
 
        cur_revno -= 1
881
 
        rev = b.repository.get_revision(rev_id)
882
 
        file_info = rev.properties.get('file-info', None)
883
 
        if file_info is None:
884
 
            file_info = {}
885
 
        else:
886
 
            file_info = bencode.bdecode(file_info.encode('UTF-8'))
887
 
        global_message = osutils.safe_unicode(rev.message)
888
 
        # Concatenate comment of the uncommitted revision
889
 
        mgr.insert(global_message, file_info)
890
 
 
891
 
        parents = graph.get_parent_map([rev_id]).get(rev_id, None)
892
 
        if not parents:
893
 
            continue
894
 
    mgr.save(None, b)