bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1092.1.26
by Robert Collins
start writing star-topology test, realise we need smart-add change |
1 |
import os |
2 |
import unittest |
|
3 |
||
|
1185.31.25
by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py |
4 |
from bzrlib.tests import TestCaseInTempDir, TestCase |
|
1092.1.26
by Robert Collins
start writing star-topology test, realise we need smart-add change |
5 |
from bzrlib.branch import Branch |
|
1185.16.72
by Martin Pool
[merge] from robert and fix up tests |
6 |
from bzrlib.errors import NotBranchError |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
7 |
from bzrlib.inventory import InventoryFile, Inventory |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
8 |
from bzrlib.workingtree import WorkingTree |
|
1092.1.26
by Robert Collins
start writing star-topology test, realise we need smart-add change |
9 |
|
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
10 |
class TestSmartAdd(TestCaseInTempDir): |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
11 |
|
12 |
def test_add_dot_from_root(self): |
|
13 |
"""Test adding . from the root of the tree.""" |
|
14 |
from bzrlib.add import smart_add |
|
15 |
paths = ("original/", "original/file1", "original/file2") |
|
16 |
self.build_tree(paths) |
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
17 |
branch = Branch.initialize(u".") |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
18 |
smart_add((u".",)) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
19 |
for path in paths: |
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
20 |
self.assertNotEqual(branch.working_tree().path2id(path), None) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
21 |
|
22 |
def test_add_dot_from_subdir(self): |
|
23 |
"""Test adding . from a subdir of the tree.""" |
|
24 |
from bzrlib.add import smart_add |
|
25 |
paths = ("original/", "original/file1", "original/file2") |
|
26 |
self.build_tree(paths) |
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
27 |
branch = Branch.initialize(u".") |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
28 |
os.chdir("original") |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
29 |
smart_add((u".",)) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
30 |
for path in paths: |
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
31 |
self.assertNotEqual(branch.working_tree().path2id(path), None) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
32 |
|
33 |
def test_add_tree_from_above_tree(self): |
|
34 |
"""Test adding a tree from above the tree.""" |
|
35 |
from bzrlib.add import smart_add |
|
36 |
paths = ("original/", "original/file1", "original/file2") |
|
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
37 |
branch_paths = ("branch/", "branch/original/", "branch/original/file1", |
38 |
"branch/original/file2") |
|
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
39 |
self.build_tree(branch_paths) |
|
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
40 |
branch = Branch.initialize("branch") |
|
1159
by Martin Pool
- clean up parameters to smart_add and smart_add_branch |
41 |
smart_add(("branch",)) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
42 |
for path in paths: |
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
43 |
self.assertNotEqual(branch.working_tree().path2id(path), None) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
44 |
|
45 |
def test_add_above_tree_preserves_tree(self): |
|
46 |
"""Test nested trees are not affect by an add above them.""" |
|
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
47 |
from bzrlib.add import smart_add |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
48 |
paths = ("original/", "original/file1", "original/file2") |
|
1143
by Martin Pool
- remove dead code and remove some small errors (pychecker) |
49 |
child_paths = ("path",) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
50 |
full_child_paths = ("original/child", "original/child/path") |
51 |
build_paths = ("original/", "original/file1", "original/file2", |
|
52 |
"original/child/", "original/child/path") |
|
|
1143
by Martin Pool
- remove dead code and remove some small errors (pychecker) |
53 |
|
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
54 |
self.build_tree(build_paths) |
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
55 |
branch = Branch.initialize(u".") |
|
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
56 |
child_branch = Branch.initialize("original/child") |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
57 |
smart_add((u".",)) |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
58 |
for path in paths: |
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
59 |
self.assertNotEqual((path, branch.working_tree().path2id(path)), |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
60 |
(path, None)) |
61 |
for path in full_child_paths: |
|
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
62 |
self.assertEqual((path, branch.working_tree().path2id(path)), |
|
1092.1.27
by Robert Collins
two bugfixes to smart_add - do not add paths from nested trees to the parent tree, and do not mutate the user supplied file list |
63 |
(path, None)) |
64 |
for path in child_paths: |
|
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
65 |
self.assertEqual(child_branch.working_tree().path2id(path), None) |
|
1092.1.28
by Robert Collins
test adding lists of paths |
66 |
|
67 |
def test_add_paths(self): |
|
68 |
"""Test smart-adding a list of paths.""" |
|
69 |
from bzrlib.add import smart_add |
|
70 |
paths = ("file1", "file2") |
|
71 |
self.build_tree(paths) |
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
72 |
branch = Branch.initialize(u".") |
|
1159
by Martin Pool
- clean up parameters to smart_add and smart_add_branch |
73 |
smart_add(paths) |
|
1092.1.28
by Robert Collins
test adding lists of paths |
74 |
for path in paths: |
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
75 |
self.assertNotEqual(branch.working_tree().path2id(path), None) |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
76 |
|
77 |
def test_add_dry_run(self): |
|
78 |
"""Test a dry run add, make sure nothing is added.""" |
|
79 |
from bzrlib.commands import run_bzr |
|
80 |
eq = self.assertEqual |
|
81 |
b = Branch.initialize(u'.') |
|
82 |
t = b.working_tree() |
|
83 |
self.build_tree(['inertiatic/', 'inertiatic/esp']) |
|
84 |
eq(list(t.unknowns()), ['inertiatic']) |
|
85 |
self.capture('add --dry-run .') |
|
86 |
eq(list(t.unknowns()), ['inertiatic']) |
|
87 |
||
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
88 |
class TestSmartAddBranch(TestCaseInTempDir): |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
89 |
"""Test smart adds with a specified branch.""" |
90 |
||
91 |
def test_add_dot_from_root(self): |
|
92 |
"""Test adding . from the root of the tree.""" |
|
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
93 |
from bzrlib.add import smart_add_tree |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
94 |
paths = ("original/", "original/file1", "original/file2") |
95 |
self.build_tree(paths) |
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
96 |
Branch.initialize(u".") |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
97 |
tree = WorkingTree() |
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
98 |
smart_add_tree(tree, (u".",)) |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
99 |
for path in paths: |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
100 |
self.assertNotEqual(tree.path2id(path), None) |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
101 |
|
102 |
def test_add_dot_from_subdir(self): |
|
103 |
"""Test adding . from a subdir of the tree.""" |
|
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
104 |
from bzrlib.add import smart_add_tree |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
105 |
paths = ("original/", "original/file1", "original/file2") |
106 |
self.build_tree(paths) |
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
107 |
Branch.initialize(u".") |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
108 |
tree = WorkingTree() |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
109 |
os.chdir("original") |
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
110 |
smart_add_tree(tree, (u".",)) |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
111 |
for path in paths: |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
112 |
self.assertNotEqual(tree.path2id(path), None) |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
113 |
|
114 |
def test_add_tree_from_above_tree(self): |
|
115 |
"""Test adding a tree from above the tree.""" |
|
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
116 |
from bzrlib.add import smart_add_tree |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
117 |
paths = ("original/", "original/file1", "original/file2") |
118 |
branch_paths = ("branch/", "branch/original/", "branch/original/file1", |
|
119 |
"branch/original/file2") |
|
120 |
self.build_tree(branch_paths) |
|
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
121 |
Branch.initialize("branch") |
122 |
tree = WorkingTree("branch") |
|
123 |
smart_add_tree(tree, ("branch",)) |
|
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
124 |
for path in paths: |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
125 |
self.assertNotEqual(tree.path2id(path), None) |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
126 |
|
127 |
def test_add_above_tree_preserves_tree(self): |
|
128 |
"""Test nested trees are not affect by an add above them.""" |
|
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
129 |
from bzrlib.add import smart_add_tree |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
130 |
paths = ("original/", "original/file1", "original/file2") |
131 |
child_paths = ("path") |
|
132 |
full_child_paths = ("original/child", "original/child/path") |
|
133 |
build_paths = ("original/", "original/file1", "original/file2", |
|
134 |
"original/child/", "original/child/path") |
|
135 |
self.build_tree(build_paths) |
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
136 |
Branch.initialize(u".") |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
137 |
tree = WorkingTree() |
|
1185.11.5
by John Arbash Meinel
Merged up-to-date against mainline, still broken. |
138 |
child_branch = Branch.initialize("original/child") |
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
139 |
smart_add_tree(tree, (u".",)) |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
140 |
for path in paths: |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
141 |
self.assertNotEqual((path, tree.path2id(path)), |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
142 |
(path, None)) |
143 |
for path in full_child_paths: |
|
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
144 |
self.assertEqual((path, tree.path2id(path)), |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
145 |
(path, None)) |
146 |
for path in child_paths: |
|
|
1497
by Robert Collins
Move Branch.read_working_inventory to WorkingTree. |
147 |
self.assertEqual(child_branch.working_tree().path2id(path), None) |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
148 |
|
149 |
def test_add_paths(self): |
|
150 |
"""Test smart-adding a list of paths.""" |
|
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
151 |
from bzrlib.add import smart_add_tree |
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
152 |
paths = ("file1", "file2") |
153 |
self.build_tree(paths) |
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
154 |
Branch.initialize(u".") |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
155 |
tree = WorkingTree() |
156 |
smart_add_tree(tree, paths) |
|
|
1092.1.29
by Robert Collins
break smart_add into smart_add and smart_add_branch which will accept a branch parameter |
157 |
for path in paths: |
|
1508.1.10
by Robert Collins
bzrlib.add.smart_add_branch is now smart_add_tree. (Robert Collins) |
158 |
self.assertNotEqual(tree.path2id(path), None) |
|
1092.1.30
by Robert Collins
change smart_add reporting of added files to callback with the entry, and change the inventory.add signature to return the added entry |
159 |
|
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
160 |
class TestAddActions(TestCaseInTempDir): |
161 |
||
162 |
def test_null(self): |
|
163 |
from bzrlib.add import add_action_null |
|
164 |
self.run_action(add_action_null, "", False) |
|
165 |
||
166 |
def test_add(self): |
|
|
1399.1.10
by Robert Collins
remove kind from the InventoryEntry constructor - only child classes should be created now |
167 |
self.entry = InventoryFile("id", "name", None) |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
168 |
from bzrlib.add import add_action_add |
169 |
self.run_action(add_action_add, "", True) |
|
170 |
||
171 |
def test_add_and_print(self): |
|
172 |
from bzrlib.add import add_action_add_and_print |
|
173 |
self.run_action(add_action_add_and_print, "added path\n", True) |
|
174 |
||
175 |
def test_print(self): |
|
176 |
from bzrlib.add import add_action_print |
|
177 |
self.run_action(add_action_print, "added path\n", False) |
|
178 |
||
179 |
def run_action(self, action, output, should_add): |
|
|
1092.1.30
by Robert Collins
change smart_add reporting of added files to callback with the entry, and change the inventory.add signature to return the added entry |
180 |
from StringIO import StringIO |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
181 |
inv = Inventory() |
|
1092.1.30
by Robert Collins
change smart_add reporting of added files to callback with the entry, and change the inventory.add signature to return the added entry |
182 |
stdout = StringIO() |
|
1185.53.2
by Michael Ellerman
Add tests for bzr add --dry-run |
183 |
|
184 |
self.apply_redirected(None, stdout, None, action, inv, 'path', 'file') |
|
185 |
self.assertEqual(stdout.getvalue(), output) |
|
186 |
||
187 |
if should_add: |
|
188 |
self.assertNotEqual(inv.path2id('path'), None) |
|
189 |
else: |
|
190 |
self.assertEqual(inv.path2id('path'), None) |