~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to clean_tree.py

  • Committer: Aaron Bentley
  • Date: 2007-12-17 13:11:59 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20071217131159-dqve0ry2kvci7o2a
Received bug report

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
 
46
46
def clean_tree(directory, unknown=False, ignored=False, detritus=False, 
47
 
               dry_run=False, no_prompt=False):
 
47
               dry_run=False):
48
48
    """Remove files in the specified classes from the tree"""
49
49
    tree = WorkingTree.open_containing(directory)[0]
50
50
    tree.lock_read()
51
51
    try:
52
 
        deletables = list(iter_deletables(tree, unknown=unknown,
53
 
            ignored=ignored, detritus=detritus))
54
 
        if len(deletables) == 0:
55
 
            note('Nothing to delete.')
56
 
            return 0
57
 
        if not no_prompt:
58
 
            for path, subp in deletables:
59
 
                print subp
60
 
            val = raw_input('Are you sure you wish to delete these [y/N]?')
61
 
            if val.lower() not in ('y', 'yes'):
62
 
                print 'Canceled'
63
 
                return 0
 
52
        deletables = iter_deletables(tree, unknown=unknown, ignored=ignored,
 
53
                                     detritus=detritus)
64
54
        delete_items(deletables, dry_run=dry_run)
65
55
    finally:
66
56
        tree.unlock()