~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-15 11:36:05 UTC
  • mto: This revision was merged to the branch mainline in revision 5975.
  • Revision ID: v.ladeuil+lp@free.fr-20110615113605-p7zyyfry9wy1hquc
Make ContentConflict resolution more robust

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
from bzrlib.merge import Merge3Merger, Merger
63
63
from bzrlib.tests import (
64
64
    features,
 
65
    HardlinkFeature,
 
66
    SymlinkFeature,
65
67
    TestCaseInTempDir,
66
68
    TestSkipped,
67
 
    )
68
 
from bzrlib.tests.features import (
69
 
    HardlinkFeature,
70
 
    SymlinkFeature,
71
 
    )
 
69
)
72
70
from bzrlib.transform import (
73
71
    build_tree,
74
72
    create_from_tree,
287
285
        new_trans_id = transform.new_directory('', ROOT_PARENT, 'alt-root-id')
288
286
        self.assertRaises(ValueError, transform.fixup_new_roots)
289
287
 
290
 
    def test_retain_existing_root(self):
291
 
        tt, root = self.get_transform()
292
 
        with tt:
293
 
            tt.new_directory('', ROOT_PARENT, 'new-root-id')
294
 
            tt.fixup_new_roots()
295
 
            self.assertNotEqual('new-root-id', tt.final_file_id(tt.root))
296
 
 
297
 
    def test_retain_existing_root_added_file(self):
298
 
        tt, root = self.get_transform()
299
 
        new_trans_id = tt.new_directory('', ROOT_PARENT, 'new-root-id')
300
 
        child = tt.new_directory('child', new_trans_id, 'child-id')
301
 
        tt.fixup_new_roots()
302
 
        self.assertEqual(tt.root, tt.final_parent(child))
303
 
 
304
288
    def test_add_unversioned_root(self):
305
289
        transform, root = self.get_transform()
306
290
        new_trans_id = transform.new_directory('', ROOT_PARENT, None)
307
 
        transform.delete_contents(transform.root)
308
291
        transform.fixup_new_roots()
309
292
        self.assertNotIn(transform.root, transform._new_id)
310
293
 
311
 
    def test_remove_root_fixup(self):
312
 
        transform, root = self.get_transform()
313
 
        old_root_id = self.wt.get_root_id()
314
 
        self.assertNotEqual('new-root-id', old_root_id)
315
 
        transform.delete_contents(root)
316
 
        transform.unversion_file(root)
317
 
        transform.fixup_new_roots()
318
 
        transform.apply()
319
 
        self.assertEqual(old_root_id, self.wt.get_root_id())
320
 
 
321
 
        transform, root = self.get_transform()
322
 
        new_trans_id = transform.new_directory('', ROOT_PARENT, 'new-root-id')
323
 
        new_trans_id = transform.new_directory('', ROOT_PARENT, 'alt-root-id')
324
 
        self.assertRaises(ValueError, transform.fixup_new_roots)
325
 
 
326
 
    def test_fixup_new_roots_permits_empty_tree(self):
327
 
        transform, root = self.get_transform()
328
 
        transform.delete_contents(root)
329
 
        transform.unversion_file(root)
330
 
        transform.fixup_new_roots()
331
 
        self.assertIs(None, transform.final_kind(root))
332
 
        self.assertIs(None, transform.final_file_id(root))
333
 
 
334
294
    def test_apply_retains_root_directory(self):
335
295
        # Do not attempt to delete the physical root directory, because that
336
296
        # is impossible.
342
302
                                  transform.apply)
343
303
        self.assertContainsRe('TransformRenameFailed not raised', str(e))
344
304
 
345
 
    def test_apply_retains_file_id(self):
346
 
        transform, root = self.get_transform()
347
 
        old_root_id = transform.tree_file_id(root)
348
 
        transform.unversion_file(root)
349
 
        transform.apply()
350
 
        self.assertEqual(old_root_id, self.wt.get_root_id())
351
 
 
352
305
    def test_hardlink(self):
353
306
        self.requireFeature(HardlinkFeature)
354
307
        transform, root = self.get_transform()
781
734
                            'wizard2', 'behind_curtain')
782
735
 
783
736
    def test_symlinks_unicode(self):
784
 
        self.requireFeature(features.UnicodeFilenameFeature)
 
737
        self.requireFeature(tests.UnicodeFilenameFeature)
785
738
        self._test_symlinks(u'\N{Euro Sign}wizard',
786
739
                            u'wizard-targ\N{Euro Sign}t',
787
740
                            u'\N{Euro Sign}wizard2',
2226
2179
        self.assertEqualStat(source_stat, target_stat)
2227
2180
 
2228
2181
    def test_case_insensitive_build_tree_inventory(self):
2229
 
        if (features.CaseInsensitiveFilesystemFeature.available()
2230
 
            or features.CaseInsCasePresFilenameFeature.available()):
 
2182
        if (tests.CaseInsensitiveFilesystemFeature.available()
 
2183
            or tests.CaseInsCasePresFilenameFeature.available()):
2231
2184
            raise tests.UnavailableFeature('Fully case sensitive filesystem')
2232
2185
        source = self.make_branch_and_tree('source')
2233
2186
        self.build_tree(['source/file', 'source/FILE'])
3346
3299
        self.assertEqual('contents', rev2_tree.get_file_text('file_id'))
3347
3300
 
3348
3301
    def test_ascii_limbo_paths(self):
3349
 
        self.requireFeature(features.UnicodeFilenameFeature)
 
3302
        self.requireFeature(tests.UnicodeFilenameFeature)
3350
3303
        branch = self.make_branch('any')
3351
3304
        tree = branch.repository.revision_tree(_mod_revision.NULL_REVISION)
3352
3305
        tt = TransformPreview(tree)
3369
3322
 
3370
3323
class TestSerializeTransform(tests.TestCaseWithTransport):
3371
3324
 
3372
 
    _test_needs_features = [features.UnicodeFilenameFeature]
 
3325
    _test_needs_features = [tests.UnicodeFilenameFeature]
3373
3326
 
3374
3327
    def get_preview(self, tree=None):
3375
3328
        if tree is None:
3450
3403
        return self.make_records(attribs, contents)
3451
3404
 
3452
3405
    def test_serialize_symlink_creation(self):
3453
 
        self.requireFeature(features.SymlinkFeature)
 
3406
        self.requireFeature(tests.SymlinkFeature)
3454
3407
        tt = self.get_preview()
3455
3408
        tt.new_symlink(u'foo\u1234', tt.root, u'bar\u1234')
3456
3409
        self.assertSerializesTo(self.symlink_creation_records(), tt)
3457
3410
 
3458
3411
    def test_deserialize_symlink_creation(self):
3459
 
        self.requireFeature(features.SymlinkFeature)
 
3412
        self.requireFeature(tests.SymlinkFeature)
3460
3413
        tt = self.get_preview()
3461
3414
        tt.deserialize(iter(self.symlink_creation_records()))
3462
3415
        abspath = tt._limbo_name('new-1')