/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: John Arbash Meinel
  • Date: 2007-10-02 19:10:01 UTC
  • mto: (322.1.1 trunk) (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: john@arbash-meinel.com-20071002191001-ezz7ejijs0e8tlg8
Add the ability to commit just specific files.
Also include the ability to save the file-info data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from bzrlib import errors, osutils
31
31
from bzrlib.trace import mutter
 
32
from bzrlib.util import bencode
32
33
 
33
34
from dialog import error_dialog, question_dialog
34
35
from errors import show_bzr_error
540
541
            text_buffer.set_text(message)
541
542
            self._last_selected_file = self._files_store.get_path(selection)
542
543
 
 
544
    def _get_specific_files(self):
 
545
        self._save_current_file_message()
 
546
        files = []
 
547
        records = iter(self._files_store)
 
548
        rec = records.next() # Skip the All Files record
 
549
        assert rec[0] is None, "Are we skipping the wrong record?"
 
550
 
 
551
        file_info = []
 
552
        for record in records:
 
553
            if record[2]: # [2] checkbox
 
554
                file_id = record[0]
 
555
                path = record[1]
 
556
                file_message = record[5]
 
557
                files.append(record[1]) # [1] real path
 
558
                if file_message:
 
559
                    file_info.append({'path':path, 'file_id':file_id,
 
560
                                     'message':file_message})
 
561
        file_info.sort(key=lambda x:(x['path'], x['file_id']))
 
562
        return files, file_info
 
563
 
543
564
    @show_bzr_error
544
565
    def _on_commit_clicked(self, button):
545
566
        """ Commit button clicked handler. """
557
578
                self._global_message_text_view.grab_focus()
558
579
                return
559
580
 
560
 
        # if not self.pending:
561
 
        #     specific_files = self._get_specific_files()
562
 
        # else:
563
 
        #     specific_files = None
 
581
        specific_files, file_info = self._get_specific_files()
564
582
 
565
583
        local = self._check_local.get_active()
566
584
 
577
595
                return
578
596
            break
579
597
 
580
 
        specific_files = None
581
598
        rev_id = None
 
599
        revprops = {}
 
600
        if file_info:
 
601
            revprops['file-info'] = bencode.bencode(file_info)
582
602
        try:
583
603
            rev_id = self._wt.commit(message,
584
604
                       allow_pointless=False,
585
605
                       strict=False,
586
606
                       local=local,
587
 
                       specific_files=specific_files)
 
607
                       specific_files=specific_files,
 
608
                       revprops=revprops)
588
609
        except errors.PointlessCommit:
589
610
            response = self._question_dialog(
590
611
                                _('Commit with no changes?'),
595
616
                               allow_pointless=True,
596
617
                               strict=False,
597
618
                               local=local,
598
 
                               specific_files=specific_files)
 
619
                               specific_files=specific_files,
 
620
                               revprops=revprops)
599
621
        self.committed_revision_id = rev_id
600
622
        self.response(gtk.RESPONSE_OK)
601
623
 
608
630
        """Just a helper for the test suite."""
609
631
        self._global_message_text_view.get_buffer().set_text(message)
610
632
 
 
633
    def _set_file_commit_message(self, message):
 
634
        """Helper for the test suite."""
 
635
        self._file_message_text_view.get_buffer().set_text(message)
 
636
 
611
637
    @staticmethod
612
638
    def _rev_to_pending_info(rev):
613
639
        """Get the information from a pending merge."""