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'
63
self.ls_equals('.bzrignore\n'
64
'--unknown', '--ignored', '--versioned')
65
self.ls_equals('.bazaar\n', '--ignored', '--versioned')
66
self.ls_equals('.bazaar\0.bzrignore\0a\0', '--null')
65
'--unknown --ignored --versioned')
66
self.ls_equals('', '--ignored --versioned')
67
self.ls_equals('.bzrignore\0a\0', '--null')
68
69
def test_ls_added(self):
70
self.ls_equals('I .bazaar/\n'
71
self.ls_equals('? .bzrignore\n'
74
74
self.wt.commit('add')
76
76
self.build_tree(['subdir/'])
77
self.ls_equals('I .bazaar/\n'
77
self.ls_equals('? .bzrignore\n'
82
81
self.build_tree(['subdir/b'])
83
82
self.wt.add(['subdir/', 'subdir/b', '.bzrignore'])
84
self.ls_equals('I .bazaar/\n'
83
self.ls_equals('V .bzrignore\n'
89
def test_show_ids(self):
90
self.build_tree(['subdir/'])
91
self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id'])
100
'V subdir/ subdir-id\n',
101
'--show-ids --verbose')
102
self.ls_equals('.bzrignore\0\0'
104
'subdir\0subdir-id\0', '--show-ids --null')
91
106
def test_ls_recursive(self):
92
107
self.build_tree(['subdir/', 'subdir/b'])
93
108
self.wt.add(['a', 'subdir/', 'subdir/b', '.bzrignore'])
95
self.ls_equals('.bazaar\n'
110
self.ls_equals('.bzrignore\n'
99
113
, '--non-recursive')
101
self.ls_equals('I .bazaar/\n'
115
self.ls_equals('V .bzrignore\n'
105
, '--verbose', '--non-recursive')
118
, '--verbose --non-recursive')
107
120
# Check what happens in a sub-directory
108
121
os.chdir('subdir')
109
122
self.ls_equals('b\n')
110
123
self.ls_equals('b\0'
112
self.ls_equals('.bazaar\n'
125
self.ls_equals('.bzrignore\n'
118
self.ls_equals('.bazaar\0'
130
self.ls_equals('.bzrignore\0'
123
, '--from-root', '--null')
124
self.ls_equals('.bazaar\n'
134
, '--from-root --null')
135
self.ls_equals('.bzrignore\n'
128
, '--from-root', '--non-recursive')
138
, '--from-root --non-recursive')
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',
130
165
def test_ls_revision(self):
131
166
self.wt.add(['a'])
134
169
self.build_tree(['subdir/'])
136
171
# Check what happens when we supply a specific revision
137
self.ls_equals('a\n', '--revision', '1')
172
self.ls_equals('a\n', '--revision 1')
138
173
self.ls_equals('V a\n'
139
, '--verbose', '--revision', '1')
174
, '--verbose --revision 1')
141
176
os.chdir('subdir')
142
self.ls_equals('', '--revision', '1')
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')
144
193
def test_ls_ignored(self):
145
194
# Now try to do ignored files.
146
195
self.wt.add(['a', '.bzrignore'])
148
197
self.build_tree(['blah.py', 'blah.pyo', 'user-ignore'])
149
self.ls_equals('.bazaar\n'
198
self.ls_equals('.bzrignore\n'
156
self.ls_equals('I .bazaar/\n'
204
self.ls_equals('V .bzrignore\n'
161
208
'I user-ignore\n'
163
self.ls_equals('.bazaar\n'
210
self.ls_equals('blah.pyo\n'
167
213
self.ls_equals('blah.py\n'