~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from bzrlib import (
19
19
    branch,
20
20
    errors,
 
21
    graph,
21
22
    )
22
23
from bzrlib.smart import (
23
24
    server,
25
26
from bzrlib.tests.per_repository import TestCaseWithRepository
26
27
 
27
28
 
28
 
class TestFetch(TestCaseWithRepository):
 
29
class TestFetchBase(TestCaseWithRepository):
29
30
 
30
31
    def make_source_branch(self):
31
32
        # It would be nice if there was a way to force this to be memory-only
51
52
        self.addCleanup(source_b.unlock)
52
53
        return content, source_b
53
54
 
 
55
 
 
56
class TestFetch(TestFetchBase):
 
57
 
54
58
    def test_sprout_from_stacked_with_short_history(self):
55
59
        content, source_b = self.make_source_branch()
56
60
        # Split the generated content into a base branch, and a stacked branch
149
153
        source_b.lock_read()
150
154
        self.addCleanup(source_b.unlock)
151
155
        stacked.pull(source_b, stop_revision='B-id')
 
156
 
 
157
 
 
158
class TestFetchFromRepoWithUnconfiguredFallbacks(TestFetchBase):
 
159
 
 
160
    def make_stacked_source_repo(self):
 
161
        _, source_b = self.make_source_branch()
 
162
        # Use 'make_branch' which gives us a bzr:// branch when appropriate,
 
163
        # rather than creating a branch-on-disk
 
164
        stack_b = self.make_branch('stack-on')
 
165
        stack_b.pull(source_b, stop_revision='B-id')
 
166
        stacked_b = self.make_branch('stacked')
 
167
        stacked_b.set_stacked_on_url('../stack-on')
 
168
        stacked_b.pull(source_b, stop_revision='C-id')
 
169
        return stacked_b.repository
 
170
 
 
171
    def test_fetch_everything_includes_parent_invs(self):
 
172
        stacked = self.make_stacked_source_repo()
 
173
        repo_missing_fallbacks = stacked.bzrdir.open_repository()
 
174
        self.addCleanup(repo_missing_fallbacks.lock_read().unlock)
 
175
        target = self.make_repository('target')
 
176
        self.addCleanup(target.lock_write().unlock)
 
177
        target.fetch(
 
178
            repo_missing_fallbacks,
 
179
            fetch_spec=graph.EverythingResult(repo_missing_fallbacks))
 
180
        self.assertEqual(repo_missing_fallbacks.revisions.keys(),
 
181
            target.revisions.keys())
 
182
        self.assertEqual(repo_missing_fallbacks.inventories.keys(),
 
183
            target.inventories.keys())
 
184
        self.assertEqual(['C-id'],
 
185
            sorted(k[-1] for k in target.revisions.keys()))
 
186
        self.assertEqual(['B-id', 'C-id'],
 
187
            sorted(k[-1] for k in target.inventories.keys()))
 
188
 
 
189
 
 
190