~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

first cut at merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# (C) 2005 Canonical Ltd
2
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
20
20
 
21
21
import bzrlib
22
22
from bzrlib.branch import Branch
23
 
import bzrlib.bzrdir as bzrdir
24
 
from bzrlib.bzrdir import BzrDir
25
 
from bzrlib.conflicts import *
26
 
import bzrlib.errors as errors
27
23
from bzrlib.errors import NotBranchError, NotVersionedError
28
 
from bzrlib.lockdir import LockDir
 
24
from bzrlib.tests import TestCaseWithTransport
 
25
from bzrlib.trace import mutter
29
26
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
30
 
from bzrlib.tests import TestCaseWithTransport, TestSkipped
31
 
from bzrlib.trace import mutter
32
 
from bzrlib.transport import get_transport
33
 
import bzrlib.workingtree as workingtree
34
27
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
35
28
                                WorkingTree)
36
29
 
58
51
        self.assertEqual(TreeLink().kind_character(), '')
59
52
 
60
53
 
61
 
class TestDefaultFormat(TestCaseWithTransport):
62
 
 
63
 
    def test_get_set_default_format(self):
64
 
        old_format = workingtree.WorkingTreeFormat.get_default_format()
65
 
        # default is 3
66
 
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
67
 
        workingtree.WorkingTreeFormat.set_default_format(SampleTreeFormat())
68
 
        try:
69
 
            # the default branch format is used by the meta dir format
70
 
            # which is not the default bzrdir format at this point
71
 
            dir = bzrdir.BzrDirMetaFormat1().initialize('.')
72
 
            dir.create_repository()
73
 
            dir.create_branch()
74
 
            result = dir.create_workingtree()
75
 
            self.assertEqual(result, 'A tree')
76
 
        finally:
77
 
            workingtree.WorkingTreeFormat.set_default_format(old_format)
78
 
        self.assertEqual(old_format, workingtree.WorkingTreeFormat.get_default_format())
79
 
 
80
 
 
81
 
class SampleTreeFormat(workingtree.WorkingTreeFormat):
82
 
    """A sample format
83
 
 
84
 
    this format is initializable, unsupported to aid in testing the 
85
 
    open and open_downlevel routines.
86
 
    """
87
 
 
88
 
    def get_format_string(self):
89
 
        """See WorkingTreeFormat.get_format_string()."""
90
 
        return "Sample tree format."
91
 
 
92
 
    def initialize(self, a_bzrdir, revision_id=None):
93
 
        """Sample branches cannot be created."""
94
 
        t = a_bzrdir.get_workingtree_transport(self)
95
 
        t.put('format', StringIO(self.get_format_string()))
96
 
        return 'A tree'
97
 
 
98
 
    def is_supported(self):
99
 
        return False
100
 
 
101
 
    def open(self, transport, _found=False):
102
 
        return "opened tree."
103
 
 
104
 
 
105
 
class TestWorkingTreeFormat(TestCaseWithTransport):
106
 
    """Tests for the WorkingTreeFormat facility."""
107
 
 
108
 
    def test_find_format(self):
109
 
        # is the right format object found for a working tree?
110
 
        # create a branch with a few known format objects.
111
 
        self.build_tree(["foo/", "bar/"])
112
 
        def check_format(format, url):
113
 
            dir = format._matchingbzrdir.initialize(url)
114
 
            dir.create_repository()
115
 
            dir.create_branch()
116
 
            format.initialize(dir)
117
 
            t = get_transport(url)
118
 
            found_format = workingtree.WorkingTreeFormat.find_format(dir)
119
 
            self.failUnless(isinstance(found_format, format.__class__))
120
 
        check_format(workingtree.WorkingTreeFormat3(), "bar")
 
54
class TestWorkingTree(TestCaseWithTransport):
 
55
 
 
56
    def test_listfiles(self):
 
57
        tree = WorkingTree.create_standalone('.')
 
58
        os.mkdir('dir')
 
59
        print >> open('file', 'w'), "content"
 
60
        if has_symlinks():
 
61
            os.symlink('target', 'symlink')
 
62
        files = list(tree.list_files())
 
63
        self.assertEqual(files[0], ('dir', '?', 'directory', None, TreeDirectory()))
 
64
        self.assertEqual(files[1], ('file', '?', 'file', None, TreeFile()))
 
65
        if has_symlinks():
 
66
            self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink()))
 
67
 
 
68
    def test_open_containing(self):
 
69
        branch = WorkingTree.create_standalone('.').branch
 
70
        wt, relpath = WorkingTree.open_containing()
 
71
        self.assertEqual('', relpath)
 
72
        self.assertEqual(wt.basedir + '/', branch.base)
 
73
        wt, relpath = WorkingTree.open_containing(u'.')
 
74
        self.assertEqual('', relpath)
 
75
        self.assertEqual(wt.basedir + '/', branch.base)
 
76
        wt, relpath = WorkingTree.open_containing('./foo')
 
77
        self.assertEqual('foo', relpath)
 
78
        self.assertEqual(wt.basedir + '/', branch.base)
 
79
        # paths that are urls are just plain wrong for working trees.
 
80
        self.assertRaises(NotBranchError,
 
81
                          WorkingTree.open_containing, 
 
82
                          'file:///' + getcwd())
 
83
 
 
84
    def test_construct_with_branch(self):
 
85
        branch = WorkingTree.create_standalone('.').branch
 
86
        tree = WorkingTree(branch.base, branch)
 
87
        self.assertEqual(branch, tree.branch)
 
88
        self.assertEqual(branch.base, tree.basedir + '/')
 
89
    
 
90
    def test_construct_without_branch(self):
 
91
        branch = WorkingTree.create_standalone('.').branch
 
92
        tree = WorkingTree(branch.base)
 
93
        self.assertEqual(branch.base, tree.branch.base)
 
94
        self.assertEqual(branch.base, tree.basedir + '/')
 
95
 
 
96
    def test_basic_relpath(self):
 
97
        # for comprehensive relpath tests, see whitebox.py.
 
98
        tree = WorkingTree.create_standalone('.')
 
99
        self.assertEqual('child',
 
100
                         tree.relpath(pathjoin(getcwd(), 'child')))
 
101
 
 
102
    def test_lock_locks_branch(self):
 
103
        tree = WorkingTree.create_standalone('.')
 
104
        tree.lock_read()
 
105
        self.assertEqual('r', tree.branch.peek_lock_mode())
 
106
        tree.unlock()
 
107
        self.assertEqual(None, tree.branch.peek_lock_mode())
 
108
        tree.lock_write()
 
109
        self.assertEqual('w', tree.branch.peek_lock_mode())
 
110
        tree.unlock()
 
111
        self.assertEqual(None, tree.branch.peek_lock_mode())
 
112
 
 
113
    def get_pullable_trees(self):
 
114
        self.build_tree(['from/', 'from/file', 'to/'])
 
115
        tree = WorkingTree.create_standalone('from')
 
116
        tree.add('file')
 
117
        tree.commit('foo', rev_id='A')
 
118
        tree_b = WorkingTree.create_standalone('to')
 
119
        return tree, tree_b
 
120
 
 
121
    def test_pull(self):
 
122
        tree_a, tree_b = self.get_pullable_trees()
 
123
        tree_b.pull(tree_a.branch)
 
124
        self.failUnless(tree_b.branch.repository.has_revision('A'))
 
125
        self.assertEqual(['A'], tree_b.branch.revision_history())
 
126
 
 
127
    def test_pull_overwrites(self):
 
128
        tree_a, tree_b = self.get_pullable_trees()
 
129
        tree_b.commit('foo', rev_id='B')
 
130
        self.assertEqual(['B'], tree_b.branch.revision_history())
 
131
        tree_b.pull(tree_a.branch, overwrite=True)
 
132
        self.failUnless(tree_b.branch.repository.has_revision('A'))
 
133
        self.failUnless(tree_b.branch.repository.has_revision('B'))
 
134
        self.assertEqual(['A'], tree_b.branch.revision_history())
 
135
 
 
136
    def test_revert(self):
 
137
        """Test selected-file revert"""
 
138
        tree = WorkingTree.create_standalone('.')
 
139
 
 
140
        self.build_tree(['hello.txt'])
 
141
        file('hello.txt', 'w').write('initial hello')
 
142
 
 
143
        self.assertRaises(NotVersionedError,
 
144
                          tree.revert, ['hello.txt'])
 
145
        tree.add(['hello.txt'])
 
146
        tree.commit('create initial hello.txt')
 
147
 
 
148
        self.check_file_contents('hello.txt', 'initial hello')
 
149
        file('hello.txt', 'w').write('new hello')
 
150
        self.check_file_contents('hello.txt', 'new hello')
 
151
 
 
152
        # revert file modified since last revision
 
153
        tree.revert(['hello.txt'])
 
154
        self.check_file_contents('hello.txt', 'initial hello')
 
155
        self.check_file_contents('hello.txt~', 'new hello')
 
156
 
 
157
        # reverting again does not clobber the backup
 
158
        tree.revert(['hello.txt'])
 
159
        self.check_file_contents('hello.txt', 'initial hello')
 
160
        self.check_file_contents('hello.txt~', 'new hello')
 
161
 
 
162
    def test_unknowns(self):
 
163
        tree = WorkingTree.create_standalone('.')
 
164
        self.build_tree(['hello.txt',
 
165
                         'hello.txt~'])
 
166
        self.assertEquals(list(tree.unknowns()),
 
167
                          ['hello.txt'])
 
168
 
 
169
    def test_hashcache(self):
 
170
        from bzrlib.tests.test_hashcache import pause
 
171
        tree = WorkingTree.create_standalone('.')
 
172
        self.build_tree(['hello.txt',
 
173
                         'hello.txt~'])
 
174
        tree.add('hello.txt')
 
175
        pause()
 
176
        sha = tree.get_file_sha1(tree.path2id('hello.txt'))
 
177
        self.assertEqual(1, tree._hashcache.miss_count)
 
178
        tree2 = WorkingTree('.', tree.branch)
 
179
        sha2 = tree2.get_file_sha1(tree2.path2id('hello.txt'))
 
180
        self.assertEqual(0, tree2._hashcache.miss_count)
 
181
        self.assertEqual(1, tree2._hashcache.hit_count)
 
182
 
 
183
    def test_checkout(self):
 
184
        # at this point as we dont have checkout versions, checkout simply
 
185
        # populates the required files for a working tree at the dir.
 
186
        self.build_tree(['branch/'])
 
187
        b = Branch.create('branch')
 
188
        t = WorkingTree.create(b, 'tree')
 
189
        # as we are moving the ownership to working tree, we will check here
 
190
        # that its split out correctly
 
191
        self.failIfExists('branch/.bzr/inventory')
 
192
        self.failIfExists('branch/.bzr/pending-merges')
 
193
        sio = StringIO()
 
194
        bzrlib.xml5.serializer_v5.write_inventory(bzrlib.inventory.Inventory(),
 
195
                                                  sio)
 
196
        self.assertFileEqual(sio.getvalue(), 'tree/.bzr/inventory')
 
197
        self.assertFileEqual('', 'tree/.bzr/pending-merges')
 
198
 
 
199
    def test_initialize(self):
 
200
        # initialize should create a working tree and branch in an existing dir
 
201
        t = WorkingTree.create_standalone('.')
 
202
        b = Branch.open('.')
 
203
        self.assertEqual(t.branch.base, b.base)
 
204
        t2 = WorkingTree('.')
 
205
        self.assertEqual(t.basedir, t2.basedir)
 
206
        self.assertEqual(b.base, t2.branch.base)
 
207
        # TODO maybe we should check the branch format? not sure if its
 
208
        # appropriate here.
 
209
 
 
210
    def test_rename_dirs(self):
 
211
        """Test renaming directories and the files within them."""
 
212
        wt = self.make_branch_and_tree('.')
 
213
        b = wt.branch
 
214
        self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])
 
215
        wt.add(['dir', 'dir/sub', 'dir/sub/file'])
 
216
 
 
217
        wt.commit('create initial state')
 
218
 
 
219
        revid = b.revision_history()[0]
 
220
        self.log('first revision_id is {%s}' % revid)
121
221
        
122
 
    def test_find_format_no_tree(self):
123
 
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
124
 
        self.assertRaises(errors.NoWorkingTree,
125
 
                          workingtree.WorkingTreeFormat.find_format,
126
 
                          dir)
127
 
 
128
 
    def test_find_format_unknown_format(self):
129
 
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
130
 
        dir.create_repository()
131
 
        dir.create_branch()
132
 
        SampleTreeFormat().initialize(dir)
133
 
        self.assertRaises(errors.UnknownFormatError,
134
 
                          workingtree.WorkingTreeFormat.find_format,
135
 
                          dir)
136
 
 
137
 
    def test_register_unregister_format(self):
138
 
        format = SampleTreeFormat()
139
 
        # make a control dir
140
 
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
141
 
        dir.create_repository()
142
 
        dir.create_branch()
143
 
        # make a branch
144
 
        format.initialize(dir)
145
 
        # register a format for it.
146
 
        workingtree.WorkingTreeFormat.register_format(format)
147
 
        # which branch.Open will refuse (not supported)
148
 
        self.assertRaises(errors.UnsupportedFormatError, workingtree.WorkingTree.open, '.')
149
 
        # but open_downlevel will work
150
 
        self.assertEqual(format.open(dir), workingtree.WorkingTree.open_downlevel('.'))
151
 
        # unregister the format
152
 
        workingtree.WorkingTreeFormat.unregister_format(format)
153
 
 
154
 
 
155
 
class TestWorkingTreeFormat3(TestCaseWithTransport):
156
 
    """Tests specific to WorkingTreeFormat3."""
157
 
 
158
 
    def test_disk_layout(self):
159
 
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
160
 
        control.create_repository()
161
 
        control.create_branch()
162
 
        tree = workingtree.WorkingTreeFormat3().initialize(control)
163
 
        # we want:
164
 
        # format 'Bazaar-NG Working Tree format 3'
165
 
        # inventory = blank inventory
166
 
        # pending-merges = ''
167
 
        # stat-cache = ??
168
 
        # no inventory.basis yet
169
 
        t = control.get_workingtree_transport(None)
170
 
        self.assertEqualDiff('Bazaar-NG Working Tree format 3',
171
 
                             t.get('format').read())
172
 
        self.assertEqualDiff('<inventory format="5">\n'
173
 
                             '</inventory>\n',
174
 
                             t.get('inventory').read())
175
 
        self.assertEqualDiff('### bzr hashcache v5\n',
176
 
                             t.get('stat-cache').read())
177
 
        self.assertFalse(t.has('inventory.basis'))
178
 
        # no last-revision file means 'None' or 'NULLREVISION'
179
 
        self.assertFalse(t.has('last-revision'))
180
 
        # TODO RBC 20060210 do a commit, check the inventory.basis is created 
181
 
        # correctly and last-revision file becomes present.
182
 
 
183
 
    def test_uses_lockdir(self):
184
 
        """WorkingTreeFormat3 uses its own LockDir:
185
 
            
186
 
            - lock is a directory
187
 
            - when the WorkingTree is locked, LockDir can see that
 
222
        inv = b.repository.get_revision_inventory(revid)
 
223
        self.log('contents of inventory: %r' % inv.entries())
 
224
 
 
225
        self.check_inventory_shape(inv,
 
226
                                   ['dir', 'dir/sub', 'dir/sub/file'])
 
227
 
 
228
        wt.rename_one('dir', 'newdir')
 
229
 
 
230
        self.check_inventory_shape(wt.read_working_inventory(),
 
231
                                   ['newdir', 'newdir/sub', 'newdir/sub/file'])
 
232
 
 
233
        wt.rename_one('newdir/sub', 'newdir/newsub')
 
234
        self.check_inventory_shape(wt.read_working_inventory(),
 
235
                                   ['newdir', 'newdir/newsub',
 
236
                                    'newdir/newsub/file'])
 
237
 
 
238
    def test_add_in_unversioned(self):
 
239
        """Try to add a file in an unversioned directory.
 
240
 
 
241
        "bzr add" adds the parent as necessary, but simple working tree add
 
242
        doesn't do that.
188
243
        """
189
 
        t = self.get_transport()
190
 
        url = self.get_url()
191
 
        dir = bzrdir.BzrDirMetaFormat1().initialize(url)
192
 
        repo = dir.create_repository()
193
 
        branch = dir.create_branch()
194
 
        try:
195
 
            tree = workingtree.WorkingTreeFormat3().initialize(dir)
196
 
        except errors.NotLocalUrl:
197
 
            raise TestSkipped('Not a local URL')
198
 
        self.assertIsDirectory('.bzr', t)
199
 
        self.assertIsDirectory('.bzr/checkout', t)
200
 
        self.assertIsDirectory('.bzr/checkout/lock', t)
201
 
        our_lock = LockDir(t, '.bzr/checkout/lock')
202
 
        self.assertEquals(our_lock.peek(), None)
203
 
        tree.lock_write()
204
 
        self.assertTrue(our_lock.peek())
205
 
        tree.unlock()
206
 
        self.assertEquals(our_lock.peek(), None)
207
 
 
208
 
 
209
 
class TestFormat2WorkingTree(TestCaseWithTransport):
210
 
    """Tests that are specific to format 2 trees."""
211
 
 
212
 
    def create_format2_tree(self, url):
213
 
        return self.make_branch_and_tree(
214
 
            url, format=bzrlib.bzrdir.BzrDirFormat6())
215
 
 
216
 
    def test_conflicts(self):
217
 
        # test backwards compatability
218
 
        tree = self.create_format2_tree('.')
219
 
        self.assertRaises(errors.UnsupportedOperation, tree.set_conflicts,
220
 
                          None)
221
 
        file('lala.BASE', 'wb').write('labase')
222
 
        expected = ContentsConflict('lala')
223
 
        self.assertEqual(list(tree.conflicts()), [expected])
224
 
        file('lala', 'wb').write('la')
225
 
        tree.add('lala', 'lala-id')
226
 
        expected = ContentsConflict('lala', file_id='lala-id')
227
 
        self.assertEqual(list(tree.conflicts()), [expected])
228
 
        file('lala.THIS', 'wb').write('lathis')
229
 
        file('lala.OTHER', 'wb').write('laother')
230
 
        # When "text conflict"s happen, stem, THIS and OTHER are text
231
 
        expected = TextConflict('lala', file_id='lala-id')
232
 
        self.assertEqual(list(tree.conflicts()), [expected])
233
 
        os.unlink('lala.OTHER')
234
 
        os.mkdir('lala.OTHER')
235
 
        expected = ContentsConflict('lala', file_id='lala-id')
236
 
        self.assertEqual(list(tree.conflicts()), [expected])
237
 
 
238
 
 
239
 
class TestNonFormatSpecificCode(TestCaseWithTransport):
240
 
    """This class contains tests of workingtree that are not format specific."""
241
 
 
242
 
    
243
 
    def test_gen_file_id(self):
244
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('bar'), 'bar-')
245
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('Mwoo oof\t m'), 'Mwoooofm-')
246
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('..gam.py'), 'gam.py-')
247
 
        self.assertStartsWith(bzrlib.workingtree.gen_file_id('..Mwoo oof\t m'), 'Mwoooofm-')
248
 
 
249
 
    def test_next_id_suffix(self):
250
 
        bzrlib.workingtree._gen_id_suffix = None
251
 
        bzrlib.workingtree._next_id_suffix()
252
 
        self.assertNotEqual(None, bzrlib.workingtree._gen_id_suffix)
253
 
        bzrlib.workingtree._gen_id_suffix = "foo-"
254
 
        bzrlib.workingtree._gen_id_serial = 1
255
 
        self.assertEqual("foo-2", bzrlib.workingtree._next_id_suffix())
256
 
        self.assertEqual("foo-3", bzrlib.workingtree._next_id_suffix())
257
 
        self.assertEqual("foo-4", bzrlib.workingtree._next_id_suffix())
258
 
        self.assertEqual("foo-5", bzrlib.workingtree._next_id_suffix())
259
 
        self.assertEqual("foo-6", bzrlib.workingtree._next_id_suffix())
260
 
        self.assertEqual("foo-7", bzrlib.workingtree._next_id_suffix())
261
 
        self.assertEqual("foo-8", bzrlib.workingtree._next_id_suffix())
262
 
        self.assertEqual("foo-9", bzrlib.workingtree._next_id_suffix())
263
 
        self.assertEqual("foo-10", bzrlib.workingtree._next_id_suffix())
264
 
 
265
 
    def test__translate_ignore_rule(self):
266
 
        tree = self.make_branch_and_tree('.')
267
 
        # translation should return the regex, the number of groups in it,
268
 
        # and the original rule in a tuple.
269
 
        # there are three sorts of ignore rules:
270
 
        # root only - regex is the rule itself without the leading ./
271
 
        self.assertEqual(
272
 
            "(rootdirrule$)", 
273
 
            tree._translate_ignore_rule("./rootdirrule"))
274
 
        # full path - regex is the rule itself
275
 
        self.assertEqual(
276
 
            "(path\\/to\\/file$)",
277
 
            tree._translate_ignore_rule("path/to/file"))
278
 
        # basename only rule - regex is a rule that ignores everything up
279
 
        # to the last / in the filename
280
 
        self.assertEqual(
281
 
            "((?:.*/)?(?!.*/)basenamerule$)",
282
 
            tree._translate_ignore_rule("basenamerule"))
283
 
 
284
 
    def test__combine_ignore_rules(self):
285
 
        tree = self.make_branch_and_tree('.')
286
 
        # the combined ignore regexs need the outer group indices
287
 
        # placed in a dictionary with the rules that were combined.
288
 
        # an empty set of rules
289
 
        # this is returned as a list of combined regex,rule sets, because
290
 
        # python has a limit of 100 combined regexes.
291
 
        compiled_rules = tree._combine_ignore_rules([])
292
 
        self.assertEqual([], compiled_rules)
293
 
        # one of each type of rule.
294
 
        compiled_rules = tree._combine_ignore_rules(
295
 
            ["rule1", "rule/two", "./three"])[0]
296
 
        # what type *is* the compiled regex to do an isinstance of ?
297
 
        self.assertEqual(3, compiled_rules[0].groups)
298
 
        self.assertEqual(
299
 
            {0:"rule1",1:"rule/two",2:"./three"},
300
 
            compiled_rules[1])
301
 
 
302
 
    def test__combine_ignore_rules_grouping(self):
303
 
        tree = self.make_branch_and_tree('.')
304
 
        # when there are too many rules, the output is split into groups of 100
305
 
        rules = []
306
 
        for index in range(198):
307
 
            rules.append('foo')
308
 
        self.assertEqual(2, len(tree._combine_ignore_rules(rules)))
309
 
 
310
 
    def test__get_ignore_rules_as_regex(self):
311
 
        tree = self.make_branch_and_tree('.')
312
 
        # test against the default rules.
313
 
        reference_output = tree._combine_ignore_rules(bzrlib.DEFAULT_IGNORE)[0]
314
 
        regex_rules = tree._get_ignore_rules_as_regex()[0]
315
 
        self.assertEqual(len(reference_output[1]), regex_rules[0].groups)
316
 
        self.assertEqual(reference_output[1], regex_rules[1])
 
244
        from bzrlib.errors import NotVersionedError
 
245
        wt = self.make_branch_and_tree('.')
 
246
        self.build_tree(['foo/',
 
247
                         'foo/hello'])
 
248
        self.assertRaises(NotVersionedError,
 
249
                          wt.add,
 
250
                          'foo/hello')
 
251
 
 
252
    def test_remove_verbose(self):
 
253
        #FIXME the remove api should not print or otherwise depend on the
 
254
        # text UI - RBC 20060124
 
255
        wt = self.make_branch_and_tree('.')
 
256
        self.build_tree(['hello'])
 
257
        wt.add(['hello'])
 
258
        wt.commit(message='add hello')
 
259
        stdout = StringIO()
 
260
        stderr = StringIO()
 
261
        self.assertEqual(None, self.apply_redirected(None, stdout, stderr,
 
262
                                                     wt.remove,
 
263
                                                     ['hello'],
 
264
                                                     verbose=True))
 
265
        self.assertEqual('?       hello\n', stdout.getvalue())
 
266
        self.assertEqual('', stderr.getvalue())