~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2007-06-21 23:43:17 UTC
  • mto: (2520.5.2 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: abentley@panoramicfeedback.com-20070621234317-5w3h8h36oe90sups
Implement new merge directive format

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006 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
31
        ignores._set_user_ignores(['user-ignore'])
32
32
 
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
42
        self.assertEqualDiff(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
51
        self.ls_equals('.bzrignore\na\n')
57
 
        self.ls_equals('.bzrignore\na\n', './')
58
52
        self.ls_equals('?        .bzrignore\n'
59
53
                       '?        a\n',
60
54
                       '--verbose')
63
57
                       '--unknown')
64
58
        self.ls_equals('', '--ignored')
65
59
        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')
 
60
        self.ls_equals('.bzrignore\n'
 
61
                       'a\n',
 
62
                       '--unknown', '--ignored', '--versioned')
 
63
        self.ls_equals('', '--ignored', '--versioned')
75
64
        self.ls_equals('.bzrignore\0a\0', '--null')
76
65
 
77
66
    def test_ls_added(self):
80
69
                       'V        a\n',
81
70
                       '--verbose')
82
71
        self.wt.commit('add')
83
 
 
 
72
        
84
73
        self.build_tree(['subdir/'])
85
74
        self.ls_equals('?        .bzrignore\n'
86
75
                       'V        a\n'
100
89
        self.ls_equals(
101
90
            '.bzrignore                                         \n'
102
91
            'a                                                  a-id\n'
103
 
            'subdir/                                            subdir-id\n',
 
92
            'subdir                                             subdir-id\n', 
104
93
            '--show-ids')
105
94
        self.ls_equals(
106
95
            '?        .bzrignore\n'
107
96
            'V        a                                         a-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'
111
100
                       'a\0a-id\0'
112
 
                       'subdir\0subdir-id\0', '--show-ids --null')
 
101
                       'subdir\0subdir-id\0', '--show-ids', '--null')
113
102
 
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'])
117
106
 
118
107
        self.ls_equals('.bzrignore\n'
119
108
                       'a\n'
120
 
                       'subdir/\n'
121
 
                       , recursive=False)
 
109
                       'subdir\n'
 
110
                       , '--non-recursive')
122
111
 
123
112
        self.ls_equals('V        .bzrignore\n'
124
113
                       'V        a\n'
125
114
                       'V        subdir/\n'
126
 
                       , '--verbose', recursive=False)
 
115
                       , '--verbose', '--non-recursive')
127
116
 
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'
132
121
                  , '--null')
133
 
        self.ls_equals('subdir/b\n'
 
122
        self.ls_equals('.bzrignore\n'
 
123
                       'a\n'
 
124
                       'subdir\n'
 
125
                       'subdir/b\n'
134
126
                       , '--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)
 
127
        self.ls_equals('.bzrignore\0'
 
128
                       'a\0'
 
129
                       'subdir\0'
 
130
                       'subdir/b\0'
 
131
                       , '--from-root', '--null')
 
132
        self.ls_equals('.bzrignore\n'
 
133
                       'a\n'
 
134
                       'subdir\n'
 
135
                       , '--from-root', '--non-recursive')
139
136
 
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'
148
145
                       '../a\n'
149
 
                       '../subdir/\n'
 
146
                       '../subdir\n'
150
147
                       '../subdir/b\n' ,
151
148
                       '..')
152
149
        self.ls_equals('../.bzrignore\0'
153
150
                       '../a\0'
154
151
                       '../subdir\0'
155
152
                       '../subdir/b\0' ,
156
 
                       '.. --null')
 
153
                       '..', '--null')
157
154
        self.ls_equals('?        ../.bzrignore\n'
158
155
                       '?        ../a\n'
159
156
                       'V        ../subdir/\n'
160
157
                       'V        ../subdir/b\n' ,
161
 
                       '.. --verbose')
162
 
        self.run_bzr_error(['cannot specify both --from-root and PATH'],
163
 
                           'ls --from-root ..')
 
158
                       '..', '--verbose')
 
159
        self.run_bzr_error('cannot specify both --from-root and PATH', 'ls',
 
160
                           '--from-root', '..')
164
161
 
165
162
    def test_ls_revision(self):
166
163
        self.wt.add(['a'])
169
166
        self.build_tree(['subdir/'])
170
167
 
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')
175
172
 
176
173
        os.chdir('subdir')
177
 
        self.ls_equals('', '--revision 1')
 
174
        self.ls_equals('', '--revision', '1')
178
175
 
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',
188
185
                       'branchdir')
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')
192
189
 
193
190
    def test_ls_ignored(self):
194
191
        # Now try to do ignored files.
215
212
        self.ls_equals('.bzrignore\n'
216
213
                       'a\n'
217
214
                       , '--versioned')
218
 
        self.ls_equals('.bzrignore\n'
219
 
                       'a\n'
220
 
                       , '-V')
221
215
 
222
216
    def test_kinds(self):
223
217
        self.build_tree(['subdir/'])
224
 
        self.ls_equals('.bzrignore\n'
225
 
                       'a\n',
 
218
        self.ls_equals('.bzrignore\n' 
 
219
                       'a\n', 
226
220
                       '--kind=file')
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')
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)
 
225
        self.run_bzr_error('invalid kind specified', 'ls', '--kind=pile')