1
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
94
93
self.run_bzr('add inertiatic/../cicatriz/esp')
95
94
self.assertEquals(self.run_bzr('unknowns')[0], '')
97
def test_add_no_recurse(self):
98
tree = self.make_branch_and_tree('.')
99
self.build_tree(['inertiatic/', 'inertiatic/esp'])
100
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n')
101
self.run_bzr('add -N inertiatic')
102
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic/esp\n')
104
96
def test_add_in_versioned(self):
105
97
"""Try to add a file in a versioned directory.
159
153
new_tree = self.make_branch_and_tree('new')
160
154
self.build_tree(['new/a', 'new/b/', 'new/b/c', 'd'])
162
out, err = self.run_bzr('add --file-ids-from ../base',
157
out, err = self.run_bzr('add --file-ids-from ../base')
164
158
self.assertEqual('', err)
165
159
self.assertEqualDiff('adding a w/ file id from a\n'
166
160
'adding b w/ file id from b\n'
180
174
new_tree = self.make_branch_and_tree('new')
181
175
self.build_tree(['new/c', 'new/d'])
183
out, err = self.run_bzr('add --file-ids-from ../base/b',
178
out, err = self.run_bzr('add --file-ids-from ../base/b')
185
179
self.assertEqual('', err)
186
180
self.assertEqualDiff('adding c w/ file id from b/c\n'
187
181
'adding d w/ file id from b/d\n',
190
new_tree = new_tree.bzrdir.open_workingtree('new')
184
new_tree = new_tree.bzrdir.open_workingtree()
191
185
self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('c'))
192
186
self.assertEqual(base_tree.path2id('b/d'), new_tree.path2id('d'))
211
205
self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
213
207
def test_add_via_symlink(self):
214
self.requireFeature(features.SymlinkFeature)
208
self.requireFeature(tests.SymlinkFeature)
215
209
self.make_branch_and_tree('source')
216
210
self.build_tree(['source/top.txt'])
217
211
os.symlink('source', 'link')
219
213
self.assertEquals(out, 'adding top.txt\n')
221
215
def test_add_symlink_to_abspath(self):
222
self.requireFeature(features.SymlinkFeature)
216
self.requireFeature(tests.SymlinkFeature)
223
217
self.make_branch_and_tree('tree')
224
218
os.symlink(osutils.abspath('target'), 'tree/link')
225
219
out = self.run_bzr(['add', 'tree/link'])[0]
239
233
def test_add_multiple_files_in_unicode_cwd(self):
240
234
"""Adding multiple files in a non-ascii cwd, see lp:686611"""
241
self.requireFeature(features.UnicodeFilenameFeature)
235
self.requireFeature(tests.UnicodeFilename)
242
236
self.make_branch_and_tree(u"\xA7")
243
237
self.build_tree([u"\xA7/a", u"\xA7/b"])
244
238
out, err = self.run_bzr(["add", "a", "b"], working_dir=u"\xA7")
245
239
self.assertEquals(out, "adding a\n" "adding b\n")
246
240
self.assertEquals(err, "")
248
def test_add_skip_large_files(self):
249
"""Test skipping files larger than add.maximum_file_size"""
250
tree = self.make_branch_and_tree('.')
251
self.build_tree(['small.txt', 'big.txt', 'big2.txt'])
252
self.build_tree_contents([('small.txt', '0\n')])
253
self.build_tree_contents([('big.txt', '01234567890123456789\n')])
254
self.build_tree_contents([('big2.txt', '01234567890123456789\n')])
255
tree.branch.get_config_stack().set('add.maximum_file_size', 5)
256
out = self.run_bzr('add')[0]
257
results = sorted(out.rstrip('\n').split('\n'))
258
self.assertEquals(['adding small.txt'], results)
259
# named items never skipped, even if over max
260
out, err = self.run_bzr(["add", "big2.txt"])
261
results = sorted(out.rstrip('\n').split('\n'))
262
self.assertEquals(['adding big2.txt'], results)
263
self.assertEquals("", err)
264
tree.branch.get_config_stack().set('add.maximum_file_size', 30)
265
out = self.run_bzr('add')[0]
266
results = sorted(out.rstrip('\n').split('\n'))
267
self.assertEquals(['adding big.txt'], results)