561
561
class TestCommitDialog_Commit(tests.TestCaseWithTransport):
562
562
"""Tests on the actual 'commit' button being pushed."""
564
def _set_question_yes(self, dlg):
565
"""Set the dialog to answer YES to any questions."""
567
def _question_yes(*args):
568
self.questions.append(args)
569
self.questions.append('YES')
570
return gtk.RESPONSE_YES
571
dlg._question_dialog = _question_yes
573
def _set_question_no(self, dlg):
574
"""Set the dialog to answer NO to any questions."""
576
def _question_no(*args):
577
self.questions.append(args)
578
self.questions.append('NO')
579
return gtk.RESPONSE_NO
580
dlg._question_dialog = _question_no
564
582
def test_bound_commit_local(self):
565
583
tree = self.make_branch_and_tree('tree')
566
584
self.build_tree(['tree/a'])
612
630
tree.add(['b'], ['b-id'])
614
632
dlg = commit.CommitDialog(tree)
616
def _question_cancel(*args):
617
questions.append(args)
618
questions.append('NO')
619
return gtk.RESPONSE_NO
621
def _question_ok(*args):
622
questions.append(args)
623
questions.append('OK')
624
return gtk.RESPONSE_OK
626
dlg._question_dialog = _question_cancel
633
self._set_question_no(dlg)
628
635
self.assertEqual(
629
636
[('Commit with an empty message?',
630
637
'You can describe your commit intent in the message.'),
633
640
# By saying NO, nothing should be committed.
634
641
self.assertEqual(rev_id, tree.last_revision())
635
642
self.assertIs(None, dlg.committed_revision_id)
636
643
self.assertTrue(dlg._global_message_text_view.get_property('is-focus'))
638
dlg._question_dialog = _question_ok
645
self._set_question_yes(dlg)
642
648
self.assertEqual(
643
649
[('Commit with an empty message?',
644
650
'You can describe your commit intent in the message.'),
647
653
committed = tree.last_revision()
648
654
self.assertNotEqual(rev_id, committed)
649
655
self.assertEqual(committed, dlg.committed_revision_id)
662
668
rev = tree.branch.repository.get_revision(last_rev)
663
669
self.assertEqual(last_rev, rev.revision_id)
664
670
self.assertEqual('Some text\n', rev.message)
672
def test_pointless_commit(self):
673
tree = self.make_branch_and_tree('tree')
674
self.build_tree(['tree/a'])
675
tree.add(['a'], ['a-id'])
676
rev_id1 = tree.commit('one')
678
dlg = commit.CommitDialog(tree)
679
dlg._set_global_commit_message('Some text\n')
681
self._set_question_no(dlg)
684
self.assertIs(None, dlg.committed_revision_id)
685
self.assertEqual(rev_id1, tree.last_revision())
687
[('Commit with no changes?',
688
'There are no changes in the working tree.'
689
' Do you want to commit anyway?'),
693
self._set_question_yes(dlg)
696
rev_id2 = tree.last_revision()
697
self.assertEqual(rev_id2, dlg.committed_revision_id)
698
self.assertNotEqual(rev_id1, rev_id2)
700
[('Commit with no changes?',
701
'There are no changes in the working tree.'
702
' Do you want to commit anyway?'),
706
def test_unknowns(self):
707
"""We should check if there are unknown files."""
708
tree = self.make_branch_and_tree('tree')
709
rev_id1 = tree.commit('one')
710
self.build_tree(['tree/a', 'tree/b'])
711
tree.add(['a'], ['a-id'])
713
dlg = commit.CommitDialog(tree)
714
dlg._set_global_commit_message('Some text\n')
715
self._set_question_no(dlg)
719
self.assertIs(None, dlg.committed_revision_id)
720
self.assertEqual(rev_id1, tree.last_revision())
722
[("Commit with unknowns?",
723
"Unknown files exist in the working tree. Commit anyway?"),
727
self._set_question_yes(dlg)
730
rev_id2 = tree.last_revision()
731
self.assertNotEqual(rev_id1, rev_id2)
732
self.assertEqual(rev_id2, dlg.committed_revision_id)
734
[("Commit with unknowns?",
735
"Unknown files exist in the working tree. Commit anyway?"),