~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to clean_tree.py

  • Committer: Aaron Bentley
  • Date: 2006-02-21 05:08:07 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20060221050807-3cc86585e1ec6edc
Updated to match API changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
import errno
17
17
import os
18
 
from bzrlib.osutils import has_symlinks, isdir
19
18
import shutil
20
 
from bzrlib.branch import Branch
21
19
import sys
22
20
 
 
21
from bzrlib.bzrdir import BzrDir
 
22
from bzrlib.osutils import has_symlinks, isdir
 
23
from bzrlib.workingtree import WorkingTree
 
24
 
23
25
def is_detritus(subp):
24
26
    return subp.endswith('.THIS') or subp.endswith('.BASE') or\
25
27
        subp.endswith('.OTHER') or subp.endswith('~') or subp.endswith('.tmp')
39
41
 
40
42
def clean_tree(directory, ignored=False, detritus=False, dry_run=False,
41
43
               to_file=sys.stdout):
42
 
    br = Branch.open_containing(directory)[0]
43
 
    tree = br.working_tree()
 
44
    tree = WorkingTree.open_containing(directory)[0]
44
45
    deletables = iter_deletables(tree, ignored=ignored, detritus=detritus)
45
46
    delete_items(deletables, dry_run=dry_run, to_file=to_file)
46
47
 
69
70
            if has_symlinks() is False:
70
71
                return
71
72
            os.mkdir('branch')
72
 
            b = Branch.initialize('branch')
 
73
            BzrDir.create_standalone_workingtree('branch')
73
74
            os.symlink(os.path.realpath('no-die-please'), 'branch/die-please')
74
75
            os.mkdir('no-die-please')
75
76
            assert os.path.exists('branch/die-please')
82
83
        def test_iter_deletable(self):
83
84
            """Files are selected for deletion appropriately"""
84
85
            os.mkdir('branch')
85
 
            b = Branch.initialize('branch')
86
 
            tree = b.working_tree()
 
86
            tree = BzrDir.create_standalone_workingtree('branch')
87
87
            file('branch/file.BASE', 'wb').write('contents')
88
88
            self.assertEqual(len(list(iter_deletables(tree))), 1)
89
89
            file('branch/file~', 'wb').write('contents')