~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-01 23:48:08 UTC
  • mfrom: (2225.1.6 revert)
  • Revision ID: pqm@pqm.ubuntu.com-20070201234808-3b1302d73474bd8c
Display changes made by revert

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by 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
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(['./.bazaar', 'user-ignore'])
 
31
        ignores._set_user_ignores(['user-ignore'])
32
32
 
33
33
        self.wt = self.make_branch_and_tree('.')
34
34
        self.build_tree_contents([
39
39
    def ls_equals(self, value, *args):
40
40
        out, err = self.run_bzr('ls', *args)
41
41
        self.assertEqual('', err)
42
 
        self.assertEqual(value, out)
 
42
        self.assertEqualDiff(value, out)
43
43
 
44
44
    def test_ls_null_verbose(self):
45
45
        # Can't supply both
48
48
 
49
49
    def test_ls_basic(self):
50
50
        """Test the abilities of 'bzr ls'"""
51
 
        self.ls_equals('.bazaar\n.bzrignore\na\n')
52
 
        self.ls_equals('I        .bazaar/\n'
53
 
                       '?        .bzrignore\n'
 
51
        self.ls_equals('.bzrignore\na\n')
 
52
        self.ls_equals('?        .bzrignore\n'
54
53
                       '?        a\n',
55
54
                       '--verbose')
56
55
        self.ls_equals('.bzrignore\n'
57
56
                       'a\n',
58
57
                       '--unknown')
59
 
        self.ls_equals('.bazaar\n', '--ignored')
 
58
        self.ls_equals('', '--ignored')
60
59
        self.ls_equals('', '--versioned')
61
 
        self.ls_equals('.bazaar\n'
62
 
                       '.bzrignore\n'
 
60
        self.ls_equals('.bzrignore\n'
63
61
                       'a\n',
64
62
                       '--unknown', '--ignored', '--versioned')
65
 
        self.ls_equals('.bazaar\n', '--ignored', '--versioned')
66
 
        self.ls_equals('.bazaar\0.bzrignore\0a\0', '--null')
 
63
        self.ls_equals('', '--ignored', '--versioned')
 
64
        self.ls_equals('.bzrignore\0a\0', '--null')
67
65
 
68
66
    def test_ls_added(self):
69
67
        self.wt.add(['a'])
70
 
        self.ls_equals('I        .bazaar/\n'
71
 
                       '?        .bzrignore\n'
 
68
        self.ls_equals('?        .bzrignore\n'
72
69
                       'V        a\n',
73
70
                       '--verbose')
74
71
        self.wt.commit('add')
75
72
        
76
73
        self.build_tree(['subdir/'])
77
 
        self.ls_equals('I        .bazaar/\n'
78
 
                       '?        .bzrignore\n'
 
74
        self.ls_equals('?        .bzrignore\n'
79
75
                       'V        a\n'
80
76
                       '?        subdir/\n'
81
77
                       , '--verbose')
82
78
        self.build_tree(['subdir/b'])
83
79
        self.wt.add(['subdir/', 'subdir/b', '.bzrignore'])
84
 
        self.ls_equals('I        .bazaar/\n'
85
 
                       'V        .bzrignore\n'
 
80
        self.ls_equals('V        .bzrignore\n'
86
81
                       'V        a\n'
87
82
                       'V        subdir/\n'
88
83
                       'V        subdir/b\n'
89
84
                       , '--verbose')
90
85
 
 
86
    def test_show_ids(self):
 
87
        self.build_tree(['subdir/'])
 
88
        self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id'])
 
89
        self.ls_equals(
 
90
            '.bzrignore                                         \n'
 
91
            'a                                                  a-id\n'
 
92
            'subdir                                             subdir-id\n', 
 
93
            '--show-ids')
 
94
        self.ls_equals(
 
95
            '?        .bzrignore\n'
 
96
            'V        a                                         a-id\n'
 
97
            'V        subdir/                                   subdir-id\n', 
 
98
            '--show-ids', '--verbose')
 
99
        self.ls_equals('.bzrignore\0\0'
 
100
                       'a\0a-id\0'
 
101
                       'subdir\0subdir-id\0', '--show-ids', '--null')
 
102
 
91
103
    def test_ls_recursive(self):
92
104
        self.build_tree(['subdir/', 'subdir/b'])
93
105
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
94
106
 
95
 
        self.ls_equals('.bazaar\n'
96
 
                       '.bzrignore\n'
 
107
        self.ls_equals('.bzrignore\n'
97
108
                       'a\n'
98
109
                       'subdir\n'
99
110
                       , '--non-recursive')
100
111
 
101
 
        self.ls_equals('I        .bazaar/\n'
102
 
                       'V        .bzrignore\n'
 
112
        self.ls_equals('V        .bzrignore\n'
103
113
                       'V        a\n'
104
114
                       'V        subdir/\n'
105
115
                       , '--verbose', '--non-recursive')
109
119
        self.ls_equals('b\n')
110
120
        self.ls_equals('b\0'
111
121
                  , '--null')
112
 
        self.ls_equals('.bazaar\n'
113
 
                       '.bzrignore\n'
 
122
        self.ls_equals('.bzrignore\n'
114
123
                       'a\n'
115
124
                       'subdir\n'
116
125
                       'subdir/b\n'
117
126
                       , '--from-root')
118
 
        self.ls_equals('.bazaar\0'
119
 
                       '.bzrignore\0'
 
127
        self.ls_equals('.bzrignore\0'
120
128
                       'a\0'
121
129
                       'subdir\0'
122
130
                       'subdir/b\0'
123
131
                       , '--from-root', '--null')
124
 
        self.ls_equals('.bazaar\n'
125
 
                       '.bzrignore\n'
 
132
        self.ls_equals('.bzrignore\n'
126
133
                       'a\n'
127
134
                       'subdir\n'
128
135
                       , '--from-root', '--non-recursive')
129
136
 
 
137
    def test_ls_path(self):
 
138
        """If a path is specified, files are listed with that prefix"""
 
139
        self.build_tree(['subdir/', 'subdir/b'])
 
140
        self.wt.add(['subdir', 'subdir/b'])
 
141
        self.ls_equals('subdir/b\n' ,
 
142
                       'subdir')
 
143
        os.chdir('subdir')
 
144
        self.ls_equals('../.bzrignore\n'
 
145
                       '../a\n'
 
146
                       '../subdir\n'
 
147
                       '../subdir/b\n' ,
 
148
                       '..')
 
149
        self.ls_equals('../.bzrignore\0'
 
150
                       '../a\0'
 
151
                       '../subdir\0'
 
152
                       '../subdir/b\0' ,
 
153
                       '..', '--null')
 
154
        self.ls_equals('?        ../.bzrignore\n'
 
155
                       '?        ../a\n'
 
156
                       'V        ../subdir/\n'
 
157
                       'V        ../subdir/b\n' ,
 
158
                       '..', '--verbose')
 
159
        self.run_bzr_error('cannot specify both --from-root and PATH', 'ls',
 
160
                           '--from-root', '..')
 
161
 
130
162
    def test_ls_revision(self):
131
163
        self.wt.add(['a'])
132
164
        self.wt.commit('add')
141
173
        os.chdir('subdir')
142
174
        self.ls_equals('', '--revision', '1')
143
175
 
 
176
    def test_ls_branch(self):
 
177
        """If a branch is specified, files are listed from it"""
 
178
        self.build_tree(['subdir/', 'subdir/b'])
 
179
        self.wt.add(['subdir', 'subdir/b'])
 
180
        self.wt.commit('committing')
 
181
        branch = self.make_branch('branchdir')
 
182
        branch.pull(self.wt.branch)
 
183
        self.ls_equals('branchdir/subdir\n'
 
184
                       'branchdir/subdir/b\n',
 
185
                       'branchdir')
 
186
        self.ls_equals('branchdir/subdir\n'
 
187
                       'branchdir/subdir/b\n',
 
188
                       'branchdir', '--revision', '1')
 
189
 
144
190
    def test_ls_ignored(self):
145
191
        # Now try to do ignored files.
146
192
        self.wt.add(['a', '.bzrignore'])
147
193
 
148
194
        self.build_tree(['blah.py', 'blah.pyo', 'user-ignore'])
149
 
        self.ls_equals('.bazaar\n'
150
 
                       '.bzrignore\n'
 
195
        self.ls_equals('.bzrignore\n'
151
196
                       'a\n'
152
197
                       'blah.py\n'
153
198
                       'blah.pyo\n'
154
199
                       'user-ignore\n'
155
200
                       )
156
 
        self.ls_equals('I        .bazaar/\n'
157
 
                       'V        .bzrignore\n'
 
201
        self.ls_equals('V        .bzrignore\n'
158
202
                       'V        a\n'
159
203
                       '?        blah.py\n'
160
204
                       'I        blah.pyo\n'
161
205
                       'I        user-ignore\n'
162
206
                       , '--verbose')
163
 
        self.ls_equals('.bazaar\n'
164
 
                       'blah.pyo\n'
 
207
        self.ls_equals('blah.pyo\n'
165
208
                       'user-ignore\n'
166
209
                       , '--ignored')
167
210
        self.ls_equals('blah.py\n'
170
213
                       'a\n'
171
214
                       , '--versioned')
172
215
 
 
216
    def test_kinds(self):
 
217
        self.build_tree(['subdir/'])
 
218
        self.ls_equals('.bzrignore\n' 
 
219
                       'a\n', 
 
220
                       '--kind=file')
 
221
        self.ls_equals('subdir\n',
 
222
                       '--kind=directory')
 
223
        self.ls_equals('',
 
224
                       '--kind=symlink')
 
225
        self.run_bzr_error('invalid kind specified', 'ls', '--kind=pile')