39
def ls_equals(self, value, args=None, recursive=True):
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
self.assertEqualDiff(value, out)
42
self.assertEqual(value, out)
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')
54
49
def test_ls_basic(self):
55
50
"""Test the abilities of 'bzr ls'"""
56
self.ls_equals('.bzrignore\na\n')
57
self.ls_equals('.bzrignore\na\n', './')
58
self.ls_equals('? .bzrignore\n'
51
self.ls_equals('.bazaar\n.bzrignore\na\n')
52
self.ls_equals('I .bazaar/\n'
61
56
self.ls_equals('.bzrignore\n'
64
self.ls_equals('', '--ignored')
59
self.ls_equals('.bazaar\n', '--ignored')
65
60
self.ls_equals('', '--versioned')
66
self.ls_equals('', '-V')
67
self.ls_equals('.bzrignore\n'
69
'--unknown --ignored --versioned')
70
self.ls_equals('.bzrignore\n'
72
'--unknown --ignored -V')
73
self.ls_equals('', '--ignored --versioned')
74
self.ls_equals('', '--ignored -V')
75
self.ls_equals('.bzrignore\0a\0', '--null')
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')
77
68
def test_ls_added(self):
79
self.ls_equals('? .bzrignore\n'
70
self.ls_equals('I .bazaar/\n'
82
74
self.wt.commit('add')
84
76
self.build_tree(['subdir/'])
85
self.ls_equals('? .bzrignore\n'
77
self.ls_equals('I .bazaar/\n'
89
82
self.build_tree(['subdir/b'])
90
83
self.wt.add(['subdir/', 'subdir/b', '.bzrignore'])
91
self.ls_equals('V .bzrignore\n'
84
self.ls_equals('I .bazaar/\n'
97
def test_show_ids(self):
98
self.build_tree(['subdir/'])
99
self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id'])
103
'subdir/ subdir-id\n',
108
'V subdir/ subdir-id\n',
109
'--show-ids --verbose')
110
self.ls_equals('.bzrignore\0\0'
112
'subdir\0subdir-id\0', '--show-ids --null')
114
def test_ls_no_recursive(self):
91
def test_ls_recursive(self):
115
92
self.build_tree(['subdir/', 'subdir/b'])
116
93
self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
118
self.ls_equals('.bzrignore\n'
95
self.ls_equals('.bazaar\n'
123
self.ls_equals('V .bzrignore\n'
101
self.ls_equals('I .bazaar/\n'
126
, '--verbose', recursive=False)
105
, '--verbose', '--non-recursive')
128
107
# Check what happens in a sub-directory
129
108
os.chdir('subdir')
130
109
self.ls_equals('b\n')
131
110
self.ls_equals('b\0'
133
self.ls_equals('subdir/b\n'
112
self.ls_equals('.bazaar\n'
135
self.ls_equals('subdir/b\0'
136
, '--from-root --null')
137
self.ls_equals('subdir/b\n'
138
, '--from-root', recursive=False)
140
def test_ls_path(self):
141
"""If a path is specified, files are listed with that prefix"""
142
self.build_tree(['subdir/', 'subdir/b'])
143
self.wt.add(['subdir', 'subdir/b'])
144
self.ls_equals('subdir/b\n' ,
147
self.ls_equals('../.bzrignore\n'
152
self.ls_equals('../.bzrignore\0'
157
self.ls_equals('? ../.bzrignore\n'
162
self.run_bzr_error(['cannot specify both --from-root and PATH'],
118
self.ls_equals('.bazaar\0'
123
, '--from-root', '--null')
124
self.ls_equals('.bazaar\n'
128
, '--from-root', '--non-recursive')
165
130
def test_ls_revision(self):
166
131
self.wt.add(['a'])
169
134
self.build_tree(['subdir/'])
171
136
# Check what happens when we supply a specific revision
172
self.ls_equals('a\n', '--revision 1')
137
self.ls_equals('a\n', '--revision', '1')
173
138
self.ls_equals('V a\n'
174
, '--verbose --revision 1')
139
, '--verbose', '--revision', '1')
176
141
os.chdir('subdir')
177
self.ls_equals('', '--revision 1')
179
def test_ls_branch(self):
180
"""If a branch is specified, files are listed from it"""
181
self.build_tree(['subdir/', 'subdir/b'])
182
self.wt.add(['subdir', 'subdir/b'])
183
self.wt.commit('committing')
184
branch = self.make_branch('branchdir')
185
branch.pull(self.wt.branch)
186
self.ls_equals('branchdir/subdir/\n'
187
'branchdir/subdir/b\n',
189
self.ls_equals('branchdir/subdir/\n'
190
'branchdir/subdir/b\n',
191
'branchdir --revision 1')
142
self.ls_equals('', '--revision', '1')
193
144
def test_ls_ignored(self):
194
145
# Now try to do ignored files.
195
146
self.wt.add(['a', '.bzrignore'])
197
148
self.build_tree(['blah.py', 'blah.pyo', 'user-ignore'])
198
self.ls_equals('.bzrignore\n'
149
self.ls_equals('.bazaar\n'
204
self.ls_equals('V .bzrignore\n'
156
self.ls_equals('I .bazaar/\n'
208
161
'I user-ignore\n'
210
self.ls_equals('blah.pyo\n'
163
self.ls_equals('.bazaar\n'
213
167
self.ls_equals('blah.py\n'