~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: 2009-04-27 08:50:49 UTC
  • mto: (4426.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4427.
  • Revision ID: bialix@ukr.net-20090427085049-w1033mm50oi2luql
using_bazaar_with_launchpad.txt: translated text copy-pasted from notabenoid site.  

TODO: need to reformat and fix errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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):
40
 
        out, err = self.run_bzr('ls', *args)
 
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)
41
46
        self.assertEqual('', err)
42
 
        self.assertEqual(value, out)
 
47
        self.assertEqualDiff(value, out)
43
48
 
44
49
    def test_ls_null_verbose(self):
45
50
        # Can't supply both
46
51
        self.run_bzr_error(['Cannot set both --verbose and --null'],
47
 
                           'ls', '--verbose', '--null')
 
52
                           'ls --verbose --null')
48
53
 
49
54
    def test_ls_basic(self):
50
55
        """Test the abilities of 'bzr ls'"""
57
62
                       '--unknown')
58
63
        self.ls_equals('', '--ignored')
59
64
        self.ls_equals('', '--versioned')
60
 
        self.ls_equals('.bzrignore\n'
61
 
                       'a\n',
62
 
                       '--unknown', '--ignored', '--versioned')
63
 
        self.ls_equals('', '--ignored', '--versioned')
 
65
        self.ls_equals('', '-V')
 
66
        self.ls_equals('.bzrignore\n'
 
67
                       'a\n',
 
68
                       '--unknown --ignored --versioned')
 
69
        self.ls_equals('.bzrignore\n'
 
70
                       'a\n',
 
71
                       '--unknown --ignored -V')
 
72
        self.ls_equals('', '--ignored --versioned')
 
73
        self.ls_equals('', '--ignored -V')
64
74
        self.ls_equals('.bzrignore\0a\0', '--null')
65
75
 
66
76
    def test_ls_added(self):
69
79
                       'V        a\n',
70
80
                       '--verbose')
71
81
        self.wt.commit('add')
72
 
        
 
82
 
73
83
        self.build_tree(['subdir/'])
74
84
        self.ls_equals('?        .bzrignore\n'
75
85
                       'V        a\n'
83
93
                       'V        subdir/b\n'
84
94
                       , '--verbose')
85
95
 
86
 
    def test_ls_recursive(self):
 
96
    def test_show_ids(self):
 
97
        self.build_tree(['subdir/'])
 
98
        self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id'])
 
99
        self.ls_equals(
 
100
            '.bzrignore                                         \n'
 
101
            'a                                                  a-id\n'
 
102
            'subdir/                                            subdir-id\n',
 
103
            '--show-ids')
 
104
        self.ls_equals(
 
105
            '?        .bzrignore\n'
 
106
            'V        a                                         a-id\n'
 
107
            'V        subdir/                                   subdir-id\n',
 
108
            '--show-ids --verbose')
 
109
        self.ls_equals('.bzrignore\0\0'
 
110
                       'a\0a-id\0'
 
111
                       'subdir\0subdir-id\0', '--show-ids --null')
 
112
 
 
113
    def test_ls_no_recursive(self):
87
114
        self.build_tree(['subdir/', 'subdir/b'])
88
115
        self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
89
116
 
90
117
        self.ls_equals('.bzrignore\n'
91
118
                       'a\n'
92
 
                       'subdir\n'
93
 
                       , '--non-recursive')
 
119
                       'subdir/\n'
 
120
                       , recursive=False)
94
121
 
95
122
        self.ls_equals('V        .bzrignore\n'
96
123
                       'V        a\n'
97
124
                       'V        subdir/\n'
98
 
                       , '--verbose', '--non-recursive')
 
125
                       , '--verbose', recursive=False)
99
126
 
100
127
        # Check what happens in a sub-directory
101
128
        os.chdir('subdir')
104
131
                  , '--null')
105
132
        self.ls_equals('.bzrignore\n'
106
133
                       'a\n'
107
 
                       'subdir\n'
 
134
                       'subdir/\n'
108
135
                       'subdir/b\n'
109
136
                       , '--from-root')
110
137
        self.ls_equals('.bzrignore\0'
111
138
                       'a\0'
112
139
                       'subdir\0'
113
140
                       'subdir/b\0'
114
 
                       , '--from-root', '--null')
 
141
                       , '--from-root --null')
115
142
        self.ls_equals('.bzrignore\n'
116
143
                       'a\n'
117
 
                       'subdir\n'
118
 
                       , '--from-root', '--non-recursive')
 
144
                       'subdir/\n'
 
145
                       , '--from-root', recursive=False)
 
146
 
 
147
    def test_ls_path(self):
 
148
        """If a path is specified, files are listed with that prefix"""
 
149
        self.build_tree(['subdir/', 'subdir/b'])
 
150
        self.wt.add(['subdir', 'subdir/b'])
 
151
        self.ls_equals('subdir/b\n' ,
 
152
                       'subdir')
 
153
        os.chdir('subdir')
 
154
        self.ls_equals('../.bzrignore\n'
 
155
                       '../a\n'
 
156
                       '../subdir/\n'
 
157
                       '../subdir/b\n' ,
 
158
                       '..')
 
159
        self.ls_equals('../.bzrignore\0'
 
160
                       '../a\0'
 
161
                       '../subdir\0'
 
162
                       '../subdir/b\0' ,
 
163
                       '.. --null')
 
164
        self.ls_equals('?        ../.bzrignore\n'
 
165
                       '?        ../a\n'
 
166
                       'V        ../subdir/\n'
 
167
                       'V        ../subdir/b\n' ,
 
168
                       '.. --verbose')
 
169
        self.run_bzr_error('cannot specify both --from-root and PATH',
 
170
                           'ls --from-root ..')
119
171
 
120
172
    def test_ls_revision(self):
121
173
        self.wt.add(['a'])
124
176
        self.build_tree(['subdir/'])
125
177
 
126
178
        # Check what happens when we supply a specific revision
127
 
        self.ls_equals('a\n', '--revision', '1')
 
179
        self.ls_equals('a\n', '--revision 1')
128
180
        self.ls_equals('V        a\n'
129
 
                       , '--verbose', '--revision', '1')
 
181
                       , '--verbose --revision 1')
130
182
 
131
183
        os.chdir('subdir')
132
 
        self.ls_equals('', '--revision', '1')
 
184
        self.ls_equals('', '--revision 1')
 
185
 
 
186
    def test_ls_branch(self):
 
187
        """If a branch is specified, files are listed from it"""
 
188
        self.build_tree(['subdir/', 'subdir/b'])
 
189
        self.wt.add(['subdir', 'subdir/b'])
 
190
        self.wt.commit('committing')
 
191
        branch = self.make_branch('branchdir')
 
192
        branch.pull(self.wt.branch)
 
193
        self.ls_equals('branchdir/subdir/\n'
 
194
                       'branchdir/subdir/b\n',
 
195
                       'branchdir')
 
196
        self.ls_equals('branchdir/subdir/\n'
 
197
                       'branchdir/subdir/b\n',
 
198
                       'branchdir --revision 1')
133
199
 
134
200
    def test_ls_ignored(self):
135
201
        # Now try to do ignored files.
156
222
        self.ls_equals('.bzrignore\n'
157
223
                       'a\n'
158
224
                       , '--versioned')
159
 
 
 
225
        self.ls_equals('.bzrignore\n'
 
226
                       'a\n'
 
227
                       , '-V')
 
228
 
 
229
    def test_kinds(self):
 
230
        self.build_tree(['subdir/'])
 
231
        self.ls_equals('.bzrignore\n'
 
232
                       'a\n',
 
233
                       '--kind=file')
 
234
        self.ls_equals('subdir/\n',
 
235
                       '--kind=directory')
 
236
        self.ls_equals('',
 
237
                       '--kind=symlink')
 
238
        self.run_bzr_error('invalid kind specified', 'ls --kind=pile')
 
239
 
 
240
    def test_ls_path_nonrecursive(self):
 
241
        self.ls_equals('%s/.bzrignore\n'
 
242
                       '%s/a\n'
 
243
                       % (self.test_dir, self.test_dir),
 
244
                       self.test_dir, recursive=False)