bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2007, 2009-2012, 2016 Canonical Ltd
|
|
2255.2.62
by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
2255.2.62
by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly |
16 |
|
17 |
"""Test that we can use smart_add on all Tree implementations."""
|
|
18 |
||
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
19 |
from io import StringIO |
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
20 |
import os |
|
4789.11.1
by John Arbash Meinel
Skip the assertFilenameSkipped tests on Windows. |
21 |
import sys |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
22 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
23 |
from ... import ( |
|
7141.3.2
by Jelmer Vernooij
add some tests. |
24 |
add as _mod_add, |
|
2255.2.62
by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly |
25 |
errors, |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
26 |
ignores, |
27 |
osutils, |
|
|
2568.2.10
by Robert Collins
And a missing import. |
28 |
tests, |
|
6123.10.1
by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped. |
29 |
trace, |
|
6851.1.1
by Jelmer Vernooij
More foreign branch fixes. |
30 |
workingtree, |
|
2255.2.62
by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly |
31 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
32 |
from .. import ( |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
33 |
features, |
34 |
per_workingtree, |
|
|
5013.2.2
by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py. |
35 |
test_smart_add, |
|
2255.7.92
by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract. |
36 |
)
|
|
5013.2.2
by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py. |
37 |
|
38 |
||
|
7141.3.2
by Jelmer Vernooij
add some tests. |
39 |
class RecordingAddAction(_mod_add.AddAction): |
40 |
||
41 |
def __init__(self): |
|
42 |
self.adds = [] |
|
43 |
||
44 |
def __call__(self, wt, parent_ie, path, kind): |
|
45 |
self.adds.append((wt, path, kind)) |
|
46 |
||
47 |
||
|
5013.2.2
by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py. |
48 |
class TestSmartAddTree(per_workingtree.TestCaseWithWorkingTree): |
|
2255.2.62
by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly |
49 |
|
50 |
def test_single_file(self): |
|
51 |
tree = self.make_branch_and_tree('tree') |
|
52 |
self.build_tree(['tree/a']) |
|
|
7141.3.2
by Jelmer Vernooij
add some tests. |
53 |
action = RecordingAddAction() |
54 |
tree.smart_add(['tree'], action=action) |
|
|
2255.2.62
by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly |
55 |
|
|
7141.3.2
by Jelmer Vernooij
add some tests. |
56 |
with tree.lock_read(): |
|
7143.19.5
by Jelmer Vernooij
Undo removal of kind. |
57 |
files = [(path, status, kind) |
|
7143.19.7
by Jelmer Vernooij
merge trunk |
58 |
for path, status, kind, parent_id |
|
7143.16.9
by Jelmer Vernooij
Fix E127 |
59 |
in tree.list_files(include_root=True)] |
|
2255.2.62
by John Arbash Meinel
add a workingtree_implementations test that makes sure smart_add_tree orks properly |
60 |
self.assertEqual([('', 'V', 'directory'), ('a', 'V', 'file')], |
61 |
files) |
|
|
7141.3.2
by Jelmer Vernooij
add some tests. |
62 |
self.assertEqual([(tree, 'a', 'file')], action.adds) |
|
2255.7.92
by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract. |
63 |
|
|
4634.55.1
by Robert Collins
Do not add files whose name contains new lines or carriage returns |
64 |
def assertFilenameSkipped(self, filename): |
65 |
tree = self.make_branch_and_tree('tree') |
|
|
4789.11.1
by John Arbash Meinel
Skip the assertFilenameSkipped tests on Windows. |
66 |
try: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
67 |
self.build_tree(['tree/' + filename]) |
|
4789.11.1
by John Arbash Meinel
Skip the assertFilenameSkipped tests on Windows. |
68 |
except errors.NoSuchFile: |
69 |
if sys.platform == 'win32': |
|
70 |
raise tests.TestNotApplicable('Cannot create files named %r on' |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
71 |
' win32' % (filename,)) |
|
4634.55.1
by Robert Collins
Do not add files whose name contains new lines or carriage returns |
72 |
tree.smart_add(['tree']) |
73 |
self.assertEqual(None, tree.path2id(filename)) |
|
74 |
||
75 |
def test_path_containing_newline_skips(self): |
|
76 |
self.assertFilenameSkipped('a\nb') |
|
77 |
||
78 |
def test_path_containing_carriagereturn_skips(self): |
|
79 |
self.assertFilenameSkipped('a\rb') |
|
80 |
||
|
2255.7.92
by Martin Pool
Test for smart_add(save=false) should be run against all WorkingTrees; adjust the test to more precisely cover the contract. |
81 |
def test_save_false(self): |
82 |
"""Dry-run add doesn't permanently affect the tree.""" |
|
83 |
wt = self.make_branch_and_tree('.') |
|
|
7141.3.2
by Jelmer Vernooij
add some tests. |
84 |
with wt.lock_write(): |
|
2585.1.1
by Aaron Bentley
Unify MutableTree.smart_add behavior by disabling quirky memory-only Inventory |
85 |
self.build_tree(['file']) |
86 |
wt.smart_add(['file'], save=False) |
|
87 |
# the file should not be added - no id.
|
|
88 |
self.assertEqual(wt.path2id('file'), None) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
89 |
# and the disk state should be the same - reopen to check.
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
90 |
wt = wt.controldir.open_workingtree() |
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
91 |
self.assertFalse(wt.is_versioned('file')) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
92 |
|
93 |
def test_add_dot_from_root(self): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
94 |
"""Test adding . from the root of the tree.""" |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
95 |
paths = ("original/", "original/file1", "original/file2") |
96 |
self.build_tree(paths) |
|
97 |
wt = self.make_branch_and_tree('.') |
|
|
7141.3.2
by Jelmer Vernooij
add some tests. |
98 |
action = RecordingAddAction() |
99 |
wt.smart_add((u".",), action=action) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
100 |
for path in paths: |
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
101 |
self.assertTrue(wt.is_versioned(path)) |
|
7141.3.2
by Jelmer Vernooij
add some tests. |
102 |
if wt.has_versioned_directories(): |
103 |
self.assertEqual( |
|
104 |
{(wt, 'original', 'directory'), |
|
105 |
(wt, 'original/file1', 'file'), |
|
106 |
(wt, 'original/file2', 'file')}, |
|
107 |
set(action.adds)) |
|
108 |
else: |
|
109 |
self.assertEqual( |
|
110 |
{(wt, 'original/file1', 'file'), |
|
111 |
(wt, 'original/file2', 'file')}, |
|
112 |
set(action.adds)) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
113 |
|
|
6123.10.1
by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped. |
114 |
def test_skip_nested_trees(self): |
115 |
"""Test smart-adding a nested tree ignors it and warns.""" |
|
116 |
wt = self.make_branch_and_tree('.') |
|
117 |
nested_wt = self.make_branch_and_tree('nested') |
|
118 |
warnings = [] |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
119 |
|
|
6123.10.1
by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped. |
120 |
def warning(*args): |
121 |
warnings.append(args[0] % args[1:]) |
|
122 |
self.overrideAttr(trace, 'warning', warning) |
|
123 |
wt.smart_add((u".",)) |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
124 |
self.assertFalse(wt.is_versioned("nested")) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
125 |
self.assertEqual( |
|
6123.10.1
by Jelmer Vernooij
"bzr add" warns about nested trees that are skipped. |
126 |
['skipping nested tree %r' % nested_wt.basedir], warnings) |
127 |
||
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
128 |
def test_add_dot_from_subdir(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
129 |
"""Test adding . from a subdir of the tree.""" |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
130 |
paths = ("original/", "original/file1", "original/file2") |
131 |
self.build_tree(paths) |
|
132 |
wt = self.make_branch_and_tree('.') |
|
133 |
wt.smart_add((u".",)) |
|
134 |
for path in paths: |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
135 |
self.assertTrue(wt.is_versioned(path)) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
136 |
|
137 |
def test_add_tree_from_above_tree(self): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
138 |
"""Test adding a tree from above the tree.""" |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
139 |
paths = ("original/", "original/file1", "original/file2") |
140 |
branch_paths = ("branch/", "branch/original/", "branch/original/file1", |
|
141 |
"branch/original/file2") |
|
142 |
self.build_tree(branch_paths) |
|
143 |
wt = self.make_branch_and_tree('branch') |
|
144 |
wt.smart_add(("branch",)) |
|
145 |
for path in paths: |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
146 |
self.assertTrue(wt.is_versioned(path)) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
147 |
|
148 |
def test_add_above_tree_preserves_tree(self): |
|
149 |
"""Test nested trees are not affect by an add above them.""" |
|
150 |
paths = ("original/", "original/file1", "original/file2") |
|
151 |
child_paths = ("path",) |
|
152 |
full_child_paths = ("original/child", "original/child/path") |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
153 |
build_paths = ("original/", "original/file1", "original/file2", |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
154 |
"original/child/", "original/child/path") |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
155 |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
156 |
self.build_tree(build_paths) |
157 |
wt = self.make_branch_and_tree('.') |
|
|
6874.1.2
by Jelmer Vernooij
Consistently use Branch.user_url. |
158 |
if wt.controldir.user_url != wt.branch.controldir.user_url: |
|
6437.70.6
by John Arbash Meinel
Fix a couple tests that wanted to directly create a wt where the branch was. |
159 |
# Lightweight checkout, make sure we have a repo location.
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
160 |
wt.branch.controldir.root_transport.mkdir('original') |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
161 |
child_tree = self.make_branch_and_tree('original/child') |
162 |
wt.smart_add((".",)) |
|
163 |
for path in paths: |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
164 |
self.assertNotEqual((path, wt.is_versioned(path)), |
165 |
(path, False)) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
166 |
for path in full_child_paths: |
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
167 |
self.assertEqual((path, wt.is_versioned(path)), |
168 |
(path, False)) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
169 |
for path in child_paths: |
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
170 |
self.assertFalse(child_tree.is_versioned(path)) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
171 |
|
172 |
def test_add_paths(self): |
|
173 |
"""Test smart-adding a list of paths.""" |
|
174 |
paths = ("file1", "file2") |
|
175 |
self.build_tree(paths) |
|
176 |
wt = self.make_branch_and_tree('.') |
|
177 |
wt.smart_add(paths) |
|
178 |
for path in paths: |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
179 |
self.assertTrue(wt.is_versioned(path)) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
180 |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
181 |
def test_add_ignored_nested_paths(self): |
182 |
"""Test smart-adding a list of paths which includes ignored ones.""" |
|
183 |
wt = self.make_branch_and_tree('.') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
184 |
tree_shape = ("adir/", "adir/CVS/", |
185 |
"adir/CVS/afile", "adir/CVS/afile2") |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
186 |
add_paths = ("adir/CVS", "adir/CVS/afile", "adir") |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
187 |
expected_paths = ("adir", "adir/CVS", |
188 |
"adir/CVS/afile", "adir/CVS/afile2") |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
189 |
self.build_tree(tree_shape) |
190 |
wt.smart_add(add_paths) |
|
191 |
for path in expected_paths: |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
192 |
self.assertTrue(wt.is_versioned(path), "No id added for %s" % path) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
193 |
|
194 |
def test_add_non_existant(self): |
|
195 |
"""Test smart-adding a file that does not exist.""" |
|
196 |
wt = self.make_branch_and_tree('.') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
197 |
self.assertRaises(errors.NoSuchFile, wt.smart_add, |
198 |
['non-existant-file']) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
199 |
|
200 |
def test_returns_and_ignores(self): |
|
201 |
"""Correctly returns added/ignored files""" |
|
202 |
wt = self.make_branch_and_tree('.') |
|
203 |
# The default ignore list includes '*.py[co]', but not CVS
|
|
204 |
ignores._set_user_ignores(['*.py[co]']) |
|
205 |
self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
206 |
'inertiatic/foo.pyc']) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
207 |
added, ignored = wt.smart_add(u'.') |
|
6861.1.1
by Jelmer Vernooij
More foreign branch test fixes. |
208 |
if wt.has_versioned_directories(): |
209 |
self.assertSubset(('inertiatic', 'inertiatic/esp', 'inertiatic/CVS'), |
|
210 |
added) |
|
211 |
else: |
|
212 |
self.assertSubset(('inertiatic/esp', 'inertiatic/CVS'), |
|
213 |
added) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
214 |
self.assertSubset(('*.py[co]',), ignored) |
215 |
self.assertSubset(('inertiatic/foo.pyc',), ignored['*.py[co]']) |
|
216 |
||
217 |
def test_add_multiple_dirs(self): |
|
218 |
"""Test smart adding multiple directories at once.""" |
|
219 |
added_paths = ['file1', 'file2', |
|
220 |
'dir1/', 'dir1/file3', |
|
221 |
'dir1/subdir2/', 'dir1/subdir2/file4', |
|
222 |
'dir2/', 'dir2/file5', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
223 |
]
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
224 |
not_added = ['file6', 'dir3/', 'dir3/file7', 'dir3/file8'] |
225 |
self.build_tree(added_paths) |
|
226 |
self.build_tree(not_added) |
|
227 |
||
228 |
wt = self.make_branch_and_tree('.') |
|
229 |
wt.smart_add(['file1', 'file2', 'dir1', 'dir2']) |
|
230 |
||
231 |
for path in added_paths: |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
232 |
self.assertTrue(wt.is_versioned(path.rstrip('/')), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
233 |
'Failed to add path: %s' % (path,)) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
234 |
for path in not_added: |
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
235 |
self.assertFalse(wt.is_versioned(path.rstrip('/')), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
236 |
'Accidentally added path: %s' % (path,)) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
237 |
|
|
4163.2.1
by Ian Clatworthy
Fix add in trees supports views |
238 |
def test_add_file_in_unknown_dir(self): |
239 |
# Test that parent directory addition is implicit
|
|
240 |
tree = self.make_branch_and_tree('.') |
|
241 |
self.build_tree(['dir/', 'dir/subdir/', 'dir/subdir/foo']) |
|
242 |
tree.smart_add(['dir/subdir/foo']) |
|
243 |
tree.lock_read() |
|
244 |
self.addCleanup(tree.unlock) |
|
245 |
self.assertEqual(['', 'dir', 'dir/subdir', 'dir/subdir/foo'], |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
246 |
[path for path, ie in tree.iter_entries_by_dir()]) |
|
4163.2.1
by Ian Clatworthy
Fix add in trees supports views |
247 |
|
|
5504.6.2
by Martin
If a dir being added used to be something else detect and correct |
248 |
def test_add_dir_bug_251864(self): |
|
5504.6.3
by Martin
Address poolie's review, mention both bugs in test and add news |
249 |
"""Added file turning into a dir should be detected on add dir |
250 |
||
251 |
Similar to bug 205636 but with automatic adding of directory contents.
|
|
252 |
"""
|
|
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
253 |
tree = self.make_branch_and_tree(".") |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
254 |
self.build_tree(["dir"]) # whoops, make a file called dir |
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
255 |
tree.smart_add(["dir"]) |
256 |
os.remove("dir") |
|
257 |
self.build_tree(["dir/", "dir/file"]) |
|
|
5504.6.2
by Martin
If a dir being added used to be something else detect and correct |
258 |
tree.smart_add(["dir"]) |
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
259 |
tree.commit("Add dir contents") |
|
5378.1.4
by Martin
Assert state of the tree after add and commit in new tests |
260 |
self.addCleanup(tree.lock_read().unlock) |
261 |
self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")], |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
262 |
[(t[0], t[2]) for t in tree.list_files()]) |
|
5378.1.4
by Martin
Assert state of the tree after add and commit in new tests |
263 |
self.assertFalse(list(tree.iter_changes(tree.basis_tree()))) |
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
264 |
|
265 |
def test_add_subdir_file_bug_205636(self): |
|
266 |
"""Added file turning into a dir should be detected on add dir/file""" |
|
267 |
tree = self.make_branch_and_tree(".") |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
268 |
self.build_tree(["dir"]) # whoops, make a file called dir |
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
269 |
tree.smart_add(["dir"]) |
270 |
os.remove("dir") |
|
271 |
self.build_tree(["dir/", "dir/file"]) |
|
|
5378.1.3
by Martin
Note that TestSmartAddTree.test_add_subdir_file_bug_205636 now passes |
272 |
tree.smart_add(["dir/file"]) |
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
273 |
tree.commit("Add file in dir") |
|
5378.1.4
by Martin
Assert state of the tree after add and commit in new tests |
274 |
self.addCleanup(tree.lock_read().unlock) |
275 |
self.assertEqual([(u"dir", "directory"), (u"dir/file", "file")], |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
276 |
[(t[0], t[2]) for t in tree.list_files()]) |
|
5378.1.4
by Martin
Assert state of the tree after add and commit in new tests |
277 |
self.assertFalse(list(tree.iter_changes(tree.basis_tree()))) |
|
5378.1.1
by Martin
Add per_workingtree tests in add and smart_add for bug 205636 |
278 |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
279 |
def test_custom_ids(self): |
|
7045.4.3
by Jelmer Vernooij
Fix test_custom_ids tests. |
280 |
sio = StringIO() |
|
5013.2.2
by Vincent Ladeuil
Fix imports in per_workingtree/test_smart_add.py. |
281 |
action = test_smart_add.AddCustomIDAction(to_file=sio, |
282 |
should_print=True) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
283 |
self.build_tree(['file1', 'dir1/', 'dir1/file2']) |
284 |
||
285 |
wt = self.make_branch_and_tree('.') |
|
|
6851.1.1
by Jelmer Vernooij
More foreign branch fixes. |
286 |
if not wt._format.supports_setting_file_ids: |
287 |
self.assertRaises( |
|
288 |
workingtree.SettingFileIdUnsupported, |
|
289 |
wt.smart_add, ['.'], action=action) |
|
290 |
return
|
|
291 |
||
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
292 |
wt.smart_add(['.'], action=action) |
293 |
# The order of adds is not strictly fixed:
|
|
294 |
sio.seek(0) |
|
295 |
lines = sorted(sio.readlines()) |
|
|
6851.1.1
by Jelmer Vernooij
More foreign branch fixes. |
296 |
self.assertEqual(['added dir1 with id directory-dir1\n', |
297 |
'added dir1/file2 with id file-dir1%file2\n', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
298 |
'added file1 with id file-file1\n', ], lines) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
299 |
wt.lock_read() |
300 |
self.addCleanup(wt.unlock) |
|
301 |
self.assertEqual([('', wt.path2id('')), |
|
|
7045.4.3
by Jelmer Vernooij
Fix test_custom_ids tests. |
302 |
('dir1', b'directory-dir1'), |
303 |
('file1', b'file-file1'), |
|
304 |
('dir1/file2', b'file-dir1%file2'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
305 |
], [(path, ie.file_id) for path, ie |
306 |
in wt.iter_entries_by_dir()]) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
307 |
|
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
308 |
|
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
309 |
class TestSmartAddConflictRelatedFiles(per_workingtree.TestCaseWithWorkingTree): |
310 |
||
311 |
def make_tree_with_text_conflict(self): |
|
312 |
tb = self.make_branch_and_tree('base') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
313 |
self.build_tree_contents([('base/file', b'content in base')]) |
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
314 |
tb.add('file') |
315 |
tb.commit('Adding file') |
|
316 |
||
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
317 |
t1 = tb.controldir.sprout('t1').open_workingtree() |
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
318 |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
319 |
self.build_tree_contents([('base/file', b'content changed in base')]) |
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
320 |
tb.commit('Changing file in base') |
321 |
||
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
322 |
self.build_tree_contents([('t1/file', b'content in t1')]) |
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
323 |
t1.commit('Changing file in t1') |
324 |
t1.merge_from_branch(tb.branch) |
|
|
7490.133.20
by Jelmer Vernooij
Some more test fixes. |
325 |
fnames = ['file.%s' % s for s in ('BASE', 'THIS', 'OTHER')] |
326 |
for fn in fnames: |
|
327 |
self.assertPathExists(os.path.join(t1.basedir, fn)) |
|
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
328 |
return t1 |
329 |
||
330 |
def test_cant_add_generated_files_implicitly(self): |
|
331 |
t = self.make_tree_with_text_conflict() |
|
332 |
added, ignored = t.smart_add([t.basedir]) |
|
333 |
self.assertEqual(([], {}), (added, ignored)) |
|
334 |
||
335 |
def test_can_add_generated_files_explicitly(self): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
336 |
fnames = ['file.%s' % s for s in ('BASE', 'THIS', 'OTHER')] |
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
337 |
t = self.make_tree_with_text_conflict() |
338 |
added, ignored = t.smart_add([t.basedir + '/%s' % f for f in fnames]) |
|
339 |
self.assertEqual((fnames, {}), (added, ignored)) |
|
340 |
||
341 |
||
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
342 |
class TestSmartAddTreeUnicode(per_workingtree.TestCaseWithWorkingTree): |
343 |
||
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
344 |
_test_needs_features = [features.UnicodeFilenameFeature] |
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
345 |
|
346 |
def setUp(self): |
|
347 |
super(TestSmartAddTreeUnicode, self).setUp() |
|
348 |
self.build_tree([u'a\u030a']) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
349 |
self.wt = self.make_branch_and_tree('.') |
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
350 |
self.overrideAttr(osutils, 'normalized_filename') |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
351 |
|
|
5868.1.4
by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode. |
352 |
def test_requires_normalized_unicode_filenames_fails_on_unnormalized(self): |
353 |
"""Adding unnormalized unicode filenames fail if and only if the |
|
354 |
workingtree format has the requires_normalized_unicode_filenames flag
|
|
|
5929.1.1
by Vincent Ladeuil
Fix spurious test failure on OSX for WorkingTreeFormat2 |
355 |
set and the underlying filesystem doesn't normalize.
|
|
5868.1.4
by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode. |
356 |
"""
|
357 |
osutils.normalized_filename = osutils._accessible_normalized_filename |
|
|
5929.1.1
by Vincent Ladeuil
Fix spurious test failure on OSX for WorkingTreeFormat2 |
358 |
if (self.workingtree_format.requires_normalized_unicode_filenames |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
359 |
and sys.platform != 'darwin'): |
|
5868.1.4
by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode. |
360 |
self.assertRaises( |
361 |
errors.NoSuchFile, self.wt.smart_add, [u'a\u030a']) |
|
362 |
else: |
|
363 |
self.wt.smart_add([u'a\u030a']) |
|
364 |
||
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
365 |
def test_accessible_explicit(self): |
366 |
osutils.normalized_filename = osutils._accessible_normalized_filename |
|
|
5582.10.29
by Jelmer Vernooij
Add requires_normalized_unicode_filenames |
367 |
if self.workingtree_format.requires_normalized_unicode_filenames: |
|
5868.1.4
by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode. |
368 |
raise tests.TestNotApplicable( |
369 |
'Working tree format smart_add requires normalized unicode '
|
|
370 |
'filenames') |
|
|
5868.1.1
by Martin
Turn two long-standing unexpected successes into skips |
371 |
self.wt.smart_add([u'a\u030a']) |
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
372 |
self.wt.lock_read() |
373 |
self.addCleanup(self.wt.unlock) |
|
374 |
self.assertEqual([('', 'directory'), (u'\xe5', 'file')], |
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
375 |
[(path, ie.kind) for path, ie in |
|
5807.1.8
by Jelmer Vernooij
Fix some tests. |
376 |
self.wt.iter_entries_by_dir()]) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
377 |
|
378 |
def test_accessible_implicit(self): |
|
379 |
osutils.normalized_filename = osutils._accessible_normalized_filename |
|
|
5582.10.29
by Jelmer Vernooij
Add requires_normalized_unicode_filenames |
380 |
if self.workingtree_format.requires_normalized_unicode_filenames: |
|
5868.1.4
by Andrew Bennetts
Tweak mgz's patch to preserve the test coverage of raising NoSuchFile if unnormalized unicode is passed to a wt format that requires normalized unicode. |
381 |
raise tests.TestNotApplicable( |
382 |
'Working tree format smart_add requires normalized unicode '
|
|
383 |
'filenames') |
|
|
5868.1.1
by Martin
Turn two long-standing unexpected successes into skips |
384 |
self.wt.smart_add([]) |
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
385 |
self.wt.lock_read() |
386 |
self.addCleanup(self.wt.unlock) |
|
387 |
self.assertEqual([('', 'directory'), (u'\xe5', 'file')], |
|
|
6809.1.1
by Martin
Apply 2to3 ws_comma fixer |
388 |
[(path, ie.kind) for path, ie |
|
5807.1.8
by Jelmer Vernooij
Fix some tests. |
389 |
in self.wt.iter_entries_by_dir()]) |
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
390 |
|
391 |
def test_inaccessible_explicit(self): |
|
392 |
osutils.normalized_filename = osutils._inaccessible_normalized_filename |
|
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
393 |
self.assertRaises(errors.InvalidNormalization, |
394 |
self.wt.smart_add, [u'a\u030a']) |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
395 |
|
396 |
def test_inaccessible_implicit(self): |
|
397 |
osutils.normalized_filename = osutils._inaccessible_normalized_filename |
|
|
5013.2.3
by Vincent Ladeuil
Simplify some tests in per_workingtree/test_smart_add.py. |
398 |
# TODO: jam 20060701 In the future, this should probably
|
399 |
# just ignore files that don't fit the normalization
|
|
400 |
# rules, rather than exploding
|
|
401 |
self.assertRaises(errors.InvalidNormalization, self.wt.smart_add, []) |