25
26
from bzrlib.tests.per_repository import TestCaseWithRepository
28
class TestFetch(TestCaseWithRepository):
29
class TestFetchBase(TestCaseWithRepository):
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
56
class TestFetch(TestFetchBase):
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')
158
class TestFetchFromRepoWithUnconfiguredFallbacks(TestFetchBase):
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
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)
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()))