~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/clean_tree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 19:18:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216191839-eg681lxqibi1qxu1
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import shutil
21
21
 
22
22
from bzrlib import (
23
 
    bzrdir,
 
23
    controldir,
24
24
    errors,
25
25
    ui,
26
26
    )
27
27
from bzrlib.osutils import isdir
28
28
from bzrlib.trace import note
29
29
from bzrlib.workingtree import WorkingTree
30
 
 
 
30
from bzrlib.i18n import gettext
31
31
 
32
32
def is_detritus(subp):
33
33
    """Return True if the supplied path is detritus, False otherwise"""
59
59
            ignored=ignored, detritus=detritus))
60
60
        deletables = _filter_out_nested_bzrdirs(deletables)
61
61
        if len(deletables) == 0:
62
 
            note('Nothing to delete.')
 
62
            note(gettext('Nothing to delete.'))
63
63
            return 0
64
64
        if not no_prompt:
65
65
            for path, subp in deletables:
66
 
                # FIXME using print is very bad idea
67
 
                # clean_tree should accept to_file argument to write the output
68
 
                print subp
69
 
            val = raw_input('Are you sure you wish to delete these [y/N]?')
70
 
            if val.lower() not in ('y', 'yes'):
71
 
                print 'Canceled'
 
66
                ui.ui_factory.note(subp)
 
67
            prompt = gettext('Are you sure you wish to delete these')
 
68
            if not ui.ui_factory.get_boolean(prompt):
 
69
                ui.ui_factory.note(gettext('Canceled'))
72
70
                return 0
73
71
        delete_items(deletables, dry_run=dry_run)
74
72
    finally:
85
83
        # directory and therefore delete it. (worth to FIXME?)
86
84
        if isdir(path):
87
85
            try:
88
 
                bzrdir.BzrDir.open(path)
 
86
                controldir.ControlDir.open(path)
89
87
            except errors.NotBranchError:
90
88
                result.append((path,subp))
91
89
            else:
105
103
        # Other errors are re-raised.
106
104
        if function is not os.remove or excinfo[1].errno != errno.EACCES:
107
105
            raise
108
 
        ui.ui_factory.show_warning('unable to remove %s' % path)
 
106
        ui.ui_factory.show_warning(gettext('unable to remove %s') % path)
109
107
    has_deleted = False
110
108
    for path, subp in deletables:
111
109
        if not has_deleted:
112
 
            note("deleting paths:")
 
110
            note(gettext("deleting paths:"))
113
111
            has_deleted = True
114
112
        if not dry_run:
115
113
            if isdir(path):
122
120
                    # We handle only permission error here
123
121
                    if e.errno != errno.EACCES:
124
122
                        raise e
125
 
                    ui.ui_factory.show_warning(
126
 
                        'unable to remove "%s": %s.' % (path, e.strerror))
 
123
                    ui.ui_factory.show_warning(gettext(
 
124
                        'unable to remove "{0}": {1}.').format(
 
125
                                                    path, e.strerror))
127
126
        else:
128
127
            note('  ' + subp)
129
128
    if not has_deleted:
130
 
        note("No files deleted.")
 
129
        note(gettext("No files deleted."))