~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: 2006-06-30 22:43:22 UTC
  • mto: (1711.4.39 win32-accepted)
  • mto: This revision was merged to the branch mainline in revision 1836.
  • Revision ID: john@arbash-meinel.com-20060630224322-c8e53eefd1a8b9f6
Investigating why test_bundle fails, something isn't transmitting properly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
from cStringIO import StringIO
 
18
import os
 
19
import tempfile
18
20
 
19
21
from bzrlib.builtins import merge
20
22
from bzrlib.bzrdir import BzrDir
21
23
from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
22
24
from bzrlib.bundle.bundle_data import BundleTree
23
25
from bzrlib.bundle.serializer import write_bundle, read_bundle
 
26
from bzrlib.branch import Branch
24
27
from bzrlib.diff import internal_diff
 
28
from bzrlib.delta import compare_trees
25
29
from bzrlib.errors import BzrError, TestamentMismatch, NotABundle, BadBundle
26
30
from bzrlib.merge import Merge3Merger
27
31
from bzrlib.osutils import has_symlinks, sha_file
52
56
            return self.make_entry(file_id, self.paths[file_id])
53
57
 
54
58
    def parent_id(self, file_id):
55
 
        from os.path import dirname
56
 
        parent_dir = dirname(self.paths[file_id])
 
59
        parent_dir = os.path.dirname(self.paths[file_id])
57
60
        if parent_dir == "":
58
61
            return None
59
62
        return self.ids[parent_dir]
70
73
        return kind
71
74
 
72
75
    def make_entry(self, file_id, path):
73
 
        from os.path import basename
74
76
        from bzrlib.inventory import (InventoryEntry, InventoryFile
75
77
                                    , InventoryDirectory, InventoryLink)
76
 
        name = basename(path)
 
78
        name = os.path.basename(path)
77
79
        kind = self.get_file_kind(file_id)
78
80
        parent_id = self.parent_id(file_id)
79
81
        text_sha_1, text_size = self.contents_stats(file_id)
379
381
    def get_checkout(self, rev_id, checkout_dir=None):
380
382
        """Get a new tree, with the specified revision in it.
381
383
        """
382
 
        from bzrlib.branch import Branch
383
 
        import tempfile
384
384
 
385
385
        if checkout_dir is None:
386
386
            checkout_dir = tempfile.mkdtemp(prefix='test-branch-', dir='.')
387
387
        else:
388
 
            import os
389
388
            if not os.path.exists(checkout_dir):
390
389
                os.mkdir(checkout_dir)
391
390
        tree = BzrDir.create_standalone_workingtree(checkout_dir)
398
397
        for ancestor in ancestors:
399
398
            old = self.b1.repository.revision_tree(ancestor)
400
399
            new = tree.branch.repository.revision_tree(ancestor)
 
400
 
 
401
            # Check that there aren't any inventory level changes
 
402
            delta = compare_trees(old, new)
 
403
            self.assertFalse(delta.has_changed)
 
404
 
 
405
            # Now check that the file contents are all correct
401
406
            for inventory_id in old:
402
407
                try:
403
408
                    old_file = old.get_file(inventory_id)
411
416
            rh = self.b1.revision_history()
412
417
            tree.branch.set_revision_history(rh[:rh.index(rev_id)+1])
413
418
            tree.update()
 
419
            #tree.revert()
 
420
            delta = compare_trees(tree, 
 
421
                                self.b1.repository.revision_tree(rev_id))
 
422
            self.assertFalse(delta.has_changed)
414
423
        return tree
415
424
 
416
425
    def valid_apply_bundle(self, base_rev_id, info, checkout_dir=None):