Commit e0527170 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

RepositoryService.FindMergeBase: support obsolescence

Either the arguments (if passed by their SHAs) or the found
ancestor (in case of instability) can be obsolete.

This method is usually called at Merge Request creation, where
obsolescence is uncommon, but it can also be called after export/import
and migrations that clear caches, and then the probabilities are much
higher.
parent 08e559de66f1
......@@ -113,6 +113,11 @@
# As per Gitaly, In future we may support this method for more
# than two revisions, but for now we don't.
ctx_from, ctx_to = ctxs[0], ctxs[1]
# Some of the changesets may be obsolete (if addressed by SHAs).
# The GCA may be obsolete as well (meaning that one of ctxs is
# also obsolete). TODO add test for obsolete cases
repo = repo.unfiltered()
gca = repo.revs(
b"ancestor(%d, %d)" % (ctx_from.rev(), ctx_to.rev())
).first()
......
......@@ -293,6 +293,15 @@
sha_not_exists = b'deadnode' * 5
assert do_rpc([sha0, sha_not_exists]) == b''
# cases with obsolescence
wrapper.update(sha2)
wrapper.amend_file('animal', message='amended animal').hex()
assert do_rpc([sha1, sha2]) == sha0
wrapper.update(sha0)
wrapper.amend_file('foo', message='amended foo')
assert do_rpc([sha1, sha2]) == sha0
def test_create_repository(grpc_channel, server_repos_root):
rel_path = 'sample_repo'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment