~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/clean_tree.py

  • Committer: Patch Queue Manager
  • Date: 2016-01-31 13:36:59 UTC
  • mfrom: (6613.1.5 1538480-match-hostname)
  • Revision ID: pqm@pqm.ubuntu.com-20160131133659-ouy92ee2wlv9xz8m
(vila) Use ssl.match_hostname instead of our own. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
17
18
 
18
19
import errno
19
20
import os
20
21
import shutil
21
22
 
22
23
from bzrlib import (
23
 
    bzrdir,
 
24
    controldir,
24
25
    errors,
25
26
    ui,
26
27
    )
27
28
from bzrlib.osutils import isdir
28
29
from bzrlib.trace import note
29
30
from bzrlib.workingtree import WorkingTree
30
 
 
 
31
from bzrlib.i18n import gettext
31
32
 
32
33
def is_detritus(subp):
33
34
    """Return True if the supplied path is detritus, False otherwise"""
59
60
            ignored=ignored, detritus=detritus))
60
61
        deletables = _filter_out_nested_bzrdirs(deletables)
61
62
        if len(deletables) == 0:
62
 
            note('Nothing to delete.')
 
63
            note(gettext('Nothing to delete.'))
63
64
            return 0
64
65
        if not no_prompt:
65
66
            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'
 
67
                ui.ui_factory.note(subp)
 
68
            prompt = gettext('Are you sure you wish to delete these')
 
69
            if not ui.ui_factory.get_boolean(prompt):
 
70
                ui.ui_factory.note(gettext('Canceled'))
72
71
                return 0
73
72
        delete_items(deletables, dry_run=dry_run)
74
73
    finally:
85
84
        # directory and therefore delete it. (worth to FIXME?)
86
85
        if isdir(path):
87
86
            try:
88
 
                bzrdir.BzrDir.open(path)
 
87
                controldir.ControlDir.open(path)
89
88
            except errors.NotBranchError:
90
89
                result.append((path,subp))
91
90
            else:
105
104
        # Other errors are re-raised.
106
105
        if function is not os.remove or excinfo[1].errno != errno.EACCES:
107
106
            raise
108
 
        ui.ui_factory.show_warning('unable to remove %s' % path)
 
107
        ui.ui_factory.show_warning(gettext('unable to remove %s') % path)
109
108
    has_deleted = False
110
109
    for path, subp in deletables:
111
110
        if not has_deleted:
112
 
            note("deleting paths:")
 
111
            note(gettext("deleting paths:"))
113
112
            has_deleted = True
114
113
        if not dry_run:
115
114
            if isdir(path):
122
121
                    # We handle only permission error here
123
122
                    if e.errno != errno.EACCES:
124
123
                        raise e
125
 
                    ui.ui_factory.show_warning(
126
 
                        'unable to remove "%s": %s.' % (path, e.strerror))
 
124
                    ui.ui_factory.show_warning(gettext(
 
125
                        'unable to remove "{0}": {1}.').format(
 
126
                                                    path, e.strerror))
127
127
        else:
128
128
            note('  ' + subp)
129
129
    if not has_deleted:
130
 
        note("No files deleted.")
 
130
        note(gettext("No files deleted."))