~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to clean_tree.py

  • Committer: Aaron Bentley
  • Date: 2006-06-08 11:52:21 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20060608115221-1b8122a2c3b24c50
Updated formatting

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib.trace import note
23
23
from bzrlib.workingtree import WorkingTree
24
24
 
 
25
 
25
26
def is_detritus(subp):
 
27
    """Return True if the supplied path is detritus, False otherwise"""
26
28
    return subp.endswith('.THIS') or subp.endswith('.BASE') or\
27
29
        subp.endswith('.OTHER') or subp.endswith('~') or subp.endswith('.tmp')
28
30
 
 
31
 
29
32
def iter_deletables(tree, unknown=True, ignored=False, detritus=False):
30
33
    """Iterate through files that may be deleted"""
31
34
    for subp in tree.extras():
39
42
            if unknown:
40
43
                yield tree.abspath(subp), subp
41
44
 
 
45
 
42
46
def clean_tree(directory, ignored=False, detritus=False, dry_run=False):
 
47
    """Remove files in the specified classes from the tree"""
43
48
    tree = WorkingTree.open_containing(directory)[0]
44
49
    deletables = iter_deletables(tree, ignored=ignored, detritus=detritus)
45
50
    delete_items(deletables, dry_run=dry_run)
46
51
 
 
52
 
47
53
def delete_items(deletables, dry_run=False):
48
54
    """Delete files in the deletables iterable"""
49
55
    has_deleted = False