~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-09-22 14:12:18 UTC
  • mfrom: (6155.3.1 jam)
  • Revision ID: pqm@pqm.ubuntu.com-20110922141218-86s4uu6nqvourw4f
(jameinel) Cleanup comments bzrlib/smart/__init__.py (John A Meinel)

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:
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:
506
511
                old.unlock()
507
512
        if not _mod_revision.is_null(rev_id):
508
513
            rh = self.b1.revision_history()
509
 
            tree.branch.set_revision_history(rh[:rh.index(rev_id)+1])
 
514
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
515
                tree.branch.set_revision_history, rh[:rh.index(rev_id)+1])
510
516
            tree.update()
511
517
            delta = tree.changes_from(self.b1.repository.revision_tree(rev_id))
512
518
            self.assertFalse(delta.has_changed(),
679
685
    def _test_symlink_bundle(self, link_name, link_target, new_link_target):
680
686
        link_id = 'link-1'
681
687
 
682
 
        self.requireFeature(tests.SymlinkFeature)
 
688
        self.requireFeature(features.SymlinkFeature)
683
689
        self.tree1 = self.make_branch_and_tree('b1')
684
690
        self.b1 = self.tree1.branch
685
691
 
726
732
        self._test_symlink_bundle('link', 'bar/foo', 'mars')
727
733
 
728
734
    def test_unicode_symlink_bundle(self):
729
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
735
        self.requireFeature(features.UnicodeFilenameFeature)
730
736
        self._test_symlink_bundle(u'\N{Euro Sign}link',
731
737
                                  u'bar/\N{Euro Sign}foo',
732
738
                                  u'mars\N{Euro Sign}')
833
839
        return bundle_file.getvalue()
834
840
 
835
841
    def test_unicode_bundle(self):
836
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
842
        self.requireFeature(features.UnicodeFilenameFeature)
837
843
        # Handle international characters
838
844
        os.mkdir('b1')
839
845
        f = open(u'b1/with Dod\N{Euro Sign}', 'wb')
1412
1418
        branch = tree_a.branch
1413
1419
        repo_a = branch.repository
1414
1420
        tree_a.commit("base", allow_pointless=True, rev_id='A')
1415
 
        self.failIf(branch.repository.has_signature_for_revision_id('A'))
 
1421
        self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
1416
1422
        try:
1417
1423
            from bzrlib.testament import Testament
1418
1424
            # monkey patch gpg signing mechanism
1442
1448
        install_bundle(repo_b, serializer.read(s))
1443
1449
 
1444
1450
 
1445
 
class V4WeaveBundleTester(V4BundleTester):
1446
 
 
1447
 
    def bzrdir_format(self):
1448
 
        return 'metaweave'
1449
 
 
1450
 
 
1451
1451
class V4_2aBundleTester(V4BundleTester):
1452
1452
 
1453
1453
    def bzrdir_format(self):