~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-14 16:54:26 UTC
  • mfrom: (6216.1.1 remove-this-file)
  • Revision ID: pqm@pqm.ubuntu.com-20111014165426-tjix4e6idryf1r2z
(jelmer) Remove an accidentally committed .THIS file. (Jelmer Vernooij)

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