/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 tests/test_commit.py

  • Committer: Vincent Ladeuil
  • Date: 2009-05-27 19:19:25 UTC
  • mto: This revision was merged to the branch mainline in revision 640.
  • Revision ID: v.ladeuil+lp@free.fr-20090527191925-rzdpx5wnh8o1tzzm
Start testing patch behavior.

* tests/test_commit.py:
(TestUncommitHook): Start capturing actual behavior with a bzr
patched with Anne's SavedCommitMessagesManager defined in bzrlib.

* commit.py:
(CommitDialog._do_cancel): Reduce duplication.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib import (
24
24
    tests,
25
25
    revision,
 
26
    uncommit,
26
27
    )
27
28
from bzrlib.util import bencode
28
29
 
1086
1087
 
1087
1088
    def test_converts_mixed_to_lf(self):
1088
1089
        self.assertSanitize('foo\nbar\nbaz\n', 'foo\r\nbar\rbaz\n')
 
1090
 
 
1091
 
 
1092
class TestUncommitHook(tests.TestCaseWithTransport):
 
1093
 
 
1094
    def test_hook_fired_on_uncommit(self):
 
1095
        tree = self.make_branch_and_tree('tree')
 
1096
        config = tree.branch.get_config()
 
1097
        self.build_tree(['tree/a', 'tree/b'])
 
1098
        tree.add(['a'], ['a-id'])
 
1099
        tree.add(['b'], ['b-id'])
 
1100
        file_info1 = [dict(path='a', file_id='a-id', message='a msg 1'),
 
1101
                     dict(path='b', file_id='b-id', message='b msg 1')]
 
1102
        rev1 = tree.commit('one',
 
1103
                            revprops={'file-info':
 
1104
                                          bencode.bencode(file_info1).decode('UTF-8')})
 
1105
 
 
1106
        file_info2 = [dict(path='a', file_id='a-id', message='a msg 2'),
 
1107
                      dict(path='b', file_id='b-id', message='b msg 2')]
 
1108
        revprops = {'file-info': bencode.bencode(file_info2).decode('UTF-8')}
 
1109
        rev2 = tree.commit ('two',
 
1110
                            revprops={'file-info': bencode.bencode(file_info2).decode('UTF-8')})
 
1111
        uncommit.uncommit(tree.branch, tree=tree)
 
1112
        self.assertEquals('two',
 
1113
                          config.get_user_option('gtk_global_commit_message'))
 
1114
        self.assertEquals(u'd4:a-id7:a msg 24:b-id7:b msg 2e',
 
1115
                          config.get_user_option('gtk_file_commit_messages'))
 
1116
        uncommit.uncommit(tree.branch, tree=tree)
 
1117
        self.assertEquals(u'one\n******\ntwo',
 
1118
                          config.get_user_option('gtk_global_commit_message'))
 
1119
        self.assertEquals(u'd4:a-id22:a msg 1'
 
1120
                          '\n******\n'
 
1121
                          'a msg 24:b-id22:b msg 1\n******\nb msg 2e',
 
1122
                          config.get_user_option('gtk_file_commit_messages'))