~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

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,
67
65
 
68
66
 
69
67
class MockTree(object):
 
68
 
70
69
    def __init__(self):
71
70
        from bzrlib.inventory import InventoryDirectory, ROOT_ID
72
71
        object.__init__(self)
77
76
 
78
77
    inventory = property(lambda x:x)
79
78
 
80
 
    def __iter__(self):
81
 
        return self.paths.iterkeys()
 
79
    def all_file_ids(self):
 
80
        return set(self.paths.keys())
82
81
 
83
82
    def __getitem__(self, file_id):
84
83
        if file_id == self.root.file_id:
145
144
        result.seek(0,0)
146
145
        return result
147
146
 
 
147
    def get_file_revision(self, file_id):
 
148
        return self.inventory[file_id].revision
 
149
 
148
150
    def contents_stats(self, file_id):
149
151
        if file_id not in self.contents:
150
152
            return None, None
492
494
                                 % (ancestor,))
493
495
 
494
496
                # Now check that the file contents are all correct
495
 
                for inventory_id in old:
 
497
                for inventory_id in old.all_file_ids():
496
498
                    try:
497
499
                        old_file = old.get_file(inventory_id)
498
500
                    except errors.NoSuchFile:
506
508
                old.unlock()
507
509
        if not _mod_revision.is_null(rev_id):
508
510
            rh = self.b1.revision_history()
509
 
            tree.branch.set_revision_history(rh[:rh.index(rev_id)+1])
 
511
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
 
512
                tree.branch.set_revision_history, rh[:rh.index(rev_id)+1])
510
513
            tree.update()
511
514
            delta = tree.changes_from(self.b1.repository.revision_tree(rev_id))
512
515
            self.assertFalse(delta.has_changed(),
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):