~bzr/ubuntu/lucid/bzr/bzr-ppa

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository_reference/test__make_parents_provider.py

2.4 promoted to not-beta PPA

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2011 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
 
 
18
"""Tests for _make_parents_provider on stacked repositories."""
 
19
 
 
20
 
 
21
from bzrlib.tests.per_repository import TestCaseWithRepository
 
22
 
 
23
 
 
24
class Test_MakeParentsProvider(TestCaseWithRepository):
 
25
 
 
26
    def test_add_fallback_after_make_pp(self):
 
27
        """Fallbacks added after _make_parents_provider are used by that
 
28
        provider.
 
29
        """
 
30
        referring_repo = self.make_repository('repo')
 
31
        pp = referring_repo._make_parents_provider()
 
32
        # Initially referring_repo has no revisions and no fallbacks
 
33
        self.addCleanup(referring_repo.lock_read().unlock)
 
34
        self.assertEqual({}, pp.get_parent_map(['revid2']))
 
35
        # Add a fallback repo with a commit
 
36
        wt_a = self.make_branch_and_tree('fallback')
 
37
        wt_a.commit('first commit', rev_id='revid1')
 
38
        wt_a.commit('second commit', rev_id='revid2')
 
39
        fallback_repo = wt_a.branch.repository
 
40
        referring_repo.add_fallback_repository(fallback_repo)
 
41
        # Now revid1 appears in pp's results.
 
42
        self.assertEqual(('revid1',), pp.get_parent_map(['revid2'])['revid2'])
 
43
 
 
44