~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_add.py

  • Committer: Robert Collins
  • Date: 2007-05-07 16:48:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2485.
  • Revision ID: robertc@robertcollins.net-20070507164814-wpagonutf4b5cf8s
Move HACKING to docs/developers/HACKING and adjust Makefile to accomodate this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
    def test_add_dot_from_root(self):
37
37
        """Test adding . from the root of the tree.""" 
38
 
        from bzrlib.add import smart_add
39
38
        paths = ("original/", "original/file1", "original/file2")
40
39
        self.build_tree(paths)
41
40
        wt = self.make_branch_and_tree('.')
109
108
        for path in expected_paths:
110
109
            self.assertNotEqual(wt.path2id(path), None, "No id added for %s" % path)
111
110
 
112
 
    def test_save_false(self):
113
 
        """Test smart-adding a path with save set to false."""
114
 
        wt = self.make_branch_and_tree('.')
115
 
        self.build_tree(['file'])
116
 
        smart_add_tree(wt, ['file'], save=False)
117
 
        self.assertNotEqual(wt.path2id('file'), None, "No id added for 'file'")
118
 
        wt.read_working_inventory()
119
 
        self.assertEqual(wt.path2id('file'), None)
120
 
 
121
111
    def test_add_dry_run(self):
122
112
        """Test a dry run add, make sure nothing is added."""
123
113
        from bzrlib.commands import run_bzr
154
144
    def __call__(self, inv, parent_ie, path, kind):
155
145
        # The first part just logs if appropriate
156
146
        # Now generate a custom id
157
 
        file_id = kind + '-' + path.raw_path.replace('/', '%')
 
147
        file_id = osutils.safe_file_id(kind + '-'
 
148
                                       + path.raw_path.replace('/', '%'),
 
149
                                       warn=False)
158
150
        if self.should_print:
159
 
            self._to_file.write('added %s with id %s\n' 
 
151
            self._to_file.write('added %s with id %s\n'
160
152
                                % (path.raw_path, file_id))
161
153
        return file_id
162
154
 
258
250
                              'added dir1/file2 with id file-dir1%file2\n',
259
251
                              'added file1 with id file-file1\n',
260
252
                             ], lines)
261
 
        self.assertEqual([('', wt.inventory.root.file_id),
 
253
        wt.lock_read()
 
254
        self.addCleanup(wt.unlock)
 
255
        self.assertEqual([('', wt.path2id('')),
262
256
                          ('dir1', 'directory-dir1'),
263
257
                          ('dir1/file2', 'file-dir1%file2'),
264
258
                          ('file1', 'file-file1'),
341
335
        # These should get newly generated ids
342
336
        c_id = new_tree.path2id('c')
343
337
        self.assertNotEqual(None, c_id)
 
338
        self.base_tree.lock_read()
 
339
        self.addCleanup(self.base_tree.unlock)
344
340
        self.failIf(c_id in self.base_tree)
345
341
 
346
342
        d_id = new_tree.path2id('subdir/d')
364
360
        # matching path or child of 'subby'.
365
361
        a_id = new_tree.path2id('subby/a')
366
362
        self.assertNotEqual(None, a_id)
 
363
        self.base_tree.lock_read()
 
364
        self.addCleanup(self.base_tree.unlock)
367
365
        self.failIf(a_id in self.base_tree)
368
366
 
369
367
 
383
381
        osutils.normalized_filename = osutils._accessible_normalized_filename
384
382
        try:
385
383
            smart_add_tree(self.wt, [u'a\u030a'])
 
384
            self.wt.lock_read()
 
385
            self.addCleanup(self.wt.unlock)
386
386
            self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
387
387
                    [(path, ie.kind) for path,ie in 
388
388
                        self.wt.inventory.iter_entries()])
395
395
        osutils.normalized_filename = osutils._accessible_normalized_filename
396
396
        try:
397
397
            smart_add_tree(self.wt, [])
 
398
            self.wt.lock_read()
 
399
            self.addCleanup(self.wt.unlock)
398
400
            self.assertEqual([('', 'directory'), (u'\xe5', 'file')],
399
401
                    [(path, ie.kind) for path,ie in 
400
402
                        self.wt.inventory.iter_entries()])