~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert Collins
  • Date: 2009-08-03 04:37:37 UTC
  • mfrom: (4580 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4649.
  • Revision ID: robertc@robertcollins.net-20090803043737-h02sf93wnnlff5tb
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2679
2679
                    result.append(content.key[-1])
2680
2680
        return result
2681
2681
 
2682
 
    def get_ordered_revs(self, format, order):
 
2682
    def get_ordered_revs(self, format, order, branch_factory=None):
2683
2683
        """Get a list of the revisions in a stream to format format.
2684
2684
 
2685
2685
        :param format: The format of the target.
2686
2686
        :param order: the order that target should have requested.
 
2687
        :param branch_factory: A callable to create a trunk and stacked branch
 
2688
            to fetch from. If none, self.prepare_stacked_remote_branch is used.
2687
2689
        :result: The revision ids in the stream, in the order seen,
2688
2690
            the topological order of revisions in the source.
2689
2691
        """
2691
2693
        target_repository_format = unordered_format.repository_format
2692
2694
        # Cross check
2693
2695
        self.assertEqual(order, target_repository_format._fetch_order)
2694
 
        trunk, stacked = self.prepare_stacked_remote_branch()
 
2696
        if branch_factory is None:
 
2697
            branch_factory = self.prepare_stacked_remote_branch
 
2698
        _, stacked = branch_factory()
2695
2699
        source = stacked.repository._get_source(target_repository_format)
2696
2700
        tip = stacked.last_revision()
2697
2701
        revs = stacked.repository.get_ancestry(tip)
2716
2720
        # from the server, then one from the backing branch.
2717
2721
        self.assertLength(2, self.hpss_calls)
2718
2722
 
 
2723
    def test_stacked_on_stacked_get_stream_unordered(self):
 
2724
        # Repository._get_source.get_stream() from a stacked repository which
 
2725
        # is itself stacked yields the full data from all three sources.
 
2726
        def make_stacked_stacked():
 
2727
            _, stacked = self.prepare_stacked_remote_branch()
 
2728
            tree = stacked.bzrdir.sprout('tree3', stacked=True
 
2729
                ).open_workingtree()
 
2730
            tree.commit('more local changes are better')
 
2731
            branch = Branch.open(self.get_url('tree3'))
 
2732
            branch.lock_read()
 
2733
            return None, branch
 
2734
        rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered',
 
2735
            branch_factory=make_stacked_stacked)
 
2736
        self.assertEqual(set(expected_revs), set(rev_ord))
 
2737
        # Getting unordered results should have made a streaming data request
 
2738
        # from the server, and one from each backing repo
 
2739
        self.assertLength(3, self.hpss_calls)
 
2740
 
2719
2741
    def test_stacked_get_stream_topological(self):
2720
2742
        # Repository._get_source.get_stream() from a stacked repository with
2721
2743
        # topological sorting yields the full data from both stacked and