~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2010-10-07 06:08:01 UTC
  • mto: This revision was merged to the branch mainline in revision 5491.
  • Revision ID: v.ladeuil+lp@free.fr-20101007060801-wfdhizfhfmctl8qa
Fix some typos and propose a release planning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
"""
25
25
 
26
26
 
27
 
from bzrlib import (
28
 
    config,
29
 
    tests,
30
 
    )
 
27
import os
31
28
 
 
29
from bzrlib.branch import Branch
 
30
from bzrlib.config import extract_email_address
 
31
from bzrlib.tests import TestCaseWithTransport
32
32
from bzrlib.urlutils import joinpath
33
33
 
34
34
 
35
 
class TestAnnotate(tests.TestCaseWithTransport):
 
35
class TestAnnotate(TestCaseWithTransport):
36
36
 
37
37
    def setUp(self):
38
38
        super(TestAnnotate, self).setUp()
151
151
                         err)
152
152
 
153
153
 
154
 
class TestSimpleAnnotate(tests.TestCaseWithTransport):
 
154
class TestSimpleAnnotate(TestCaseWithTransport):
155
155
    """Annotate tests with no complex setup."""
156
156
 
157
157
    def _setup_edited_file(self, relpath='.'):
162
162
        tree.add('file')
163
163
        tree.commit('add file', committer="test@host", rev_id="rev1")
164
164
        self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
 
165
        tree.branch.get_config().set_user_option('email', 'current@host2')
165
166
        return tree
166
167
 
167
168
    def test_annotate_cmd_revspec_branch(self):
168
169
        tree = self._setup_edited_file('trunk')
169
170
        tree.branch.create_checkout(self.get_url('work'), lightweight=True)
170
 
        out, err = self.run_bzr(['annotate', 'file', '-r', 'branch:../trunk'],
171
 
                                working_dir='work')
 
171
        os.chdir('work')
 
172
        out, err = self.run_bzr('annotate file -r branch:../trunk')
172
173
        self.assertEqual('', err)
173
174
        self.assertEqual(
174
175
            '1   test@ho | foo\n'
177
178
 
178
179
    def test_annotate_edited_file(self):
179
180
        tree = self._setup_edited_file()
180
 
        tree.branch.get_config().set_user_option('email', 'current@host2')
181
181
        out, err = self.run_bzr('annotate file')
182
182
        self.assertEqual(
183
183
            '1   test@ho | foo\n'
185
185
            '1   test@ho | gam\n',
186
186
            out)
187
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
 
 
203
188
    def test_annotate_edited_file_show_ids(self):
204
189
        tree = self._setup_edited_file()
205
 
        tree.branch.get_config().set_user_option('email', 'current@host2')
206
190
        out, err = self.run_bzr('annotate file --show-ids')
207
191
        self.assertEqual(
208
192
            '    rev1 | foo\n'
227
211
        tree.merge_from_branch(tree.branch, "rev1.1.1")
228
212
        # edit the file to be 'resolved' and have a further local edit
229
213
        self.build_tree_contents([('file', 'local\nfoo\nbar\nbaz\ngam\n')])
230
 
        return tree
231
214
 
232
215
    def test_annotated_edited_merged_file_revnos(self):
233
 
        wt = self._create_merged_file()
234
 
        out, err = self.run_bzr(['annotate', 'file'])
235
 
        email = config.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())
236
219
        self.assertEqual(
237
220
            '3?    %-7s | local\n'
238
221
            '1     test@ho | foo\n'
243
226
 
244
227
    def test_annotated_edited_merged_file_ids(self):
245
228
        self._create_merged_file()
246
 
        out, err = self.run_bzr(['annotate', 'file', '--show-ids'])
 
229
        out, err = self.run_bzr('annotate file --show-ids')
247
230
        self.assertEqual(
248
231
            'current: | local\n'
249
232
            '    rev1 | foo\n'
253
236
            out)
254
237
 
255
238
    def test_annotate_empty_file(self):
256
 
        tree = self.make_branch_and_tree('.')
257
 
        self.build_tree_contents([('empty', '')])
 
239
        tree = self.make_branch_and_tree('tree')
 
240
        self.build_tree_contents([('tree/empty', '')])
258
241
        tree.add('empty')
259
242
        tree.commit('add empty file')
260
 
        out, err = self.run_bzr(['annotate', 'empty'])
261
 
        self.assertEqual('', out)
262
243
 
263
 
    def test_annotate_removed_file(self):
264
 
        tree = self.make_branch_and_tree('.')
265
 
        self.build_tree_contents([('empty', '')])
266
 
        tree.add('empty')
267
 
        tree.commit('add empty file')
268
 
        # delete the file.
269
 
        tree.remove('empty')
270
 
        tree.commit('remove empty file')
271
 
        out, err = self.run_bzr(['annotate', '-r1', 'empty'])
 
244
        os.chdir('tree')
 
245
        out, err = self.run_bzr('annotate empty')
272
246
        self.assertEqual('', out)
273
247
 
274
248
    def test_annotate_empty_file_show_ids(self):
275
 
        tree = self.make_branch_and_tree('.')
276
 
        self.build_tree_contents([('empty', '')])
 
249
        tree = self.make_branch_and_tree('tree')
 
250
        self.build_tree_contents([('tree/empty', '')])
277
251
        tree.add('empty')
278
252
        tree.commit('add empty file')
 
253
 
 
254
        os.chdir('tree')
279
255
        out, err = self.run_bzr(['annotate', '--show-ids', 'empty'])
280
256
        self.assertEqual('', out)
281
257
 
282
258
    def test_annotate_nonexistant_file(self):
283
 
        tree = self.make_branch_and_tree('.')
284
 
        self.build_tree(['file'])
 
259
        tree = self.make_branch_and_tree('tree')
 
260
        self.build_tree(['tree/file'])
285
261
        tree.add(['file'])
286
262
        tree.commit('add a file')
287
 
        out, err = self.run_bzr(['annotate', 'doesnotexist'], retcode=3)
 
263
 
 
264
        os.chdir('tree')
 
265
        out, err = self.run_bzr("annotate doesnotexist", retcode=3)
288
266
        self.assertEqual('', out)
289
267
        self.assertEqual("bzr: ERROR: doesnotexist is not versioned.\n", err)
290
268
 
291
269
    def test_annotate_without_workingtree(self):
292
 
        tree = self.make_branch_and_tree('.')
293
 
        self.build_tree_contents([('empty', '')])
 
270
        tree = self.make_branch_and_tree('branch')
 
271
        self.build_tree_contents([('branch/empty', '')])
294
272
        tree.add('empty')
295
273
        tree.commit('add empty file')
296
274
        bzrdir = tree.branch.bzrdir
297
275
        bzrdir.destroy_workingtree()
298
276
        self.assertFalse(bzrdir.has_workingtree())
299
 
        out, err = self.run_bzr(['annotate', 'empty'])
 
277
 
 
278
        os.chdir('branch')
 
279
        out, err = self.run_bzr('annotate empty')
300
280
        self.assertEqual('', out)
301
281
 
302
282
    def test_annotate_directory(self):
305
285
        self.build_tree_contents([('a/hello.txt', 'my helicopter\n')])
306
286
        wt.add(['hello.txt'])
307
287
        wt.commit('commit', committer='test@user')
308
 
        out, err = self.run_bzr(['annotate', '-d', 'a', 'hello.txt'])
 
288
        out, err = self.run_bzr('annotate -d a hello.txt')
309
289
        self.assertEqualDiff('1   test@us | my helicopter\n', out)