~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: Aaron Bentley
  • Date: 2006-06-20 02:32:24 UTC
  • mto: This revision was merged to the branch mainline in revision 1802.
  • Revision ID: aaron.bentley@utoronto.ca-20060620023224-745f7801d2ef3ac5
Move BundleReader into v07 serializer

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from bzrlib.builtins import merge
20
20
from bzrlib.bzrdir import BzrDir
21
21
from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
22
 
from bzrlib.bundle.read_bundle import BundleTree, BundleReader
23
 
from bzrlib.bundle.serializer import write_bundle
 
22
from bzrlib.bundle.read_bundle import BundleTree
 
23
from bzrlib.bundle.serializer import write_bundle, read_bundle
24
24
from bzrlib.diff import internal_diff
25
25
from bzrlib.errors import BzrError, TestamentMismatch, NotABundle
26
26
from bzrlib.merge import Merge3Merger
321
321
        open(',,bundle', 'wb').write(bundle_txt.getvalue())
322
322
        bundle_txt.seek(0)
323
323
        # This should also validate the generated bundle 
324
 
        bundle = BundleReader(bundle_txt)
 
324
        bundle = read_bundle(bundle_txt)
325
325
        repository = self.b1.repository
326
 
        for bundle_rev in bundle.info.real_revisions:
 
326
        for bundle_rev in bundle.real_revisions:
327
327
            # These really should have already been checked when we read the
328
328
            # bundle, since it computes the sha1 hash for the revision, which
329
329
            # only will match if everything is okay, but lets be explicit about
337
337
            self.assertEqual(len(branch_rev.parent_ids), 
338
338
                             len(bundle_rev.parent_ids))
339
339
        self.assertEqual(rev_ids, 
340
 
                         [r.revision_id for r in bundle.info.real_revisions])
 
340
                         [r.revision_id for r in bundle.real_revisions])
341
341
        self.valid_apply_bundle(base_rev_id, bundle,
342
342
                                   checkout_dir=checkout_dir)
343
343
 
360
360
        new_text = bundle_txt.getvalue().replace('executable:no', 
361
361
                                               'executable:yes')
362
362
        bundle_txt = StringIO(new_text)
363
 
        bundle = BundleReader(bundle_txt)
 
363
        bundle = read_bundle(bundle_txt)
364
364
        self.valid_apply_bundle(base_rev_id, bundle)
365
365
        return bundle 
366
366
 
367
367
    def test_non_bundle(self):
368
 
        self.assertRaises(NotABundle, BundleReader, StringIO('#!/bin/sh\n'))
 
368
        self.assertRaises(NotABundle, read_bundle, StringIO('#!/bin/sh\n'))
369
369
 
370
370
    def get_checkout(self, rev_id, checkout_dir=None):
371
371
        """Get a new tree, with the specified revision in it.
385
385
        s.seek(0)
386
386
        assert isinstance(s.getvalue(), str), (
387
387
            "Bundle isn't a bytestring:\n %s..." % repr(s.getvalue())[:40])
388
 
        install_bundle(tree.branch.repository, BundleReader(s))
 
388
        install_bundle(tree.branch.repository, read_bundle(s))
389
389
        for ancestor in ancestors:
390
390
            old = self.b1.repository.revision_tree(ancestor)
391
391
            new = tree.branch.repository.revision_tree(ancestor)
404
404
            tree.update()
405
405
        return tree
406
406
 
407
 
    def valid_apply_bundle(self, base_rev_id, reader, checkout_dir=None):
 
407
    def valid_apply_bundle(self, base_rev_id, info, checkout_dir=None):
408
408
        """Get the base revision, apply the changes, and make
409
409
        sure everything matches the builtin branch.
410
410
        """
411
411
        to_tree = self.get_checkout(base_rev_id, checkout_dir=checkout_dir)
412
412
        repository = to_tree.branch.repository
413
413
        self.assertIs(repository.has_revision(base_rev_id), True)
414
 
        info = reader.info
415
414
        for rev in info.real_revisions:
416
415
            self.assert_(not repository.has_revision(rev.revision_id),
417
416
                'Revision {%s} present before applying bundle' 
418
417
                % rev.revision_id)
419
 
        merge_bundle(reader, to_tree, True, Merge3Merger, False, False)
 
418
        merge_bundle(info, to_tree, True, Merge3Merger, False, False)
420
419
 
421
420
        for rev in info.real_revisions:
422
421
            self.assert_(repository.has_revision(rev.revision_id),