~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to clean_tree.py

  • Committer: Aaron Bentley
  • Date: 2005-12-16 13:42:53 UTC
  • Revision ID: abentley@panoramicfeedback.com-20051216134253-632812e160315bc8
Updated test to match bzrlib

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
18
19
import shutil
 
20
from bzrlib.branch import Branch
19
21
import sys
20
22
 
21
 
from bzrlib.bzrdir import BzrDir
22
 
from bzrlib.osutils import has_symlinks, isdir
23
 
from bzrlib.workingtree import WorkingTree
24
 
 
25
23
def is_detritus(subp):
26
24
    return subp.endswith('.THIS') or subp.endswith('.BASE') or\
27
25
        subp.endswith('.OTHER') or subp.endswith('~') or subp.endswith('.tmp')
41
39
 
42
40
def clean_tree(directory, ignored=False, detritus=False, dry_run=False,
43
41
               to_file=sys.stdout):
44
 
    tree = WorkingTree.open_containing(directory)[0]
 
42
    br = Branch.open_containing(directory)[0]
 
43
    tree = br.working_tree()
45
44
    deletables = iter_deletables(tree, ignored=ignored, detritus=detritus)
46
45
    delete_items(deletables, dry_run=dry_run, to_file=to_file)
47
46
 
70
69
            if has_symlinks() is False:
71
70
                return
72
71
            os.mkdir('branch')
73
 
            BzrDir.create_standalone_workingtree('branch')
 
72
            b = Branch.initialize('branch')
74
73
            os.symlink(os.path.realpath('no-die-please'), 'branch/die-please')
75
74
            os.mkdir('no-die-please')
76
75
            assert os.path.exists('branch/die-please')
83
82
        def test_iter_deletable(self):
84
83
            """Files are selected for deletion appropriately"""
85
84
            os.mkdir('branch')
86
 
            tree = BzrDir.create_standalone_workingtree('branch')
 
85
            b = Branch.initialize('branch')
 
86
            tree = b.working_tree()
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')