536
538
('a-id', 'a', True),
537
539
('b-id', 'b', True),
538
540
], [(r[0], r[1], r[2]) for r in dlg._files_store])
543
class TestCommitDialog_Commit(tests.TestCaseWithTransport):
544
"""Tests on the actual 'commit' button being pushed."""
546
def test_commit_no_message(self):
547
tree = self.make_branch_and_tree('tree')
548
self.build_tree(['tree/a', 'tree/b'])
549
tree.add(['a'], ['a-id'])
550
rev_id = tree.commit('one')
552
tree.add(['b'], ['b-id'])
554
dlg = commit.CommitDialog(tree)
556
def _question_cancel(*args):
557
questions.append(args)
558
questions.append('NO')
559
return gtk.RESPONSE_NO
561
def _question_ok(*args):
562
questions.append(args)
563
questions.append('OK')
564
return gtk.RESPONSE_OK
566
dlg._question_dialog = _question_cancel
569
[('Commit with an empty message?',
570
'You can describe your commit intent in the message.'),
573
# By saying NO, nothing should be committed.
574
self.assertEqual(rev_id, tree.last_revision())
575
self.assertIs(None, dlg.committed_revision_id)
577
dlg._question_dialog = _question_ok
582
[('Commit with an empty message?',
583
'You can describe your commit intent in the message.'),
586
committed = tree.last_revision()
587
self.assertNotEqual(rev_id, committed)
588
self.assertEqual(committed, dlg.committed_revision_id)
590
def test_initial_commit(self):
591
tree = self.make_branch_and_tree('tree')
592
self.build_tree(['tree/a'])
593
tree.add(['a'], ['a-id'])
595
dlg = commit.CommitDialog(tree)
596
dlg._global_message_text_view.get_buffer().set_text('Some text\n')
599
last_rev = tree.last_revision()
600
self.assertEqual(last_rev, dlg.committed_revision_id)
601
rev = tree.branch.repository.get_revision(last_rev)
602
self.assertEqual(last_rev, rev.revision_id)
603
self.assertEqual('Some text\n', rev.message)