bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
1399.1.12
by Robert Collins
 add new test script  | 
1  | 
# (C) 2005 Canonical Ltd
 | 
2  | 
# Authors:  Robert Collins <robert.collins@canonical.com>
 | 
|
3  | 
#
 | 
|
4  | 
# This program is free software; you can redistribute it and/or modify
 | 
|
5  | 
# it under the terms of the GNU General Public License as published by
 | 
|
6  | 
# the Free Software Foundation; either version 2 of the License, or
 | 
|
7  | 
# (at your option) any later version.
 | 
|
8  | 
#
 | 
|
9  | 
# This program is distributed in the hope that it will be useful,
 | 
|
10  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
11  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
12  | 
# GNU General Public License for more details.
 | 
|
13  | 
#
 | 
|
14  | 
# You should have received a copy of the GNU General Public License
 | 
|
15  | 
# along with this program; if not, write to the Free Software
 | 
|
16  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
17  | 
||
18  | 
import os  | 
|
19  | 
from bzrlib.branch import Branch  | 
|
20  | 
from bzrlib.selftest import TestCaseInTempDir  | 
|
21  | 
from bzrlib.trace import mutter  | 
|
| 
1457.1.1
by Robert Collins
 rather than getting the branch inventory, WorkingTree can use the whole Branch, or make its own.  | 
22  | 
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,  | 
23  | 
WorkingTree)  | 
|
| 
1399.1.12
by Robert Collins
 add new test script  | 
24  | 
|
25  | 
class TestTreeDirectory(TestCaseInTempDir):  | 
|
26  | 
||
27  | 
def test_kind_character(self):  | 
|
28  | 
self.assertEqual(TreeDirectory().kind_character(), '/')  | 
|
29  | 
||
30  | 
||
31  | 
class TestTreeEntry(TestCaseInTempDir):  | 
|
32  | 
||
33  | 
def test_kind_character(self):  | 
|
34  | 
self.assertEqual(TreeEntry().kind_character(), '???')  | 
|
35  | 
||
36  | 
||
37  | 
class TestTreeFile(TestCaseInTempDir):  | 
|
38  | 
||
39  | 
def test_kind_character(self):  | 
|
40  | 
self.assertEqual(TreeFile().kind_character(), '')  | 
|
41  | 
||
42  | 
||
43  | 
class TestTreeLink(TestCaseInTempDir):  | 
|
44  | 
||
45  | 
def test_kind_character(self):  | 
|
46  | 
self.assertEqual(TreeLink().kind_character(), '')  | 
|
47  | 
||
48  | 
||
49  | 
class TestWorkingTree(TestCaseInTempDir):  | 
|
50  | 
||
51  | 
def test_listfiles(self):  | 
|
52  | 
branch = Branch.initialize('.')  | 
|
53  | 
os.mkdir('dir')  | 
|
54  | 
print >> open('file', 'w'), "content"  | 
|
55  | 
os.symlink('target', 'symlink')  | 
|
56  | 
tree = branch.working_tree()  | 
|
57  | 
files = list(tree.list_files())  | 
|
58  | 
self.assertEqual(files[0], ('dir', '?', 'directory', None, TreeDirectory()))  | 
|
59  | 
self.assertEqual(files[1], ('file', '?', 'file', None, TreeFile()))  | 
|
60  | 
self.assertEqual(files[2], ('symlink', '?', 'symlink', None, TreeLink()))  | 
|
| 
1457.1.1
by Robert Collins
 rather than getting the branch inventory, WorkingTree can use the whole Branch, or make its own.  | 
61  | 
|
62  | 
def test_construct_with_branch(self):  | 
|
63  | 
branch = Branch.initialize('.')  | 
|
64  | 
tree = WorkingTree(branch.base, branch)  | 
|
65  | 
self.assertEqual(branch, tree.branch)  | 
|
66  | 
self.assertEqual(branch.inventory, tree._inventory)  | 
|
67  | 
self.assertEqual(branch.base, tree.basedir)  | 
|
68  | 
||
69  | 
def test_construct_without_branch(self):  | 
|
70  | 
branch = Branch.initialize('.')  | 
|
71  | 
tree = WorkingTree(branch.base)  | 
|
72  | 
self.assertEqual(branch.base, tree.branch.base)  | 
|
73  | 
self.assertEqual(branch.inventory, tree._inventory)  | 
|
74  | 
self.assertEqual(branch.base, tree.basedir)  | 
|
| 
1457.1.3
by Robert Collins
 make Branch.relpath delegate to the working tree.  | 
75  | 
|
76  | 
def test_basic_relpath(self):  | 
|
77  | 
        # for comprehensive relpath tests, see whitebox.py.
 | 
|
78  | 
branch = Branch.initialize('.')  | 
|
79  | 
tree = WorkingTree(branch.base)  | 
|
80  | 
self.assertEqual('child',  | 
|
81  | 
tree.relpath(os.path.join(os.getcwd(), 'child')))  | 
|
| 
1442.1.65
by Robert Collins
 Branch.remove has been moved to WorkingTree.  | 
82  | 
|
83  | 
def test_lock_locks_branch(self):  | 
|
84  | 
branch = Branch.initialize('.')  | 
|
85  | 
tree = WorkingTree(branch.base)  | 
|
86  | 
tree.lock_read()  | 
|
87  | 
self.assertEqual(1, tree.branch._lock_count)  | 
|
88  | 
self.assertEqual('r', tree.branch._lock_mode)  | 
|
89  | 
tree.unlock()  | 
|
90  | 
self.assertEqual(None, tree.branch._lock_count)  | 
|
91  | 
tree.lock_write()  | 
|
92  | 
self.assertEqual(1, tree.branch._lock_count)  | 
|
93  | 
self.assertEqual('w', tree.branch._lock_mode)  | 
|
94  | 
tree.unlock()  | 
|
95  | 
self.assertEqual(None, tree.branch._lock_count)  | 
|
| 
1442.1.68
by Robert Collins
 'bzr pull' now accepts '--clobber'.  | 
96  | 
|
97  | 
def get_pullable_branches(self):  | 
|
| 
1442.1.67
by Robert Collins
 Factor out the guts of 'pull' from the command into WorkingTree.pull().  | 
98  | 
self.build_tree(['from/', 'from/file', 'to/'])  | 
99  | 
br_a = Branch.initialize('from')  | 
|
100  | 
br_a.add('file')  | 
|
101  | 
br_a.commit('foo', rev_id='A')  | 
|
102  | 
br_b = Branch.initialize('to')  | 
|
| 
1442.1.68
by Robert Collins
 'bzr pull' now accepts '--clobber'.  | 
103  | 
return br_a, br_b  | 
104  | 
||
105  | 
def test_pull(self):  | 
|
106  | 
br_a, br_b = self.get_pullable_branches()  | 
|
| 
1442.1.67
by Robert Collins
 Factor out the guts of 'pull' from the command into WorkingTree.pull().  | 
107  | 
br_b.working_tree().pull(br_a)  | 
108  | 
self.failUnless(br_b.has_revision('A'))  | 
|
109  | 
self.assertEqual(['A'], br_b.revision_history())  | 
|
| 
1442.1.68
by Robert Collins
 'bzr pull' now accepts '--clobber'.  | 
110  | 
|
| 
1185.12.92
by Aaron Bentley
 Fixed pull help, renamed clobber to overwrite  | 
111  | 
def test_pull_overwrites(self):  | 
| 
1442.1.68
by Robert Collins
 'bzr pull' now accepts '--clobber'.  | 
112  | 
br_a, br_b = self.get_pullable_branches()  | 
113  | 
br_b.commit('foo', rev_id='B')  | 
|
114  | 
self.assertEqual(['B'], br_b.revision_history())  | 
|
| 
1185.12.92
by Aaron Bentley
 Fixed pull help, renamed clobber to overwrite  | 
115  | 
br_b.working_tree().pull(br_a, overwrite=True)  | 
| 
1442.1.68
by Robert Collins
 'bzr pull' now accepts '--clobber'.  | 
116  | 
self.failUnless(br_b.has_revision('A'))  | 
117  | 
self.failUnless(br_b.has_revision('B'))  | 
|
118  | 
self.assertEqual(['A'], br_b.revision_history())  |