~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2009-01-28 18:42:55 UTC
  • mto: This revision was merged to the branch mainline in revision 3968.
  • Revision ID: jelmer@samba.org-20090128184255-bdmklkvm83ltk191
Update NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
                                 ('a', 'hello\n'),
37
37
                                 ])
38
38
 
39
 
    def ls_equals(self, value, *args):
40
 
        out, err = self.run_bzr('ls', *args)
 
39
    def ls_equals(self, value, args=None):
 
40
        command = 'ls'
 
41
        if args is not None:
 
42
            command += ' ' + args
 
43
        out, err = self.run_bzr(command)
41
44
        self.assertEqual('', err)
42
45
        self.assertEqualDiff(value, out)
43
46
 
44
47
    def test_ls_null_verbose(self):
45
48
        # Can't supply both
46
49
        self.run_bzr_error(['Cannot set both --verbose and --null'],
47
 
                           'ls', '--verbose', '--null')
 
50
                           'ls --verbose --null')
48
51
 
49
52
    def test_ls_basic(self):
50
53
        """Test the abilities of 'bzr ls'"""
57
60
                       '--unknown')
58
61
        self.ls_equals('', '--ignored')
59
62
        self.ls_equals('', '--versioned')
60
 
        self.ls_equals('.bzrignore\n'
61
 
                       'a\n',
62
 
                       '--unknown', '--ignored', '--versioned')
63
 
        self.ls_equals('', '--ignored', '--versioned')
 
63
        self.ls_equals('', '-V')
 
64
        self.ls_equals('.bzrignore\n'
 
65
                       'a\n',
 
66
                       '--unknown --ignored --versioned')
 
67
        self.ls_equals('.bzrignore\n'
 
68
                       'a\n',
 
69
                       '--unknown --ignored -V')
 
70
        self.ls_equals('', '--ignored --versioned')
 
71
        self.ls_equals('', '--ignored -V')
64
72
        self.ls_equals('.bzrignore\0a\0', '--null')
65
73
 
66
74
    def test_ls_added(self):
89
97
        self.ls_equals(
90
98
            '.bzrignore                                         \n'
91
99
            'a                                                  a-id\n'
92
 
            'subdir                                             subdir-id\n', 
 
100
            'subdir/                                            subdir-id\n', 
93
101
            '--show-ids')
94
102
        self.ls_equals(
95
103
            '?        .bzrignore\n'
96
104
            'V        a                                         a-id\n'
97
105
            'V        subdir/                                   subdir-id\n', 
98
 
            '--show-ids', '--verbose')
 
106
            '--show-ids --verbose')
99
107
        self.ls_equals('.bzrignore\0\0'
100
108
                       'a\0a-id\0'
101
 
                       'subdir\0subdir-id\0', '--show-ids', '--null')
 
109
                       'subdir\0subdir-id\0', '--show-ids --null')
102
110
 
103
111
    def test_ls_recursive(self):
104
112
        self.build_tree(['subdir/', 'subdir/b'])
106
114
 
107
115
        self.ls_equals('.bzrignore\n'
108
116
                       'a\n'
109
 
                       'subdir\n'
 
117
                       'subdir/\n'
110
118
                       , '--non-recursive')
111
119
 
112
120
        self.ls_equals('V        .bzrignore\n'
113
121
                       'V        a\n'
114
122
                       'V        subdir/\n'
115
 
                       , '--verbose', '--non-recursive')
 
123
                       , '--verbose --non-recursive')
116
124
 
117
125
        # Check what happens in a sub-directory
118
126
        os.chdir('subdir')
121
129
                  , '--null')
122
130
        self.ls_equals('.bzrignore\n'
123
131
                       'a\n'
124
 
                       'subdir\n'
 
132
                       'subdir/\n'
125
133
                       'subdir/b\n'
126
134
                       , '--from-root')
127
135
        self.ls_equals('.bzrignore\0'
128
136
                       'a\0'
129
137
                       'subdir\0'
130
138
                       'subdir/b\0'
131
 
                       , '--from-root', '--null')
 
139
                       , '--from-root --null')
132
140
        self.ls_equals('.bzrignore\n'
133
141
                       'a\n'
134
 
                       'subdir\n'
135
 
                       , '--from-root', '--non-recursive')
 
142
                       'subdir/\n'
 
143
                       , '--from-root --non-recursive')
136
144
 
137
145
    def test_ls_path(self):
138
146
        """If a path is specified, files are listed with that prefix"""
143
151
        os.chdir('subdir')
144
152
        self.ls_equals('../.bzrignore\n'
145
153
                       '../a\n'
146
 
                       '../subdir\n'
 
154
                       '../subdir/\n'
147
155
                       '../subdir/b\n' ,
148
156
                       '..')
149
157
        self.ls_equals('../.bzrignore\0'
150
158
                       '../a\0'
151
159
                       '../subdir\0'
152
160
                       '../subdir/b\0' ,
153
 
                       '..', '--null')
 
161
                       '.. --null')
154
162
        self.ls_equals('?        ../.bzrignore\n'
155
163
                       '?        ../a\n'
156
164
                       'V        ../subdir/\n'
157
165
                       'V        ../subdir/b\n' ,
158
 
                       '..', '--verbose')
159
 
        self.run_bzr_error('cannot specify both --from-root and PATH', 'ls',
160
 
                           '--from-root', '..')
 
166
                       '.. --verbose')
 
167
        self.run_bzr_error('cannot specify both --from-root and PATH',
 
168
                           'ls --from-root ..')
161
169
 
162
170
    def test_ls_revision(self):
163
171
        self.wt.add(['a'])
166
174
        self.build_tree(['subdir/'])
167
175
 
168
176
        # Check what happens when we supply a specific revision
169
 
        self.ls_equals('a\n', '--revision', '1')
 
177
        self.ls_equals('a\n', '--revision 1')
170
178
        self.ls_equals('V        a\n'
171
 
                       , '--verbose', '--revision', '1')
 
179
                       , '--verbose --revision 1')
172
180
 
173
181
        os.chdir('subdir')
174
 
        self.ls_equals('', '--revision', '1')
 
182
        self.ls_equals('', '--revision 1')
175
183
 
176
184
    def test_ls_branch(self):
177
185
        """If a branch is specified, files are listed from it"""
180
188
        self.wt.commit('committing')
181
189
        branch = self.make_branch('branchdir')
182
190
        branch.pull(self.wt.branch)
183
 
        self.ls_equals('branchdir/subdir\n'
 
191
        self.ls_equals('branchdir/subdir/\n'
184
192
                       'branchdir/subdir/b\n',
185
193
                       'branchdir')
186
 
        self.ls_equals('branchdir/subdir\n'
 
194
        self.ls_equals('branchdir/subdir/\n'
187
195
                       'branchdir/subdir/b\n',
188
 
                       'branchdir', '--revision', '1')
 
196
                       'branchdir --revision 1')
189
197
 
190
198
    def test_ls_ignored(self):
191
199
        # Now try to do ignored files.
212
220
        self.ls_equals('.bzrignore\n'
213
221
                       'a\n'
214
222
                       , '--versioned')
 
223
        self.ls_equals('.bzrignore\n'
 
224
                       'a\n'
 
225
                       , '-V')
215
226
 
216
227
    def test_kinds(self):
217
228
        self.build_tree(['subdir/'])
218
229
        self.ls_equals('.bzrignore\n' 
219
230
                       'a\n', 
220
231
                       '--kind=file')
221
 
        self.ls_equals('subdir\n',
 
232
        self.ls_equals('subdir/\n',
222
233
                       '--kind=directory')
223
234
        self.ls_equals('',
224
235
                       '--kind=symlink')
225
 
        self.run_bzr_error('invalid kind specified', 'ls', '--kind=pile')
 
236
        self.run_bzr_error('invalid kind specified', 'ls --kind=pile')