183
183
class TestCommitDialog(tests.TestCaseWithTransport):
185
def test_bound(self):
186
tree = self.make_branch_and_tree('tree')
187
rev_id = tree.commit('first')
188
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
189
tree2.branch.bind(tree.branch)
191
# tree is not a checkout
192
dlg = commit.CommitDialog(tree)
193
self.assertFalse(dlg._check_local.get_property('visible'))
195
# tree2 is a checkout
196
dlg2 = commit.CommitDialog(tree2)
197
self.assertTrue(dlg2._check_local.get_property('visible'))
185
199
def test_no_pending(self):
186
200
tree = self.make_branch_and_tree('tree')
187
201
rev_id1 = tree.commit('one')
189
203
dlg = commit.CommitDialog(tree)
190
# TODO: assert that the pending box is hidden
205
self.assertFalse(dlg._pending_box.get_property('visible'))
191
207
commit_col = dlg._treeview_files.get_column(0)
192
208
self.assertEqual('Commit', commit_col.get_title())
193
209
renderer = commit_col.get_cell_renderers()[0]
205
221
tree.merge_from_branch(tree2.branch)
207
223
dlg = commit.CommitDialog(tree)
208
# TODO: assert that the pending box is set to show
225
self.assertTrue(dlg._pending_box.get_property('visible'))
209
227
commit_col = dlg._treeview_files.get_column(0)
210
228
self.assertEqual('Commit*', commit_col.get_title())
211
229
renderer = commit_col.get_cell_renderers()[0]
543
561
class TestCommitDialog_Commit(tests.TestCaseWithTransport):
544
562
"""Tests on the actual 'commit' button being pushed."""
564
def test_bound_commit_local(self):
565
tree = self.make_branch_and_tree('tree')
566
self.build_tree(['tree/a'])
567
tree.add(['a'], ['a-id'])
568
rev_id1 = tree.commit('one')
570
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
571
self.build_tree(['tree2/b'])
572
tree2.add(['b'], ['b-id'])
573
tree2.branch.bind(tree.branch)
575
dlg = commit.CommitDialog(tree2)
576
# With the check box set, it should only effect the local branch
577
dlg._check_local.set_active(True)
578
dlg._set_global_commit_message('Commit message\n')
581
last_rev = tree2.last_revision()
582
self.assertEqual(last_rev, dlg.committed_revision_id)
583
self.assertEqual(rev_id1, tree.branch.last_revision())
585
def test_bound_commit_both(self):
586
tree = self.make_branch_and_tree('tree')
587
self.build_tree(['tree/a'])
588
tree.add(['a'], ['a-id'])
589
rev_id1 = tree.commit('one')
591
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
592
self.build_tree(['tree2/b'])
593
tree2.add(['b'], ['b-id'])
594
tree2.branch.bind(tree.branch)
596
dlg = commit.CommitDialog(tree2)
597
# With the check box set, it should only effect the local branch
598
dlg._check_local.set_active(False)
599
dlg._set_global_commit_message('Commit message\n')
602
last_rev = tree2.last_revision()
603
self.assertEqual(last_rev, dlg.committed_revision_id)
604
self.assertEqual(last_rev, tree.branch.last_revision())
546
606
def test_commit_no_message(self):
547
607
tree = self.make_branch_and_tree('tree')
548
608
self.build_tree(['tree/a', 'tree/b'])
573
633
# By saying NO, nothing should be committed.
574
634
self.assertEqual(rev_id, tree.last_revision())
575
635
self.assertIs(None, dlg.committed_revision_id)
636
self.assertTrue(dlg._global_message_text_view.get_property('is-focus'))
577
638
dlg._question_dialog = _question_ok
593
654
tree.add(['a'], ['a-id'])
595
656
dlg = commit.CommitDialog(tree)
596
dlg._global_message_text_view.get_buffer().set_text('Some text\n')
657
dlg._set_global_commit_message('Some text\n')
599
660
last_rev = tree.last_revision()