/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-27 11:34:38 UTC
  • mto: This revision was merged to the branch mainline in revision 6216.
  • Revision ID: jelmer@samba.org-20110927113438-iaunzmkn9yscv0al
More test fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-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
27
27
    inventory,
28
28
    merge,
29
29
    osutils,
30
 
    repository,
31
30
    revision as _mod_revision,
 
31
    symbol_versioning,
32
32
    tests,
33
33
    treebuilder,
34
34
    )
35
35
from bzrlib.bundle import read_mergeable_from_url
36
36
from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
37
37
from bzrlib.bundle.bundle_data import BundleTree
38
 
from bzrlib.bzrdir import BzrDir
39
38
from bzrlib.directory_service import directories
40
39
from bzrlib.bundle.serializer import write_bundle, read_bundle, v09, v4
41
40
from bzrlib.bundle.serializer.v08 import BundleSerializerV08
42
41
from bzrlib.bundle.serializer.v09 import BundleSerializerV09
43
42
from bzrlib.bundle.serializer.v4 import BundleSerializerV4
44
 
from bzrlib.branch import Branch
45
43
from bzrlib.repofmt import knitrepo
46
44
from bzrlib.tests import (
47
45
    test_read_bundle,
48
46
    test_commit,
49
47
    )
50
48
from bzrlib.transform import TreeTransform
 
49
from bzrlib.tests import (
 
50
    features,
 
51
    )
51
52
 
52
53
 
53
54
def get_text(vf, key):
67
68
 
68
69
 
69
70
class MockTree(object):
 
71
 
70
72
    def __init__(self):
71
73
        from bzrlib.inventory import InventoryDirectory, ROOT_ID
72
74
        object.__init__(self)
77
79
 
78
80
    inventory = property(lambda x:x)
79
81
 
80
 
    def __iter__(self):
81
 
        return self.paths.iterkeys()
 
82
    def all_file_ids(self):
 
83
        return set(self.paths.keys())
82
84
 
83
85
    def __getitem__(self, file_id):
84
86
        if file_id == self.root.file_id:
114
116
            ie = InventoryDirectory(file_id, name, parent_id)
115
117
        elif kind == 'file':
116
118
            ie = InventoryFile(file_id, name, parent_id)
 
119
            ie.text_sha1 = text_sha_1
 
120
            ie.text_size = text_size
117
121
        elif kind == 'symlink':
118
122
            ie = InventoryLink(file_id, name, parent_id)
119
123
        else:
120
124
            raise errors.BzrError('unknown kind %r' % kind)
121
 
        ie.text_sha1 = text_sha_1
122
 
        ie.text_size = text_size
123
125
        return ie
124
126
 
125
127
    def add_dir(self, file_id, path):
145
147
        result.seek(0,0)
146
148
        return result
147
149
 
 
150
    def get_file_revision(self, file_id):
 
151
        return self.inventory[file_id].revision
 
152
 
148
153
    def contents_stats(self, file_id):
149
154
        if file_id not in self.contents:
150
155
            return None, None
492
497
                                 % (ancestor,))
493
498
 
494
499
                # Now check that the file contents are all correct
495
 
                for inventory_id in old:
 
500
                for inventory_id in old.all_file_ids():
496
501
                    try:
497
502
                        old_file = old.get_file(inventory_id)
498
503
                    except errors.NoSuchFile:
505
510
                new.unlock()
506
511
                old.unlock()
507
512
        if not _mod_revision.is_null(rev_id):
508
 
            rh = self.b1.revision_history()
509
 
            tree.branch.set_revision_history(rh[:rh.index(rev_id)+1])
 
513
            rh = list(self.b1.iter_reverse_revision_history())
 
514
            rh.reverse()
 
515
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
516
                tree.branch.set_revision_history, rh[:rh.index(rev_id)+1])
510
517
            tree.update()
511
518
            delta = tree.changes_from(self.b1.repository.revision_tree(rev_id))
512
519
            self.assertFalse(delta.has_changed(),
679
686
    def _test_symlink_bundle(self, link_name, link_target, new_link_target):
680
687
        link_id = 'link-1'
681
688
 
682
 
        self.requireFeature(tests.SymlinkFeature)
 
689
        self.requireFeature(features.SymlinkFeature)
683
690
        self.tree1 = self.make_branch_and_tree('b1')
684
691
        self.b1 = self.tree1.branch
685
692
 
726
733
        self._test_symlink_bundle('link', 'bar/foo', 'mars')
727
734
 
728
735
    def test_unicode_symlink_bundle(self):
729
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
736
        self.requireFeature(features.UnicodeFilenameFeature)
730
737
        self._test_symlink_bundle(u'\N{Euro Sign}link',
731
738
                                  u'bar/\N{Euro Sign}foo',
732
739
                                  u'mars\N{Euro Sign}')
833
840
        return bundle_file.getvalue()
834
841
 
835
842
    def test_unicode_bundle(self):
836
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
843
        self.requireFeature(features.UnicodeFilenameFeature)
837
844
        # Handle international characters
838
845
        os.mkdir('b1')
839
846
        f = open(u'b1/with Dod\N{Euro Sign}', 'wb')
1412
1419
        branch = tree_a.branch
1413
1420
        repo_a = branch.repository
1414
1421
        tree_a.commit("base", allow_pointless=True, rev_id='A')
1415
 
        self.failIf(branch.repository.has_signature_for_revision_id('A'))
 
1422
        self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
1416
1423
        try:
1417
1424
            from bzrlib.testament import Testament
1418
1425
            # monkey patch gpg signing mechanism
1442
1449
        install_bundle(repo_b, serializer.read(s))
1443
1450
 
1444
1451
 
1445
 
class V4WeaveBundleTester(V4BundleTester):
1446
 
 
1447
 
    def bzrdir_format(self):
1448
 
        return 'metaweave'
1449
 
 
1450
 
 
1451
1452
class V4_2aBundleTester(V4BundleTester):
1452
1453
 
1453
1454
    def bzrdir_format(self):