28
28
super(TestLS, self).setUp()
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'])
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)
44
44
def test_ls_null_verbose(self):
45
45
# Can't supply both
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'
51
self.ls_equals('.bzrignore\na\n')
52
self.ls_equals('? .bzrignore\n'
56
55
self.ls_equals('.bzrignore\n'
59
self.ls_equals('.bazaar\n', '--ignored')
58
self.ls_equals('', '--ignored')
60
59
self.ls_equals('', '--versioned')
61
self.ls_equals('.bazaar\n'
60
self.ls_equals('.bzrignore\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')
68
66
def test_ls_added(self):
70
self.ls_equals('I .bazaar/\n'
68
self.ls_equals('? .bzrignore\n'
74
71
self.wt.commit('add')
76
73
self.build_tree(['subdir/'])
77
self.ls_equals('I .bazaar/\n'
74
self.ls_equals('? .bzrignore\n'
82
78
self.build_tree(['subdir/b'])
83
79
self.wt.add(['subdir/', 'subdir/b', '.bzrignore'])
84
self.ls_equals('I .bazaar/\n'
80
self.ls_equals('V .bzrignore\n'
86
def test_show_ids(self):
87
self.build_tree(['subdir/'])
88
self.wt.add(['a', 'subdir'], ['a-id', 'subdir-id'])
97
'V subdir/ subdir-id\n',
98
'--show-ids', '--verbose')
99
self.ls_equals('.bzrignore\0\0'
101
'subdir\0subdir-id\0', '--show-ids', '--null')
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'])
95
self.ls_equals('.bazaar\n'
107
self.ls_equals('.bzrignore\n'
99
110
, '--non-recursive')
101
self.ls_equals('I .bazaar/\n'
112
self.ls_equals('V .bzrignore\n'
105
115
, '--verbose', '--non-recursive')
109
119
self.ls_equals('b\n')
110
120
self.ls_equals('b\0'
112
self.ls_equals('.bazaar\n'
122
self.ls_equals('.bzrignore\n'
118
self.ls_equals('.bazaar\0'
127
self.ls_equals('.bzrignore\0'
123
131
, '--from-root', '--null')
124
self.ls_equals('.bazaar\n'
132
self.ls_equals('.bzrignore\n'
128
135
, '--from-root', '--non-recursive')
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' ,
144
self.ls_equals('../.bzrignore\n'
149
self.ls_equals('../.bzrignore\0'
154
self.ls_equals('? ../.bzrignore\n'
159
self.run_bzr_error('cannot specify both --from-root and PATH', 'ls',
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')
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',
186
self.ls_equals('branchdir/subdir\n'
187
'branchdir/subdir/b\n',
188
'branchdir', '--revision', '1')
144
190
def test_ls_ignored(self):
145
191
# Now try to do ignored files.
146
192
self.wt.add(['a', '.bzrignore'])
148
194
self.build_tree(['blah.py', 'blah.pyo', 'user-ignore'])
149
self.ls_equals('.bazaar\n'
195
self.ls_equals('.bzrignore\n'
156
self.ls_equals('I .bazaar/\n'
201
self.ls_equals('V .bzrignore\n'
161
205
'I user-ignore\n'
163
self.ls_equals('.bazaar\n'
207
self.ls_equals('blah.pyo\n'
167
210
self.ls_equals('blah.py\n'