~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 04:25:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5472.
  • Revision ID: andrew.bennetts@canonical.com-20101008042510-sg9vdhmnggilzxsk
Fix stray TAB in source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
"""
25
25
 
26
26
 
27
 
from bzrlib import tests
 
27
import os
28
28
 
 
29
from bzrlib.branch import Branch
29
30
from bzrlib.config import extract_email_address
 
31
from bzrlib.tests import TestCaseWithTransport
30
32
from bzrlib.urlutils import joinpath
31
33
 
32
34
 
33
 
class TestAnnotate(tests.TestCaseWithTransport):
 
35
class TestAnnotate(TestCaseWithTransport):
34
36
 
35
37
    def setUp(self):
36
38
        super(TestAnnotate, self).setUp()
149
151
                         err)
150
152
 
151
153
 
152
 
class TestSimpleAnnotate(tests.TestCaseWithTransport):
 
154
class TestSimpleAnnotate(TestCaseWithTransport):
153
155
    """Annotate tests with no complex setup."""
154
156
 
155
157
    def _setup_edited_file(self, relpath='.'):
166
168
    def test_annotate_cmd_revspec_branch(self):
167
169
        tree = self._setup_edited_file('trunk')
168
170
        tree.branch.create_checkout(self.get_url('work'), lightweight=True)
169
 
        out, err = self.run_bzr(['annotate', 'file', '-r', 'branch:../trunk'],
170
 
                                working_dir='work')
 
171
        os.chdir('work')
 
172
        out, err = self.run_bzr('annotate file -r branch:../trunk')
171
173
        self.assertEqual('', err)
172
174
        self.assertEqual(
173
175
            '1   test@ho | foo\n'
209
211
        tree.merge_from_branch(tree.branch, "rev1.1.1")
210
212
        # edit the file to be 'resolved' and have a further local edit
211
213
        self.build_tree_contents([('file', 'local\nfoo\nbar\nbaz\ngam\n')])
212
 
        return tree
213
214
 
214
215
    def test_annotated_edited_merged_file_revnos(self):
215
 
        wt = self._create_merged_file()
216
 
        out, err = self.run_bzr(['annotate', 'file'])
217
 
        email = extract_email_address(wt.branch.get_config().username())
 
216
        self._create_merged_file()
 
217
        out, err = self.run_bzr('annotate file')
 
218
        email = extract_email_address(Branch.open('.').get_config().username())
218
219
        self.assertEqual(
219
220
            '3?    %-7s | local\n'
220
221
            '1     test@ho | foo\n'
225
226
 
226
227
    def test_annotated_edited_merged_file_ids(self):
227
228
        self._create_merged_file()
228
 
        out, err = self.run_bzr(['annotate', 'file', '--show-ids'])
 
229
        out, err = self.run_bzr('annotate file --show-ids')
229
230
        self.assertEqual(
230
231
            'current: | local\n'
231
232
            '    rev1 | foo\n'
235
236
            out)
236
237
 
237
238
    def test_annotate_empty_file(self):
238
 
        tree = self.make_branch_and_tree('.')
239
 
        self.build_tree_contents([('empty', '')])
 
239
        tree = self.make_branch_and_tree('tree')
 
240
        self.build_tree_contents([('tree/empty', '')])
240
241
        tree.add('empty')
241
242
        tree.commit('add empty file')
242
 
        out, err = self.run_bzr(['annotate', 'empty'])
243
 
        self.assertEqual('', out)
244
243
 
245
 
    def test_annotate_removed_file(self):
246
 
        tree = self.make_branch_and_tree('.')
247
 
        self.build_tree_contents([('empty', '')])
248
 
        tree.add('empty')
249
 
        tree.commit('add empty file')
250
 
        # delete the file.
251
 
        tree.remove('empty')
252
 
        tree.commit('remove empty file')
253
 
        out, err = self.run_bzr(['annotate', '-r1', 'empty'])
 
244
        os.chdir('tree')
 
245
        out, err = self.run_bzr('annotate empty')
254
246
        self.assertEqual('', out)
255
247
 
256
248
    def test_annotate_empty_file_show_ids(self):
257
 
        tree = self.make_branch_and_tree('.')
258
 
        self.build_tree_contents([('empty', '')])
 
249
        tree = self.make_branch_and_tree('tree')
 
250
        self.build_tree_contents([('tree/empty', '')])
259
251
        tree.add('empty')
260
252
        tree.commit('add empty file')
 
253
 
 
254
        os.chdir('tree')
261
255
        out, err = self.run_bzr(['annotate', '--show-ids', 'empty'])
262
256
        self.assertEqual('', out)
263
257
 
264
258
    def test_annotate_nonexistant_file(self):
265
 
        tree = self.make_branch_and_tree('.')
266
 
        self.build_tree(['file'])
 
259
        tree = self.make_branch_and_tree('tree')
 
260
        self.build_tree(['tree/file'])
267
261
        tree.add(['file'])
268
262
        tree.commit('add a file')
269
 
        out, err = self.run_bzr(['annotate', 'doesnotexist'], retcode=3)
 
263
 
 
264
        os.chdir('tree')
 
265
        out, err = self.run_bzr("annotate doesnotexist", retcode=3)
270
266
        self.assertEqual('', out)
271
267
        self.assertEqual("bzr: ERROR: doesnotexist is not versioned.\n", err)
272
268
 
273
269
    def test_annotate_without_workingtree(self):
274
 
        tree = self.make_branch_and_tree('.')
275
 
        self.build_tree_contents([('empty', '')])
 
270
        tree = self.make_branch_and_tree('branch')
 
271
        self.build_tree_contents([('branch/empty', '')])
276
272
        tree.add('empty')
277
273
        tree.commit('add empty file')
278
274
        bzrdir = tree.branch.bzrdir
279
275
        bzrdir.destroy_workingtree()
280
276
        self.assertFalse(bzrdir.has_workingtree())
281
 
        out, err = self.run_bzr(['annotate', 'empty'])
 
277
 
 
278
        os.chdir('branch')
 
279
        out, err = self.run_bzr('annotate empty')
282
280
        self.assertEqual('', out)
283
281
 
284
282
    def test_annotate_directory(self):
287
285
        self.build_tree_contents([('a/hello.txt', 'my helicopter\n')])
288
286
        wt.add(['hello.txt'])
289
287
        wt.commit('commit', committer='test@user')
290
 
        out, err = self.run_bzr(['annotate', '-d', 'a', 'hello.txt'])
 
288
        out, err = self.run_bzr('annotate -d a hello.txt')
291
289
        self.assertEqualDiff('1   test@us | my helicopter\n', out)