~thumper/bzr/alias-command

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Tim Penhey
  • Date: 2008-04-20 08:48:04 UTC
  • mfrom: (2900.1.474 +trunk)
  • Revision ID: tim@penhey.net-20080420084804-fw6m8ezw4n7pnmo1
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    treebuilder,
29
29
    )
30
30
from bzrlib.bzrdir import BzrDir
 
31
from bzrlib.bundle import read_mergeable_from_url
31
32
from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
32
33
from bzrlib.bundle.bundle_data import BundleTree
 
34
from bzrlib.directory_service import directories
33
35
from bzrlib.bundle.serializer import write_bundle, read_bundle, v09, v4
34
36
from bzrlib.bundle.serializer.v08 import BundleSerializerV08
35
37
from bzrlib.bundle.serializer.v09 import BundleSerializerV09
40
42
                           NoSuchFile,)
41
43
from bzrlib.merge import Merge3Merger
42
44
from bzrlib.repofmt import knitrepo
43
 
from bzrlib.osutils import has_symlinks, sha_file
44
 
from bzrlib.tests import (TestCaseInTempDir, TestCaseWithTransport,
45
 
                          TestCase, TestSkipped, test_commit)
 
45
from bzrlib.osutils import sha_file
 
46
from bzrlib.tests import (
 
47
    SymlinkFeature,
 
48
    TestCase,
 
49
    TestCaseInTempDir,
 
50
    TestCaseWithTransport,
 
51
    TestSkipped,
 
52
    test_read_bundle,
 
53
    test_commit,
 
54
    )
46
55
from bzrlib.transform import TreeTransform
47
56
 
48
57
 
492
501
        sure everything matches the builtin branch.
493
502
        """
494
503
        to_tree = self.get_checkout(base_rev_id, checkout_dir=checkout_dir)
 
504
        to_tree.lock_write()
 
505
        try:
 
506
            self._valid_apply_bundle(base_rev_id, info, to_tree)
 
507
        finally:
 
508
            to_tree.unlock()
 
509
 
 
510
    def _valid_apply_bundle(self, base_rev_id, info, to_tree):
495
511
        original_parents = to_tree.get_parent_ids()
496
512
        repository = to_tree.branch.repository
497
513
        original_parents = to_tree.get_parent_ids()
641
657
        bundle = self.get_valid_bundle('a@cset-0-6', 'a@cset-0-7')
642
658
 
643
659
    def test_symlink_bundle(self):
644
 
        if not has_symlinks():
645
 
            raise TestSkipped("No symlink support")
 
660
        self.requireFeature(SymlinkFeature)
646
661
        self.tree1 = self.make_branch_and_tree('b1')
647
662
        self.b1 = self.tree1.branch
648
663
        tt = TreeTransform(self.tree1)
1327
1342
        self.assertEqual('contents2\nstatic\n', vf.get_text('rev2'))
1328
1343
        rtree = target_repo.revision_tree('rev2')
1329
1344
        inventory_vf = target_repo.get_inventory_weave()
1330
 
        self.assertEqual(['rev1'], inventory_vf.get_parents('rev2'))
 
1345
        self.assertEqual({'rev2':('rev1',)},
 
1346
            inventory_vf.get_parent_map(['rev2']))
1331
1347
        self.assertEqual('changed file',
1332
1348
                         target_repo.get_revision('rev2').message)
1333
1349
 
1547
1563
        self.assertEqual((None, {'foo': 'bar', 'storage_kind': 'header'},
1548
1564
            'info', None, None), record)
1549
1565
        self.assertRaises(BadBundle, record_iter.next)
 
1566
 
 
1567
 
 
1568
class TestReadMergeableFromUrl(TestCaseWithTransport):
 
1569
 
 
1570
    def test_read_mergeable_skips_local(self):
 
1571
        """A local bundle named like the URL should not be read.
 
1572
        """
 
1573
        out, wt = test_read_bundle.create_bundle_file(self)
 
1574
        class FooService(object):
 
1575
            """A directory service that always returns source"""
 
1576
 
 
1577
            def look_up(self, name, url):
 
1578
                return 'source'
 
1579
        directories.register('foo:', FooService, 'Testing directory service')
 
1580
        self.addCleanup(lambda: directories.remove('foo:'))
 
1581
        self.build_tree_contents([('./foo:bar', out.getvalue())])
 
1582
        self.assertRaises(errors.NotABundle, read_mergeable_from_url,
 
1583
                          'foo:bar')