1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006 Canonical Ltd
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
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
17
17
"""External tests of 'bzr ls'"""
39
def ls_equals(self, value, args=None, recursive=True):
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
42
self.assertEqualDiff(value, out)
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')
54
49
def test_ls_basic(self):
55
50
"""Test the abilities of 'bzr ls'"""
56
51
self.ls_equals('.bzrignore\na\n')
57
self.ls_equals('.bzrignore\na\n', './')
58
52
self.ls_equals('? .bzrignore\n'
64
58
self.ls_equals('', '--ignored')
65
59
self.ls_equals('', '--versioned')
66
self.ls_equals('', '-V')
67
self.ls_equals('.bzrignore\n'
69
'--unknown --ignored --versioned')
70
self.ls_equals('.bzrignore\n'
72
'--unknown --ignored -V')
73
self.ls_equals('', '--ignored --versioned')
74
self.ls_equals('', '--ignored -V')
60
self.ls_equals('.bzrignore\n'
62
'--unknown', '--ignored', '--versioned')
63
self.ls_equals('', '--ignored', '--versioned')
75
64
self.ls_equals('.bzrignore\0a\0', '--null')
77
66
def test_ls_added(self):
103
'subdir/ subdir-id\n',
108
'V subdir/ subdir-id\n',
109
'--show-ids --verbose')
97
'V subdir/ subdir-id\n',
98
'--show-ids', '--verbose')
110
99
self.ls_equals('.bzrignore\0\0'
112
'subdir\0subdir-id\0', '--show-ids --null')
101
'subdir\0subdir-id\0', '--show-ids', '--null')
114
def test_ls_no_recursive(self):
103
def test_ls_recursive(self):
115
104
self.build_tree(['subdir/', 'subdir/b'])
116
105
self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
118
107
self.ls_equals('.bzrignore\n'
123
112
self.ls_equals('V .bzrignore\n'
126
, '--verbose', recursive=False)
115
, '--verbose', '--non-recursive')
128
117
# Check what happens in a sub-directory
129
118
os.chdir('subdir')
130
119
self.ls_equals('b\n')
131
120
self.ls_equals('b\0'
133
self.ls_equals('subdir/b\n'
122
self.ls_equals('.bzrignore\n'
135
self.ls_equals('subdir/b\0'
136
, '--from-root --null')
137
self.ls_equals('subdir/b\n'
138
, '--from-root', recursive=False)
127
self.ls_equals('.bzrignore\0'
131
, '--from-root', '--null')
132
self.ls_equals('.bzrignore\n'
135
, '--from-root', '--non-recursive')
140
137
def test_ls_path(self):
141
138
"""If a path is specified, files are listed with that prefix"""
146
143
os.chdir('subdir')
147
144
self.ls_equals('../.bzrignore\n'
150
147
'../subdir/b\n' ,
152
149
self.ls_equals('../.bzrignore\0'
155
152
'../subdir/b\0' ,
157
154
self.ls_equals('? ../.bzrignore\n'
160
157
'V ../subdir/b\n' ,
162
self.run_bzr_error(['cannot specify both --from-root and PATH'],
159
self.run_bzr_error('cannot specify both --from-root and PATH', 'ls',
165
162
def test_ls_revision(self):
166
163
self.wt.add(['a'])
169
166
self.build_tree(['subdir/'])
171
168
# Check what happens when we supply a specific revision
172
self.ls_equals('a\n', '--revision 1')
169
self.ls_equals('a\n', '--revision', '1')
173
170
self.ls_equals('V a\n'
174
, '--verbose --revision 1')
171
, '--verbose', '--revision', '1')
176
173
os.chdir('subdir')
177
self.ls_equals('', '--revision 1')
174
self.ls_equals('', '--revision', '1')
179
176
def test_ls_branch(self):
180
177
"""If a branch is specified, files are listed from it"""
183
180
self.wt.commit('committing')
184
181
branch = self.make_branch('branchdir')
185
182
branch.pull(self.wt.branch)
186
self.ls_equals('branchdir/subdir/\n'
183
self.ls_equals('branchdir/subdir\n'
187
184
'branchdir/subdir/b\n',
189
self.ls_equals('branchdir/subdir/\n'
186
self.ls_equals('branchdir/subdir\n'
190
187
'branchdir/subdir/b\n',
191
'branchdir --revision 1')
188
'branchdir', '--revision', '1')
193
190
def test_ls_ignored(self):
194
191
# Now try to do ignored files.
215
212
self.ls_equals('.bzrignore\n'
218
self.ls_equals('.bzrignore\n'
222
216
def test_kinds(self):
223
217
self.build_tree(['subdir/'])
224
self.ls_equals('.bzrignore\n'
218
self.ls_equals('.bzrignore\n'
227
self.ls_equals('subdir/\n',
221
self.ls_equals('subdir\n',
228
222
'--kind=directory')
229
223
self.ls_equals('',
230
224
'--kind=symlink')
231
self.run_bzr_error(['invalid kind specified'], 'ls --kind=pile')
233
def test_ls_path_nonrecursive(self):
234
self.ls_equals('%s/.bzrignore\n'
236
% (self.test_dir, self.test_dir),
237
self.test_dir, recursive=False)
225
self.run_bzr_error('invalid kind specified', 'ls', '--kind=pile')