~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_clean_tree.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
import errno
19
19
import os
20
20
import shutil
 
21
from StringIO import StringIO
21
22
import sys
 
23
import types
22
24
 
23
25
from bzrlib import tests, ui
24
 
from bzrlib.controldir import (
25
 
    ControlDir,
 
26
from bzrlib.bzrdir import (
 
27
    BzrDir,
26
28
    )
27
29
from bzrlib.clean_tree import (
28
30
    clean_tree,
42
44
        if has_symlinks() is False:
43
45
            return
44
46
        os.mkdir('branch')
45
 
        ControlDir.create_standalone_workingtree('branch')
 
47
        BzrDir.create_standalone_workingtree('branch')
46
48
        os.symlink(os.path.realpath('no-die-please'), 'branch/die-please')
47
49
        os.mkdir('no-die-please')
48
 
        self.assertPathExists('branch/die-please')
 
50
        self.failUnlessExists('branch/die-please')
49
51
        os.mkdir('no-die-please/child')
50
52
 
51
53
        clean_tree('branch', unknown=True, no_prompt=True)
52
 
        self.assertPathExists('no-die-please')
53
 
        self.assertPathExists('no-die-please/child')
 
54
        self.failUnlessExists('no-die-please')
 
55
        self.failUnlessExists('no-die-please/child')
54
56
 
55
57
    def test_iter_deletable(self):
56
58
        """Files are selected for deletion appropriately"""
57
59
        os.mkdir('branch')
58
 
        tree = ControlDir.create_standalone_workingtree('branch')
 
60
        tree = BzrDir.create_standalone_workingtree('branch')
59
61
        transport = tree.bzrdir.root_transport
60
62
        transport.put_bytes('.bzrignore', '*~\n*.pyc\n.bzrignore\n')
61
63
        transport.put_bytes('file.BASE', 'contents')
97
99
        def _dummy_rmtree(path, ignore_errors=False, onerror=None):
98
100
            """Call user supplied error handler onerror.
99
101
            """
 
102
            self.assertTrue(isinstance(onerror, types.FunctionType))
100
103
            # Indicate failure in removing 'path' if path is subdir0
101
104
            # We later check to ensure that this is indicated
102
105
            # to the user as a warning. We raise OSError to construct
121
124
        stderr = tests.StringIOWrapper()
122
125
        ui.ui_factory = tests.TestUIFactory(stdout=stdout, stderr=stderr)
123
126
 
124
 
        ControlDir.create_standalone_workingtree('.')
 
127
        BzrDir.create_standalone_workingtree('.')
125
128
        self.build_tree(['0foo', '1bar', '2baz', 'subdir0/'])
126
129
        clean_tree('.', unknown=True, no_prompt=True)
127
130
        self.assertContainsRe(stderr.getvalue(),