~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_add.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-07-11 02:46:35 UTC
  • mfrom: (6017.1.2 test-isolation-speed)
  • Revision ID: pqm@pqm.ubuntu.com-20110711024635-f39c8kz23s347m1t
(spiv) Speed up TestCaseWithMemoryTransport._check_safety_net by reading the
 dirstate file directly rather than using WorkingTree.open(). (Andrew
 Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
2
2
#
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
24
24
    tests,
25
25
    )
26
26
from bzrlib.tests import (
27
 
    features,
28
27
    script,
29
28
    )
30
29
from bzrlib.tests.scenarios import load_tests_apply_scenarios
94
93
        self.run_bzr('add inertiatic/../cicatriz/esp')
95
94
        self.assertEquals(self.run_bzr('unknowns')[0], '')
96
95
 
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')
103
 
 
104
96
    def test_add_in_versioned(self):
105
97
        """Try to add a file in a versioned directory.
106
98
 
116
108
 
117
109
    def test_subdir_add(self):
118
110
        """Add in subdirectory should add only things from there down"""
 
111
        from bzrlib.workingtree import WorkingTree
 
112
 
119
113
        eq = self.assertEqual
120
114
        ass = self.assertTrue
121
115
 
159
153
        new_tree = self.make_branch_and_tree('new')
160
154
        self.build_tree(['new/a', 'new/b/', 'new/b/c', 'd'])
161
155
 
162
 
        out, err = self.run_bzr('add --file-ids-from ../base',
163
 
                                working_dir='new')
 
156
        os.chdir('new')
 
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'])
182
176
 
183
 
        out, err = self.run_bzr('add --file-ids-from ../base/b',
184
 
                                working_dir='new')
 
177
        os.chdir('new')
 
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',
188
182
                             out)
189
183
 
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'))
193
187
 
211
205
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
212
206
 
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')
220
214
 
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]
238
232
 
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, "")
247
 
 
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)