80
81
def test_add_dot_from_root(self):
81
82
"""Test adding . from the root of the tree."""
82
from bzrlib.add import smart_add_branch
83
from bzrlib.add import smart_add_tree
83
84
paths = ("original/", "original/file1", "original/file2")
84
85
self.build_tree(paths)
85
branch = Branch.initialize(".")
86
smart_add_branch(branch, (".",))
86
Branch.initialize(u".")
88
smart_add_tree(tree, (u".",))
88
self.assertNotEqual(branch.working_tree().path2id(path), None)
90
self.assertNotEqual(tree.path2id(path), None)
90
92
def test_add_dot_from_subdir(self):
91
93
"""Test adding . from a subdir of the tree."""
92
from bzrlib.add import smart_add_branch
94
from bzrlib.add import smart_add_tree
93
95
paths = ("original/", "original/file1", "original/file2")
94
96
self.build_tree(paths)
95
branch = Branch.initialize(".")
97
Branch.initialize(u".")
96
99
os.chdir("original")
97
smart_add_branch(branch, (".",))
100
smart_add_tree(tree, (u".",))
98
101
for path in paths:
99
self.assertNotEqual(branch.working_tree().path2id(path), None)
102
self.assertNotEqual(tree.path2id(path), None)
101
104
def test_add_tree_from_above_tree(self):
102
105
"""Test adding a tree from above the tree."""
103
from bzrlib.add import smart_add_branch
106
from bzrlib.add import smart_add_tree
104
107
paths = ("original/", "original/file1", "original/file2")
105
108
branch_paths = ("branch/", "branch/original/", "branch/original/file1",
106
109
"branch/original/file2")
107
110
self.build_tree(branch_paths)
108
branch = Branch.initialize("branch")
109
smart_add_branch(branch, ("branch",))
111
Branch.initialize("branch")
112
tree = WorkingTree("branch")
113
smart_add_tree(tree, ("branch",))
110
114
for path in paths:
111
self.assertNotEqual(branch.working_tree().path2id(path), None)
115
self.assertNotEqual(tree.path2id(path), None)
113
117
def test_add_above_tree_preserves_tree(self):
114
118
"""Test nested trees are not affect by an add above them."""
115
from bzrlib.add import smart_add_branch
119
from bzrlib.add import smart_add_tree
116
120
paths = ("original/", "original/file1", "original/file2")
117
121
child_paths = ("path")
118
122
full_child_paths = ("original/child", "original/child/path")
119
123
build_paths = ("original/", "original/file1", "original/file2",
120
124
"original/child/", "original/child/path")
121
125
self.build_tree(build_paths)
122
branch = Branch.initialize(".")
126
Branch.initialize(u".")
123
128
child_branch = Branch.initialize("original/child")
124
smart_add_branch(branch, (".",))
129
smart_add_tree(tree, (u".",))
125
130
for path in paths:
126
self.assertNotEqual((path, branch.working_tree().path2id(path)),
131
self.assertNotEqual((path, tree.path2id(path)),
128
133
for path in full_child_paths:
129
self.assertEqual((path, branch.working_tree().path2id(path)),
134
self.assertEqual((path, tree.path2id(path)),
131
136
for path in child_paths:
132
137
self.assertEqual(child_branch.working_tree().path2id(path), None)
134
139
def test_add_paths(self):
135
140
"""Test smart-adding a list of paths."""
136
from bzrlib.add import smart_add_branch
141
from bzrlib.add import smart_add_tree
137
142
paths = ("file1", "file2")
138
143
self.build_tree(paths)
139
branch = Branch.initialize(".")
140
smart_add_branch(branch, paths)
144
Branch.initialize(u".")
146
smart_add_tree(tree, paths)
141
147
for path in paths:
142
self.assertNotEqual(branch.working_tree().path2id(path), None)
148
self.assertNotEqual(tree.path2id(path), None)
144
150
class TestAddCallbacks(TestCaseInTempDir):