/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_status.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
 
19
18
from .. import (
20
19
    config,
21
20
    status as _mod_status,
114
113
        self.addCleanup(tree.unlock)
115
114
        output = StringIO()
116
115
        show_pending_merges(tree, output, verbose=True)
117
 
        self.assertEqualDiff('pending merges:\n'
118
 
                             '  Joe Foo 2007-12-04 another non-ghost\n'
119
 
                             '    Joe Foo 2007-12-04 [merge] commit with ghost\n'
120
 
                             '    (ghost) a-ghost-revision\n'
121
 
                             '    Joe Foo 2007-12-04 a non-ghost\n',
122
 
                             output.getvalue())
 
116
        self.assertEqualDiff(
 
117
            'pending merges:\n'
 
118
            '  Joe Foo 2007-12-04 another non-ghost\n'
 
119
            '    Joe Foo 2007-12-04 [merge] commit with ghost\n'
 
120
            '    (ghost) a-ghost-revision\n'
 
121
            '    Joe Foo 2007-12-04 a non-ghost\n',
 
122
            output.getvalue())
123
123
 
124
124
    def tests_revision_to_revision(self):
125
125
        """doing a status between two revision trees should work."""
126
126
        tree = self.make_branch_and_tree('.')
127
127
        r1_id = tree.commit('one', allow_pointless=True)
128
128
        r2_id = tree.commit('two', allow_pointless=True)
129
 
        r2_tree = tree.branch.repository.revision_tree(r2_id)
130
129
        output = StringIO()
131
 
        show_tree_status(tree, to_file=output,
132
 
                     revision=[RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
133
 
                               RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
 
130
        show_tree_status(tree, to_file=output, revision=[
 
131
            RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
 
132
            RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
134
133
        # return does not matter as long as it did not raise.
135
134
 
136
135
 
140
139
        """Check that creating a StatusHooks instance has the right defaults.
141
140
        """
142
141
        hooks = _mod_status.StatusHooks()
143
 
        self.assertTrue("post_status" in hooks, "post_status not in %s" % hooks)
 
142
        self.assertTrue("post_status" in hooks,
 
143
                        "post_status not in %s" % hooks)
144
144
        self.assertTrue("pre_status" in hooks, "pre_status not in %s" % hooks)
145
145
 
146
146
    def test_installed_hooks_are_StatusHooks(self):
148
148
        """
149
149
        # the installed hooks are saved in self._preserved_hooks.
150
150
        self.assertIsInstance(self._preserved_hooks[_mod_status][1],
151
 
            _mod_status.StatusHooks)
 
151
                              _mod_status.StatusHooks)
152
152
 
153
153
    def test_post_status_hook(self):
154
154
        """Ensure that post_status hook is invoked with the right args.
159
159
        tree = self.make_branch_and_tree('.')
160
160
        r1_id = tree.commit('one', allow_pointless=True)
161
161
        r2_id = tree.commit('two', allow_pointless=True)
162
 
        r2_tree = tree.branch.repository.revision_tree(r2_id)
163
162
        output = StringIO()
164
 
        show_tree_status(tree, to_file=output,
165
 
            revision=[RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
166
 
                RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
 
163
        show_tree_status(tree, to_file=output, revision=[
 
164
            RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
 
165
            RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
167
166
        self.assertLength(1, calls)
168
167
        params = calls[0]
169
168
        self.assertIsInstance(params, _mod_status.StatusHookParams)
170
169
        attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
171
 
            'show_ids', 'short', 'verbose', 'specific_files']
 
170
                 'show_ids', 'short', 'verbose', 'specific_files']
172
171
        for a in attrs:
173
172
            self.assertTrue(hasattr(params, a),
174
 
                'Attribute "%s" not found in StatusHookParam' % a)
 
173
                            'Attribute "%s" not found in StatusHookParam' % a)
175
174
 
176
175
    def test_pre_status_hook(self):
177
176
        """Ensure that pre_status hook is invoked with the right args.
182
181
        tree = self.make_branch_and_tree('.')
183
182
        r1_id = tree.commit('one', allow_pointless=True)
184
183
        r2_id = tree.commit('two', allow_pointless=True)
185
 
        r2_tree = tree.branch.repository.revision_tree(r2_id)
186
184
        output = StringIO()
187
 
        show_tree_status(tree, to_file=output,
188
 
            revision=[RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
 
185
        show_tree_status(
 
186
            tree, to_file=output,
 
187
            revision=[
 
188
                RevisionSpec.from_string("revid:%s" % r1_id.decode('utf-8')),
189
189
                RevisionSpec.from_string("revid:%s" % r2_id.decode('utf-8'))])
190
190
        self.assertLength(1, calls)
191
191
        params = calls[0]
192
192
        self.assertIsInstance(params, _mod_status.StatusHookParams)
193
193
        attrs = ['old_tree', 'new_tree', 'to_file', 'versioned',
194
 
            'show_ids', 'short', 'verbose', 'specific_files']
 
194
                 'show_ids', 'short', 'verbose', 'specific_files']
195
195
        for a in attrs:
196
196
            self.assertTrue(hasattr(params, a),
197
 
                'Attribute "%s" not found in StatusHookParam' % a)
198
 
 
 
197
                            'Attribute "%s" not found in StatusHookParam' % a)