298
300
revision_id = tree.commit('test')
299
301
repo.fetch(tree.branch.repository)
300
302
repo.fetch(tree.branch.repository)
304
def make_simple_branch_with_ghost(self):
305
builder = self.make_branch_builder('source')
306
builder.start_series()
307
builder.build_snapshot('A-id', None, [
308
('add', ('', 'root-id', 'directory', None)),
309
('add', ('file', 'file-id', 'file', 'content\n'))])
310
builder.build_snapshot('B-id', ['A-id', 'ghost-id'], [])
311
builder.finish_series()
312
source_b = builder.get_branch()
314
self.addCleanup(source_b.unlock)
317
def test_fetch_with_ghost(self):
318
source_b = self.make_simple_branch_with_ghost()
319
target = self.make_repository('target')
321
self.addCleanup(target.unlock)
322
target.fetch(source_b.repository, revision_id='B-id')
324
def test_fetch_into_smart_with_ghost(self):
325
trans = self.make_smart_server('target')
326
source_b = self.make_simple_branch_with_ghost()
327
target = self.make_repository('target')
328
# Re-open the repository over the smart protocol
329
target = repository.Repository.open(trans.base)
331
self.addCleanup(target.unlock)
333
target.fetch(source_b.repository, revision_id='B-id')
334
except errors.TokenLockingNotSupported:
335
# The code inside fetch() that tries to lock and then fails, also
336
# causes weird problems with 'lock_not_held' later on...
338
raise tests.KnownFailure('some repositories fail to fetch'
339
' via the smart server because of locking issues.')
341
def test_fetch_from_smart_with_ghost(self):
342
trans = self.make_smart_server('source')
343
source_b = self.make_simple_branch_with_ghost()
344
target = self.make_repository('target')
346
self.addCleanup(target.unlock)
347
# Re-open the repository over the smart protocol
348
source = repository.Repository.open(trans.base)
350
self.addCleanup(source.unlock)
351
target.fetch(source, revision_id='B-id')
354
class TestSource(TestCaseWithRepository):
355
"""Tests for/about the results of Repository._get_source."""
357
def test_no_absent_records_in_stream_with_ghosts(self):
358
# XXX: Arguably should be in interrepository_implementations but
359
# doesn't actually gain coverage there; need a specific set of
360
# permutations to cover it.
361
# bug lp:376255 was reported about this.
362
builder = self.make_branch_builder('repo')
363
builder.start_series()
364
builder.build_snapshot('tip', ['ghost'],
365
[('add', ('', 'ROOT_ID', 'directory', ''))],
366
allow_leftmost_as_ghost=True)
367
builder.finish_series()
368
b = builder.get_branch()
370
self.addCleanup(b.unlock)
372
source = repo._get_source(repo._format)
373
search = graph.PendingAncestryResult(['tip'], repo)
374
stream = source.get_stream(search)
375
for substream_type, substream in stream:
376
for record in substream:
377
self.assertNotEqual('absent', record.storage_kind,
378
"Absent record for %s" % (((substream_type,) + record.key),))