~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to clean_tree.py

  • Committer: Aaron Bentley
  • Date: 2007-01-08 17:27:48 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070108172748-1b22qtszaadoby89
Improve bzr import docs

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
 
    tree.lock_read()
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
64
 
        delete_items(deletables, dry_run=dry_run)
65
 
    finally:
66
 
        tree.unlock()
 
50
    deletables = iter_deletables(tree, unknown=unknown, ignored=ignored, 
 
51
                                 detritus=detritus)
 
52
    delete_items(deletables, dry_run=dry_run)
67
53
 
68
54
 
69
55
def delete_items(deletables, dry_run=False):