/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.2 by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical
1
# Copyright (C) 2005 Canonical Ltd
1185.16.32 by Martin Pool
- add a basic annotate built-in command
2
# -*- coding: utf-8 -*-
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
3
#
1185.16.32 by Martin Pool
- add a basic annotate built-in command
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
8
#
1185.16.32 by Martin Pool
- add a basic annotate built-in command
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
13
#
1185.16.32 by Martin Pool
- add a basic annotate built-in command
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
19
"""Black-box tests for bzr.
20
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 
23
rather starts again from the run_bzr function.
24
"""
25
26
27
import os
28
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
29
from bzrlib.tests import TestCaseWithTransport
1185.16.32 by Martin Pool
- add a basic annotate built-in command
30
31
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
32
class TestAnnotate(TestCaseWithTransport):
33
1185.16.53 by Martin Pool
- annotate improvements from Goffreddo, with extra bug fixes and tests
34
    def setUp(self):
35
        super(TestAnnotate, self).setUp()
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
36
        wt = self.make_branch_and_tree('.')
37
        b = wt.branch
1185.33.31 by Martin Pool
Make annotate cope better with revisions committed without a valid
38
        self.build_tree_contents([('hello.txt', 'my helicopter\n'),
39
                                  ('nomail.txt', 'nomail\n')])
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
40
        wt.add(['hello.txt'])
2182.3.7 by John Arbash Meinel
Cleanup and add blackbox tests for annotate.
41
        self.revision_id_1 = wt.commit('add hello',
42
                              committer='test@user', timestamp=1165960000.00)
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
43
        wt.add(['nomail.txt'])
2182.3.7 by John Arbash Meinel
Cleanup and add blackbox tests for annotate.
44
        self.revision_id_2 = wt.commit('add nomail',
45
                              committer='no mail', timestamp=1165970000.00)
46
        self.build_tree_contents([('hello.txt', 'my helicopter\n'
47
                                                'your helicopter\n')])
48
        self.revision_id_3 = wt.commit('mod hello',
49
                              committer='user@test', timestamp=1166040000.00)
50
        self.build_tree_contents([('hello.txt', 'my helicopter\n'
51
                                                'your helicopter\n'
52
                                                'all of\n'
53
                                                'our helicopters\n'
54
                                  )])
55
        self.revision_id_4 = wt.commit('mod hello',
56
                              committer='user@test', timestamp=1166050000.00)
1185.16.53 by Martin Pool
- annotate improvements from Goffreddo, with extra bug fixes and tests
57
1185.16.32 by Martin Pool
- add a basic annotate built-in command
58
    def test_help_annotate(self):
59
        """Annotate command exists"""
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
60
        out, err = self.run_bzr('--no-plugins', 'annotate', '--help')
1185.16.53 by Martin Pool
- annotate improvements from Goffreddo, with extra bug fixes and tests
61
62
    def test_annotate_cmd(self):
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
63
        out, err = self.run_bzr('annotate', 'hello.txt')
64
        self.assertEqual('', err)
65
        self.assertEqualDiff('''\
2182.3.3 by John Arbash Meinel
Add tests for annotate with dotted revnos.
66
1   test@us | my helicopter
67
3   user@te | your helicopter
2182.3.7 by John Arbash Meinel
Cleanup and add blackbox tests for annotate.
68
4   user@te | all of
69
            | our helicopters
70
''', out)
71
72
    def test_annotate_cmd_full(self):
73
        out, err = self.run_bzr('annotate', 'hello.txt', '--all')
74
        self.assertEqual('', err)
75
        self.assertEqualDiff('''\
76
1   test@us | my helicopter
77
3   user@te | your helicopter
78
4   user@te | all of
79
4   user@te | our helicopters
80
''', out)
81
82
    def test_annotate_cmd_long(self):
83
        out, err = self.run_bzr('annotate', 'hello.txt', '--long')
84
        self.assertEqual('', err)
85
        self.assertEqualDiff('''\
86
1   test@user 20061212 | my helicopter
87
3   user@test 20061213 | your helicopter
88
4   user@test 20061213 | all of
89
                       | our helicopters
90
''', out)
91
92
    def test_annotate_cmd_show_ids(self):
93
        out, err = self.run_bzr('annotate', 'hello.txt', '--show-ids')
94
        max_len = max([len(self.revision_id_1),
95
                       len(self.revision_id_3),
96
                       len(self.revision_id_4)])
97
        self.assertEqual('', err)
98
        self.assertEqualDiff('''\
99
%*s | my helicopter
100
%*s | your helicopter
101
%*s | all of
102
%*s | our helicopters
103
''' % (max_len, self.revision_id_1,
104
       max_len, self.revision_id_3,
105
       max_len, self.revision_id_4,
106
       max_len, '',
107
      )
108
, out)
1185.33.31 by Martin Pool
Make annotate cope better with revisions committed without a valid
109
110
    def test_no_mail(self):
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
111
        out, err = self.run_bzr('annotate', 'nomail.txt')
112
        self.assertEqual('', err)
113
        self.assertEqualDiff('''\
2182.3.3 by John Arbash Meinel
Add tests for annotate with dotted revnos.
114
2   no mail | nomail
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
115
''', out)
1694.2.6 by Martin Pool
[merge] bzr.dev
116
117
    def test_annotate_cmd_revision(self):
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
118
        out, err = self.run_bzr('annotate', 'hello.txt', '-r1')
119
        self.assertEqual('', err)
120
        self.assertEqualDiff('''\
2182.3.3 by John Arbash Meinel
Add tests for annotate with dotted revnos.
121
1   test@us | my helicopter
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
122
''', out)
1694.2.6 by Martin Pool
[merge] bzr.dev
123
1558.14.6 by Aaron Bentley
Added annotate test
124
    def test_annotate_cmd_revision3(self):
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
125
        out, err = self.run_bzr('annotate', 'hello.txt', '-r3')
126
        self.assertEqual('', err)
127
        self.assertEqualDiff('''\
2182.3.3 by John Arbash Meinel
Add tests for annotate with dotted revnos.
128
1   test@us | my helicopter
129
3   user@te | your helicopter
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
130
''', out)
1558.14.6 by Aaron Bentley
Added annotate test
131
1694.2.6 by Martin Pool
[merge] bzr.dev
132
    def test_annotate_cmd_unknown_revision(self):
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
133
        out, err = self.run_bzr('annotate', 'hello.txt', '-r', '10',
134
                                retcode=3)
135
        self.assertEqual('', out)
1948.4.15 by John Arbash Meinel
Change the InvalidRevisionSpec formatting to be more readable
136
        self.assertContainsRe(err, 'Requested revision: \'10\' does not exist')
1694.2.6 by Martin Pool
[merge] bzr.dev
137
138
    def test_annotate_cmd_two_revisions(self):
2182.3.6 by John Arbash Meinel
Cleanup annotate blackbox tests
139
        out, err = self.run_bzr('annotate', 'hello.txt', '-r1..2',
140
                                retcode=3)
141
        self.assertEqual('', out)
142
        self.assertEqual('bzr: ERROR: bzr annotate --revision takes'
143
                         ' exactly 1 argument\n',
144
                         err)
2027.3.1 by John Arbash Meinel
'bzr annotate' shouldn't fail on an empty file: fix bug #56814
145
146
    def test_annotate_empty_file(self):
147
        tree = self.make_branch_and_tree('tree')
148
        self.build_tree_contents([('tree/empty', '')])
149
        tree.add('empty')
150
        tree.commit('add empty file')
151
152
        os.chdir('tree')
153
        out, err = self.run_bzr('annotate', 'empty')
154
        self.assertEqual('', out)