~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""External tests of 'bzr ls'"""
18
18
 
26
26
 
27
27
    def setUp(self):
28
28
        super(TestLS, self).setUp()
29
 
 
 
29
        
30
30
        # Create a simple branch that can be used in testing
31
 
        ignores._set_user_ignores(['user-ignore'])
 
31
        ignores._set_user_ignores(['./.bazaar', 'user-ignore'])
32
32
 
33
33
        self.wt = self.make_branch_and_tree('.')
34
34
        self.build_tree_contents([
36
36
                                 ('a', 'hello\n'),
37
37
                                 ])
38
38
 
39
 
    def ls_equals(self, value, args=None, recursive=True):
40
 
        command = 'ls'
41
 
        if args is not None:
42
 
            command += ' ' + args
43
 
        if recursive:
44
 
            command += ' -R'
45
 
        out, err = self.run_bzr(command)
 
39
    def ls_equals(self, value, *args):
 
40
        out, err = self.run_bzr('ls', *args)
46
41
        self.assertEqual('', err)
47
 
        self.assertEqualDiff(value, out)
 
42
        self.assertEqual(value, out)
48
43
 
49
44
    def test_ls_null_verbose(self):
50
45
        # Can't supply both
51
46
        self.run_bzr_error(['Cannot set both --verbose and --null'],
52
 
                           'ls --verbose --null')
 
47
                           'ls', '--verbose', '--null')
53
48
 
54
49
    def test_ls_basic(self):
55
50
        """Test the abilities of 'bzr ls'"""
56
 
        self.ls_equals('.bzrignore\na\n')
57
 
        self.ls_equals('.bzrignore\na\n', './')
58
 
        self.ls_equals('?        .bzrignore\n'
 
51
        self.ls_equals('.bazaar\n.bzrignore\na\n')
 
52
        self.ls_equals('I        .bazaar/\n'
 
53
                       '?        .bzrignore\n'
59
54
                       '?        a\n',
60
55
                       '--verbose')
61
56
        self.ls_equals('.bzrignore\n'
62
57
                       'a\n',
63
58
                       '--unknown')
64
 
        self.ls_equals('', '--ignored')
 
59
        self.ls_equals('.bazaar\n', '--ignored')
65
60
        self.ls_equals('', '--versioned')
66
 
        self.ls_equals('', '-V')
67
 
        self.ls_equals('.bzrignore\n'
68
 
                       'a\n',
69
 
                       '--unknown --ignored --versioned')
70
 
        self.ls_equals('.bzrignore\n'
71
 
                       'a\n',
72
 
                       '--unknown --ignored -V')
73
 
        self.ls_equals('', '--ignored --versioned')
74
 
        self.ls_equals('', '--ignored -V')
75
 
        self.ls_equals('.bzrignore\0a\0', '--null')
 
61
        self.ls_equals('.bazaar\n'
 
62
                       '.bzrignore\n'
 
63
                       'a\n',
 
64
                       '--unknown', '--ignored', '--versioned')
 
65
        self.ls_equals('.bazaar\n', '--ignored', '--versioned')
 
66
        self.ls_equals('.bazaar\0.bzrignore\0a\0', '--null')
76
67
 
77
68
    def test_ls_added(self):
78
69
        self.wt.add(['a'])
79
 
        self.ls_equals('?        .bzrignore\n'
 
70
        self.ls_equals('I        .bazaar/\n'
 
71
                       '?        .bzrignore\n'
80
72
                       'V        a\n',
81
73
                       '--verbose')
82
74
        self.wt.commit('add')
83
 
 
 
75
        
84
76
        self.build_tree(['subdir/'])
85
 
        self.ls_equals('?        .bzrignore\n'
 
77
        self.ls_equals('I        .bazaar/\n'
 
78
                       '?        .bzrignore\n'
86
79
                       'V        a\n'
87
80
                       '?        subdir/\n'
88
81
                       , '--verbose')
89
82
        self.build_tree(['subdir/b'])
90
83
        self.wt.add(['subdir/', 'subdir/b', '.bzrignore'])
91
 
        self.ls_equals('V        .bzrignore\n'
 
84
        self.ls_equals('I        .bazaar/\n'
 
85
                       'V        .bzrignore\n'
92
86
                       'V        a\n'
93
87
                       'V        subdir/\n'
94
88
                       'V        subdir/b\n'
95
89
                       , '--verbose')
96
90
 
97
 
    def test_show_ids(self):
98
 
        self.build_tree(['subdir/'])
99
 
        self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id'])
100
 
        self.ls_equals(
101
 
            '.bzrignore                                         \n'
102
 
            'a                                                  a-id\n'
103
 
            'subdir/                                            subdir-id\n',
104
 
            '--show-ids')
105
 
        self.ls_equals(
106
 
            '?        .bzrignore\n'
107
 
            'V        a                                         a-id\n'
108
 
            'V        subdir/                                   subdir-id\n',
109
 
            '--show-ids --verbose')
110
 
        self.ls_equals('.bzrignore\0\0'
111
 
                       'a\0a-id\0'
112
 
                       'subdir\0subdir-id\0', '--show-ids --null')
113
 
 
114
 
    def test_ls_no_recursive(self):
 
91
    def test_ls_recursive(self):
115
92
        self.build_tree(['subdir/', 'subdir/b'])
116
93
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
117
94
 
118
 
        self.ls_equals('.bzrignore\n'
 
95
        self.ls_equals('.bazaar\n'
 
96
                       '.bzrignore\n'
119
97
                       'a\n'
120
 
                       'subdir/\n'
121
 
                       , recursive=False)
 
98
                       'subdir\n'
 
99
                       , '--non-recursive')
122
100
 
123
 
        self.ls_equals('V        .bzrignore\n'
 
101
        self.ls_equals('I        .bazaar/\n'
 
102
                       'V        .bzrignore\n'
124
103
                       'V        a\n'
125
104
                       'V        subdir/\n'
126
 
                       , '--verbose', recursive=False)
 
105
                       , '--verbose', '--non-recursive')
127
106
 
128
107
        # Check what happens in a sub-directory
129
108
        os.chdir('subdir')
130
109
        self.ls_equals('b\n')
131
110
        self.ls_equals('b\0'
132
111
                  , '--null')
133
 
        self.ls_equals('subdir/b\n'
 
112
        self.ls_equals('.bazaar\n'
 
113
                       '.bzrignore\n'
 
114
                       'a\n'
 
115
                       'subdir\n'
 
116
                       'subdir/b\n'
134
117
                       , '--from-root')
135
 
        self.ls_equals('subdir/b\0'
136
 
                       , '--from-root --null')
137
 
        self.ls_equals('subdir/b\n'
138
 
                       , '--from-root', recursive=False)
139
 
 
140
 
    def test_ls_path(self):
141
 
        """If a path is specified, files are listed with that prefix"""
142
 
        self.build_tree(['subdir/', 'subdir/b'])
143
 
        self.wt.add(['subdir', 'subdir/b'])
144
 
        self.ls_equals('subdir/b\n' ,
145
 
                       'subdir')
146
 
        os.chdir('subdir')
147
 
        self.ls_equals('../.bzrignore\n'
148
 
                       '../a\n'
149
 
                       '../subdir/\n'
150
 
                       '../subdir/b\n' ,
151
 
                       '..')
152
 
        self.ls_equals('../.bzrignore\0'
153
 
                       '../a\0'
154
 
                       '../subdir\0'
155
 
                       '../subdir/b\0' ,
156
 
                       '.. --null')
157
 
        self.ls_equals('?        ../.bzrignore\n'
158
 
                       '?        ../a\n'
159
 
                       'V        ../subdir/\n'
160
 
                       'V        ../subdir/b\n' ,
161
 
                       '.. --verbose')
162
 
        self.run_bzr_error(['cannot specify both --from-root and PATH'],
163
 
                           'ls --from-root ..')
 
118
        self.ls_equals('.bazaar\0'
 
119
                       '.bzrignore\0'
 
120
                       'a\0'
 
121
                       'subdir\0'
 
122
                       'subdir/b\0'
 
123
                       , '--from-root', '--null')
 
124
        self.ls_equals('.bazaar\n'
 
125
                       '.bzrignore\n'
 
126
                       'a\n'
 
127
                       'subdir\n'
 
128
                       , '--from-root', '--non-recursive')
164
129
 
165
130
    def test_ls_revision(self):
166
131
        self.wt.add(['a'])
169
134
        self.build_tree(['subdir/'])
170
135
 
171
136
        # Check what happens when we supply a specific revision
172
 
        self.ls_equals('a\n', '--revision 1')
 
137
        self.ls_equals('a\n', '--revision', '1')
173
138
        self.ls_equals('V        a\n'
174
 
                       , '--verbose --revision 1')
 
139
                       , '--verbose', '--revision', '1')
175
140
 
176
141
        os.chdir('subdir')
177
 
        self.ls_equals('', '--revision 1')
178
 
 
179
 
    def test_ls_branch(self):
180
 
        """If a branch is specified, files are listed from it"""
181
 
        self.build_tree(['subdir/', 'subdir/b'])
182
 
        self.wt.add(['subdir', 'subdir/b'])
183
 
        self.wt.commit('committing')
184
 
        branch = self.make_branch('branchdir')
185
 
        branch.pull(self.wt.branch)
186
 
        self.ls_equals('branchdir/subdir/\n'
187
 
                       'branchdir/subdir/b\n',
188
 
                       'branchdir')
189
 
        self.ls_equals('branchdir/subdir/\n'
190
 
                       'branchdir/subdir/b\n',
191
 
                       'branchdir --revision 1')
 
142
        self.ls_equals('', '--revision', '1')
192
143
 
193
144
    def test_ls_ignored(self):
194
145
        # Now try to do ignored files.
195
146
        self.wt.add(['a', '.bzrignore'])
196
147
 
197
148
        self.build_tree(['blah.py', 'blah.pyo', 'user-ignore'])
198
 
        self.ls_equals('.bzrignore\n'
 
149
        self.ls_equals('.bazaar\n'
 
150
                       '.bzrignore\n'
199
151
                       'a\n'
200
152
                       'blah.py\n'
201
153
                       'blah.pyo\n'
202
154
                       'user-ignore\n'
203
155
                       )
204
 
        self.ls_equals('V        .bzrignore\n'
 
156
        self.ls_equals('I        .bazaar/\n'
 
157
                       'V        .bzrignore\n'
205
158
                       'V        a\n'
206
159
                       '?        blah.py\n'
207
160
                       'I        blah.pyo\n'
208
161
                       'I        user-ignore\n'
209
162
                       , '--verbose')
210
 
        self.ls_equals('blah.pyo\n'
 
163
        self.ls_equals('.bazaar\n'
 
164
                       'blah.pyo\n'
211
165
                       'user-ignore\n'
212
166
                       , '--ignored')
213
167
        self.ls_equals('blah.py\n'
215
169
        self.ls_equals('.bzrignore\n'
216
170
                       'a\n'
217
171
                       , '--versioned')
218
 
        self.ls_equals('.bzrignore\n'
219
 
                       'a\n'
220
 
                       , '-V')
221
 
 
222
 
    def test_kinds(self):
223
 
        self.build_tree(['subdir/'])
224
 
        self.ls_equals('.bzrignore\n'
225
 
                       'a\n',
226
 
                       '--kind=file')
227
 
        self.ls_equals('subdir/\n',
228
 
                       '--kind=directory')
229
 
        self.ls_equals('',
230
 
                       '--kind=symlink')
231
 
        self.run_bzr_error(['invalid kind specified'], 'ls --kind=pile')
232
 
 
233
 
    def test_ls_path_nonrecursive(self):
234
 
        self.ls_equals('%s/.bzrignore\n'
235
 
                       '%s/a\n'
236
 
                       % (self.test_dir, self.test_dir),
237
 
                       self.test_dir, recursive=False)
 
172