~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin
  • Date: 2010-05-25 17:27:52 UTC
  • mfrom: (5254 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5257.
  • Revision ID: gzlist@googlemail.com-20100525172752-amm089xcikv968sw
Merge bzr.dev to unite with similar changes already made

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
29
29
from bzrlib.branch import Branch
30
30
from bzrlib.config import extract_email_address
31
31
from bzrlib.tests import TestCaseWithTransport
 
32
from bzrlib.urlutils import joinpath
32
33
 
33
34
 
34
35
class TestAnnotate(TestCaseWithTransport):
139
140
        out, err = self.run_bzr('annotate hello.txt -r 10',
140
141
                                retcode=3)
141
142
        self.assertEqual('', out)
142
 
        self.assertContainsRe(err, 'Requested revision: \'10\' does not exist')
 
143
        self.assertContainsRe(err, "Requested revision: '10' does not exist")
143
144
 
144
145
    def test_annotate_cmd_two_revisions(self):
145
146
        out, err = self.run_bzr('annotate hello.txt -r1..2',
153
154
class TestSimpleAnnotate(TestCaseWithTransport):
154
155
    """Annotate tests with no complex setup."""
155
156
 
156
 
    def _setup_edited_file(self):
 
157
    def _setup_edited_file(self, relpath='.'):
157
158
        """Create a tree with a locally edited file."""
158
 
        tree = self.make_branch_and_tree('.')
159
 
        self.build_tree_contents([('file', 'foo\ngam\n')])
 
159
        tree = self.make_branch_and_tree(relpath)
 
160
        file_relpath = joinpath(relpath, 'file')
 
161
        self.build_tree_contents([(file_relpath, 'foo\ngam\n')])
160
162
        tree.add('file')
161
163
        tree.commit('add file', committer="test@host", rev_id="rev1")
162
 
        self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
 
164
        self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
163
165
        tree.branch.get_config().set_user_option('email', 'current@host2')
 
166
        return tree
 
167
 
 
168
    def test_annotate_cmd_revspec_branch(self):
 
169
        tree = self._setup_edited_file('trunk')
 
170
        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')
 
173
        self.assertEqual('', err)
 
174
        self.assertEqual(
 
175
            '1   test@ho | foo\n'
 
176
            '            | gam\n',
 
177
            out)
164
178
 
165
179
    def test_annotate_edited_file(self):
166
180
        tree = self._setup_edited_file()
264
278
        os.chdir('branch')
265
279
        out, err = self.run_bzr('annotate empty')
266
280
        self.assertEqual('', out)
 
281
 
 
282
    def test_annotate_directory(self):
 
283
        """Test --directory option"""
 
284
        wt = self.make_branch_and_tree('a')
 
285
        self.build_tree_contents([('a/hello.txt', 'my helicopter\n')])
 
286
        wt.add(['hello.txt'])
 
287
        wt.commit('commit', committer='test@user')
 
288
        out, err = self.run_bzr('annotate -d a hello.txt')
 
289
        self.assertEqualDiff('1   test@us | my helicopter\n', out)