172
172
errors.UnstackableRepositoryFormat):
173
173
# not a testable combination.
176
cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',
177
preserve_stacking=False)
178
except errors.NoSuchRevision:
180
'Pack-to-pack fetch does not handle stacking properly.'
183
self.fail('Expected a failure due to broken fetching.')
175
cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',
176
preserve_stacking=False)
184
177
unstacked_branch = cloned_unstacked_bzrdir.open_branch()
185
178
self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),
186
179
unstacked_branch.get_stacked_on_url)
215
208
self.assertEqual('../stack-on', target.get_stacked_on_url())
216
209
except errors.UnstackableBranchFormat:
212
def prepare_stacked_on_fetch(self):
213
stack_on = self.make_branch_and_tree('stack-on')
214
stack_on.commit('first commit', rev_id='rev1')
216
stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
217
except (errors.UnstackableRepositoryFormat,
218
errors.UnstackableBranchFormat):
219
raise TestNotApplicable('Format does not support stacking.')
220
unstacked = self.make_repository('unstacked')
221
return stacked_dir.open_workingtree(), unstacked
223
def test_fetch_copies_from_stacked_on(self):
224
stacked, unstacked = self.prepare_stacked_on_fetch()
225
unstacked.fetch(stacked.branch.repository, 'rev1')
226
unstacked.get_revision('rev1')
228
def test_fetch_copies_from_stacked_on_and_stacked(self):
229
stacked, unstacked = self.prepare_stacked_on_fetch()
230
stacked.commit('second commit', rev_id='rev2')
231
unstacked.fetch(stacked.branch.repository, 'rev2')
232
unstacked.get_revision('rev1')
233
unstacked.get_revision('rev2')