39
def ls_equals(self, value, *args):
40
out, err = self.run_bzr('ls', *args)
39
def ls_equals(self, value, args=None):
43
out, err = self.run_bzr(command)
41
44
self.assertEqual('', err)
42
self.assertEqual(value, out)
45
self.assertEqualDiff(value, out)
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')
49
52
def test_ls_basic(self):
50
53
"""Test the abilities of 'bzr ls'"""
51
self.ls_equals('.bazaar\n.bzrignore\na\n')
52
self.ls_equals('I .bazaar/\n'
54
self.ls_equals('.bzrignore\na\n')
55
self.ls_equals('? .bzrignore\n'
56
58
self.ls_equals('.bzrignore\n'
59
self.ls_equals('.bazaar\n', '--ignored')
61
self.ls_equals('', '--ignored')
60
62
self.ls_equals('', '--versioned')
61
self.ls_equals('.bazaar\n'
64
'--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('', '-V')
64
self.ls_equals('.bzrignore\n'
66
'--unknown --ignored --versioned')
67
self.ls_equals('.bzrignore\n'
69
'--unknown --ignored -V')
70
self.ls_equals('', '--ignored --versioned')
71
self.ls_equals('', '--ignored -V')
72
self.ls_equals('.bzrignore\0a\0', '--null')
68
74
def test_ls_added(self):
70
self.ls_equals('I .bazaar/\n'
76
self.ls_equals('? .bzrignore\n'
74
79
self.wt.commit('add')
76
81
self.build_tree(['subdir/'])
77
self.ls_equals('I .bazaar/\n'
82
self.ls_equals('? .bzrignore\n'
82
86
self.build_tree(['subdir/b'])
83
87
self.wt.add(['subdir/', 'subdir/b', '.bzrignore'])
84
self.ls_equals('I .bazaar/\n'
88
self.ls_equals('V .bzrignore\n'
94
def test_show_ids(self):
95
self.build_tree(['subdir/'])
96
self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id'])
100
'subdir/ subdir-id\n',
105
'V subdir/ subdir-id\n',
106
'--show-ids --verbose')
107
self.ls_equals('.bzrignore\0\0'
109
'subdir\0subdir-id\0', '--show-ids --null')
91
111
def test_ls_recursive(self):
92
112
self.build_tree(['subdir/', 'subdir/b'])
93
113
self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
95
self.ls_equals('.bazaar\n'
115
self.ls_equals('.bzrignore\n'
99
118
, '--non-recursive')
101
self.ls_equals('I .bazaar/\n'
120
self.ls_equals('V .bzrignore\n'
105
, '--verbose', '--non-recursive')
123
, '--verbose --non-recursive')
107
125
# Check what happens in a sub-directory
108
126
os.chdir('subdir')
109
127
self.ls_equals('b\n')
110
128
self.ls_equals('b\0'
112
self.ls_equals('.bazaar\n'
130
self.ls_equals('.bzrignore\n'
118
self.ls_equals('.bazaar\0'
135
self.ls_equals('.bzrignore\0'
123
, '--from-root', '--null')
124
self.ls_equals('.bazaar\n'
139
, '--from-root --null')
140
self.ls_equals('.bzrignore\n'
128
, '--from-root', '--non-recursive')
143
, '--from-root --non-recursive')
145
def test_ls_path(self):
146
"""If a path is specified, files are listed with that prefix"""
147
self.build_tree(['subdir/', 'subdir/b'])
148
self.wt.add(['subdir', 'subdir/b'])
149
self.ls_equals('subdir/b\n' ,
152
self.ls_equals('../.bzrignore\n'
157
self.ls_equals('../.bzrignore\0'
162
self.ls_equals('? ../.bzrignore\n'
167
self.run_bzr_error('cannot specify both --from-root and PATH',
130
170
def test_ls_revision(self):
131
171
self.wt.add(['a'])
134
174
self.build_tree(['subdir/'])
136
176
# Check what happens when we supply a specific revision
137
self.ls_equals('a\n', '--revision', '1')
177
self.ls_equals('a\n', '--revision 1')
138
178
self.ls_equals('V a\n'
139
, '--verbose', '--revision', '1')
179
, '--verbose --revision 1')
141
181
os.chdir('subdir')
142
self.ls_equals('', '--revision', '1')
182
self.ls_equals('', '--revision 1')
184
def test_ls_branch(self):
185
"""If a branch is specified, files are listed from it"""
186
self.build_tree(['subdir/', 'subdir/b'])
187
self.wt.add(['subdir', 'subdir/b'])
188
self.wt.commit('committing')
189
branch = self.make_branch('branchdir')
190
branch.pull(self.wt.branch)
191
self.ls_equals('branchdir/subdir/\n'
192
'branchdir/subdir/b\n',
194
self.ls_equals('branchdir/subdir/\n'
195
'branchdir/subdir/b\n',
196
'branchdir --revision 1')
144
198
def test_ls_ignored(self):
145
199
# Now try to do ignored files.
146
200
self.wt.add(['a', '.bzrignore'])
148
202
self.build_tree(['blah.py', 'blah.pyo', 'user-ignore'])
149
self.ls_equals('.bazaar\n'
203
self.ls_equals('.bzrignore\n'
156
self.ls_equals('I .bazaar/\n'
209
self.ls_equals('V .bzrignore\n'
161
213
'I user-ignore\n'
163
self.ls_equals('.bazaar\n'
215
self.ls_equals('blah.pyo\n'
167
218
self.ls_equals('blah.py\n'