~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge pt1 hooks branch.

Show diffs side-by-side

added added

removed removed

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