bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
4020.1.4
by Aaron Bentley
 Assign copyright, update tests.  | 
1  | 
# Copyright (C) 2005, 2009 Canonical Ltd
 | 
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
2  | 
#
 | 
3  | 
# This program is free software; you can redistribute it and/or modify
 | 
|
4  | 
# it under the terms of the GNU General Public License as published by
 | 
|
5  | 
# the Free Software Foundation; either version 2 of the License, or
 | 
|
6  | 
# (at your option) any later version.
 | 
|
7  | 
#
 | 
|
8  | 
# This program is distributed in the hope that it will be useful,
 | 
|
9  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
10  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
11  | 
# GNU General Public License for more details.
 | 
|
12  | 
#
 | 
|
13  | 
# You should have received a copy of the GNU General Public License
 | 
|
14  | 
# along with this program; if not, write to the Free Software
 | 
|
15  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
16  | 
||
17  | 
||
18  | 
import os  | 
|
19  | 
from StringIO import StringIO  | 
|
| 
4020.1.2
by Jelmer Vernooij
 Import blackbox test for clean-tree, run regular tests.  | 
20  | 
|
21  | 
from bzrlib.bzrdir import (  | 
|
22  | 
BzrDir,  | 
|
23  | 
    )
 | 
|
24  | 
from bzrlib.clean_tree import (  | 
|
25  | 
clean_tree,  | 
|
26  | 
iter_deletables,  | 
|
27  | 
    )
 | 
|
28  | 
from bzrlib.osutils import (  | 
|
29  | 
has_symlinks,  | 
|
30  | 
    )
 | 
|
31  | 
from bzrlib.tests import (  | 
|
32  | 
TestCaseInTempDir,  | 
|
33  | 
    )
 | 
|
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
34  | 
|
| 
4020.1.5
by Aaron Bentley
 Fix some formatting issues.  | 
35  | 
|
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
36  | 
class TestCleanTree(TestCaseInTempDir):  | 
| 
4020.1.2
by Jelmer Vernooij
 Import blackbox test for clean-tree, run regular tests.  | 
37  | 
|
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
38  | 
def test_symlinks(self):  | 
39  | 
if has_symlinks() is False:  | 
|
40  | 
            return
 | 
|
41  | 
os.mkdir('branch')  | 
|
42  | 
BzrDir.create_standalone_workingtree('branch')  | 
|
43  | 
os.symlink(os.path.realpath('no-die-please'), 'branch/die-please')  | 
|
44  | 
os.mkdir('no-die-please')  | 
|
| 
4020.1.7
by Aaron Bentley
 Convert asserts to TestCase helper methods  | 
45  | 
self.failUnlessExists('branch/die-please')  | 
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
46  | 
os.mkdir('no-die-please/child')  | 
47  | 
||
48  | 
clean_tree('branch', unknown=True, no_prompt=True)  | 
|
| 
4020.1.7
by Aaron Bentley
 Convert asserts to TestCase helper methods  | 
49  | 
self.failUnlessExists('no-die-please')  | 
50  | 
self.failUnlessExists('no-die-please/child')  | 
|
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
51  | 
|
52  | 
def test_iter_deletable(self):  | 
|
53  | 
"""Files are selected for deletion appropriately"""  | 
|
54  | 
os.mkdir('branch')  | 
|
55  | 
tree = BzrDir.create_standalone_workingtree('branch')  | 
|
| 
4020.1.4
by Aaron Bentley
 Assign copyright, update tests.  | 
56  | 
transport = tree.bzrdir.root_transport  | 
57  | 
transport.put_bytes('.bzrignore', '*~\n*.pyc\n.bzrignore\n')  | 
|
58  | 
transport.put_bytes('file.BASE', 'contents')  | 
|
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
59  | 
tree.lock_write()  | 
60  | 
try:  | 
|
61  | 
self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)  | 
|
| 
4020.1.4
by Aaron Bentley
 Assign copyright, update tests.  | 
62  | 
transport.put_bytes('file', 'contents')  | 
63  | 
transport.put_bytes('file~', 'contents')  | 
|
64  | 
transport.put_bytes('file.pyc', 'contents')  | 
|
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
65  | 
dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])  | 
| 
4020.1.7
by Aaron Bentley
 Convert asserts to TestCase helper methods  | 
66  | 
self.assertEqual(['file', 'file.BASE'], dels)  | 
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
67  | 
|
68  | 
dels = [r for a,r in iter_deletables(tree, detritus=True)]  | 
|
| 
4020.1.7
by Aaron Bentley
 Convert asserts to TestCase helper methods  | 
69  | 
self.assertEqual(sorted(['file~', 'file.BASE']), dels)  | 
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
70  | 
|
71  | 
dels = [r for a,r in iter_deletables(tree, ignored=True)]  | 
|
| 
4020.1.7
by Aaron Bentley
 Convert asserts to TestCase helper methods  | 
72  | 
self.assertEqual(sorted(['file~', 'file.pyc', '.bzrignore']),  | 
73  | 
dels)  | 
|
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
74  | 
|
75  | 
dels = [r for a,r in iter_deletables(tree, unknown=False)]  | 
|
| 
4020.1.7
by Aaron Bentley
 Convert asserts to TestCase helper methods  | 
76  | 
self.assertEqual([], dels)  | 
| 
4020.1.1
by Jelmer Vernooij
 Import clean-tree from bzrtools.  | 
77  | 
finally:  | 
78  | 
tree.unlock()  |