/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/clean_tree.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import os
19
19
import shutil
20
20
 
21
 
from bzrlib import bzrdir, errors
22
21
from bzrlib.osutils import isdir
23
22
from bzrlib.trace import note
24
23
from bzrlib.workingtree import WorkingTree
52
51
    try:
53
52
        deletables = list(iter_deletables(tree, unknown=unknown,
54
53
            ignored=ignored, detritus=detritus))
55
 
        deletables = _filter_out_nested_bzrdirs(deletables)
56
54
        if len(deletables) == 0:
57
55
            note('Nothing to delete.')
58
56
            return 0
59
57
        if not no_prompt:
60
58
            for path, subp in deletables:
61
 
                # FIXME using print is very bad idea
62
 
                # clean_tree should accept to_file argument to write the output
63
59
                print subp
64
60
            val = raw_input('Are you sure you wish to delete these [y/N]?')
65
61
            if val.lower() not in ('y', 'yes'):
70
66
        tree.unlock()
71
67
 
72
68
 
73
 
def _filter_out_nested_bzrdirs(deletables):
74
 
    result = []
75
 
    for path, subp in deletables:
76
 
        # bzr won't recurse into unknowns/ignored directories by default
77
 
        # so we don't pay a penalty for checking subdirs of path for nested
78
 
        # bzrdir.
79
 
        # That said we won't detect the branch in the subdir of non-branch
80
 
        # directory and therefore delete it. (worth to FIXME?)
81
 
        if isdir(path):
82
 
            try:
83
 
                bzrdir.BzrDir.open(path)
84
 
            except errors.NotBranchError:
85
 
                result.append((path,subp))
86
 
            else:
87
 
                # TODO may be we need to notify user about skipped directories?
88
 
                pass
89
 
        else:
90
 
            result.append((path,subp))
91
 
    return result
92
 
 
93
 
 
94
69
def delete_items(deletables, dry_run=False):
95
70
    """Delete files in the deletables iterable"""
96
71
    has_deleted = False