~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2008-09-23 23:28:27 UTC
  • mto: (3696.4.15 process-entry-optimised)
  • mto: This revision was merged to the branch mainline in revision 3731.
  • Revision ID: robertc@robertcollins.net-20080923232827-vpd4xsif8x8op6i3
Review feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
 
19
19
"""Black-box tests for bzr.
20
20
 
21
21
These check that it behaves properly when it's invoked through the regular
22
 
command-line interface. This doesn't actually run a new interpreter but
 
22
command-line interface. This doesn't actually run a new interpreter but 
23
23
rather starts again from the run_bzr function.
24
24
"""
25
25
 
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
33
32
 
34
33
 
35
34
class TestAnnotate(TestCaseWithTransport):
140
139
        out, err = self.run_bzr('annotate hello.txt -r 10',
141
140
                                retcode=3)
142
141
        self.assertEqual('', out)
143
 
        self.assertContainsRe(err, "Requested revision: '10' does not exist")
 
142
        self.assertContainsRe(err, 'Requested revision: \'10\' does not exist')
144
143
 
145
144
    def test_annotate_cmd_two_revisions(self):
146
145
        out, err = self.run_bzr('annotate hello.txt -r1..2',
147
146
                                retcode=3)
148
147
        self.assertEqual('', out)
149
148
        self.assertEqual('bzr: ERROR: bzr annotate --revision takes'
150
 
                         ' exactly one revision identifier\n',
 
149
                         ' exactly 1 argument\n',
151
150
                         err)
152
151
 
153
152
 
154
153
class TestSimpleAnnotate(TestCaseWithTransport):
155
154
    """Annotate tests with no complex setup."""
156
155
 
157
 
    def _setup_edited_file(self, relpath='.'):
 
156
    def _setup_edited_file(self):
158
157
        """Create a tree with a locally edited file."""
159
 
        tree = self.make_branch_and_tree(relpath)
160
 
        file_relpath = joinpath(relpath, 'file')
161
 
        self.build_tree_contents([(file_relpath, 'foo\ngam\n')])
 
158
        tree = self.make_branch_and_tree('.')
 
159
        self.build_tree_contents([('file', 'foo\ngam\n')])
162
160
        tree.add('file')
163
161
        tree.commit('add file', committer="test@host", rev_id="rev1")
164
 
        self.build_tree_contents([(file_relpath, 'foo\nbar\ngam\n')])
 
162
        self.build_tree_contents([('file', 'foo\nbar\ngam\n')])
165
163
        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)
178
164
 
179
165
    def test_annotate_edited_file(self):
180
166
        tree = self._setup_edited_file()
245
231
        out, err = self.run_bzr('annotate empty')
246
232
        self.assertEqual('', out)
247
233
 
248
 
    def test_annotate_empty_file_show_ids(self):
249
 
        tree = self.make_branch_and_tree('tree')
250
 
        self.build_tree_contents([('tree/empty', '')])
251
 
        tree.add('empty')
252
 
        tree.commit('add empty file')
253
 
 
254
 
        os.chdir('tree')
255
 
        out, err = self.run_bzr(['annotate', '--show-ids', 'empty'])
256
 
        self.assertEqual('', out)
257
 
 
258
234
    def test_annotate_nonexistant_file(self):
259
235
        tree = self.make_branch_and_tree('tree')
260
236
        self.build_tree(['tree/file'])