~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_annotate.py

add test

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
"""
25
25
 
26
26
 
27
 
from bzrlib import tests
 
27
from bzrlib import (
 
28
    config,
 
29
    tests,
 
30
    )
28
31
 
29
 
from bzrlib.config import extract_email_address
30
32
from bzrlib.urlutils import joinpath
31
33
 
32
34
 
160
162
        tree.add('file')
161
163
        tree.commit('add file', committer="test@host", rev_id="rev1")
162
164
        self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
163
 
        tree.branch.get_config().set_user_option('email', 'current@host2')
164
165
        return tree
165
166
 
166
167
    def test_annotate_cmd_revspec_branch(self):
176
177
 
177
178
    def test_annotate_edited_file(self):
178
179
        tree = self._setup_edited_file()
 
180
        tree.branch.get_config().set_user_option('email', 'current@host2')
179
181
        out, err = self.run_bzr('annotate file')
180
182
        self.assertEqual(
181
183
            '1   test@ho | foo\n'
183
185
            '1   test@ho | gam\n',
184
186
            out)
185
187
 
 
188
    def test_annotate_edited_file_no_default(self):
 
189
        # Ensure that when no username is available annotate still works.
 
190
        self.overrideEnv('EMAIL', None)
 
191
        self.overrideEnv('BZR_EMAIL', None)
 
192
        # Also, make sure that it's not inferred from mailname.
 
193
        self.overrideAttr(config, '_auto_user_id',
 
194
            lambda: (None, None))
 
195
        tree = self._setup_edited_file()
 
196
        out, err = self.run_bzr('annotate file')
 
197
        self.assertEqual(
 
198
            '1   test@ho | foo\n'
 
199
            '2?  local u | bar\n'
 
200
            '1   test@ho | gam\n',
 
201
            out)
 
202
 
186
203
    def test_annotate_edited_file_show_ids(self):
187
204
        tree = self._setup_edited_file()
 
205
        tree.branch.get_config().set_user_option('email', 'current@host2')
188
206
        out, err = self.run_bzr('annotate file --show-ids')
189
207
        self.assertEqual(
190
208
            '    rev1 | foo\n'
214
232
    def test_annotated_edited_merged_file_revnos(self):
215
233
        wt = self._create_merged_file()
216
234
        out, err = self.run_bzr(['annotate', 'file'])
217
 
        email = extract_email_address(wt.branch.get_config().username())
 
235
        email = config.extract_email_address(wt.branch.get_config().username())
218
236
        self.assertEqual(
219
237
            '3?    %-7s | local\n'
220
238
            '1     test@ho | foo\n'