~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-28 00:25:32 UTC
  • mfrom: (5264.1.2 command-help-bug-177500)
  • Revision ID: pqm@pqm.ubuntu.com-20100528002532-9bzj1fajyxckd1rg
(lifeless) Stop raising at runtime when a command has no help,
 instead have a test in the test suite that checks all known command objects.
 (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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,
30
31
    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
38
39
from bzrlib.directory_service import directories
39
40
from bzrlib.bundle.serializer import write_bundle, read_bundle, v09, v4
40
41
from bzrlib.bundle.serializer.v08 import BundleSerializerV08
41
42
from bzrlib.bundle.serializer.v09 import BundleSerializerV09
42
43
from bzrlib.bundle.serializer.v4 import BundleSerializerV4
 
44
from bzrlib.branch import Branch
43
45
from bzrlib.repofmt import knitrepo
44
46
from bzrlib.tests import (
45
47
    test_read_bundle,
65
67
 
66
68
 
67
69
class MockTree(object):
68
 
 
69
70
    def __init__(self):
70
71
        from bzrlib.inventory import InventoryDirectory, ROOT_ID
71
72
        object.__init__(self)
76
77
 
77
78
    inventory = property(lambda x:x)
78
79
 
79
 
    def all_file_ids(self):
80
 
        return set(self.paths.keys())
 
80
    def __iter__(self):
 
81
        return self.paths.iterkeys()
81
82
 
82
83
    def __getitem__(self, file_id):
83
84
        if file_id == self.root.file_id:
113
114
            ie = InventoryDirectory(file_id, name, parent_id)
114
115
        elif kind == 'file':
115
116
            ie = InventoryFile(file_id, name, parent_id)
116
 
            ie.text_sha1 = text_sha_1
117
 
            ie.text_size = text_size
118
117
        elif kind == 'symlink':
119
118
            ie = InventoryLink(file_id, name, parent_id)
120
119
        else:
121
120
            raise errors.BzrError('unknown kind %r' % kind)
 
121
        ie.text_sha1 = text_sha_1
 
122
        ie.text_size = text_size
122
123
        return ie
123
124
 
124
125
    def add_dir(self, file_id, path):
144
145
        result.seek(0,0)
145
146
        return result
146
147
 
147
 
    def get_file_revision(self, file_id):
148
 
        return self.inventory[file_id].revision
149
 
 
150
148
    def contents_stats(self, file_id):
151
149
        if file_id not in self.contents:
152
150
            return None, None
494
492
                                 % (ancestor,))
495
493
 
496
494
                # Now check that the file contents are all correct
497
 
                for inventory_id in old.all_file_ids():
 
495
                for inventory_id in old:
498
496
                    try:
499
497
                        old_file = old.get_file(inventory_id)
500
498
                    except errors.NoSuchFile:
508
506
                old.unlock()
509
507
        if not _mod_revision.is_null(rev_id):
510
508
            rh = self.b1.revision_history()
511
 
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
512
 
                tree.branch.set_revision_history, rh[:rh.index(rev_id)+1])
 
509
            tree.branch.set_revision_history(rh[:rh.index(rev_id)+1])
513
510
            tree.update()
514
511
            delta = tree.changes_from(self.b1.repository.revision_tree(rev_id))
515
512
            self.assertFalse(delta.has_changed(),
1415
1412
        branch = tree_a.branch
1416
1413
        repo_a = branch.repository
1417
1414
        tree_a.commit("base", allow_pointless=True, rev_id='A')
1418
 
        self.assertFalse(branch.repository.has_signature_for_revision_id('A'))
 
1415
        self.failIf(branch.repository.has_signature_for_revision_id('A'))
1419
1416
        try:
1420
1417
            from bzrlib.testament import Testament
1421
1418
            # monkey patch gpg signing mechanism
1445
1442
        install_bundle(repo_b, serializer.read(s))
1446
1443
 
1447
1444
 
 
1445
class V4WeaveBundleTester(V4BundleTester):
 
1446
 
 
1447
    def bzrdir_format(self):
 
1448
        return 'metaweave'
 
1449
 
 
1450
 
1448
1451
class V4_2aBundleTester(V4BundleTester):
1449
1452
 
1450
1453
    def bzrdir_format(self):