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

RepositoryService.FindMergeBase: support more than 2 arguments

The `ancestor` revset primitive supports them readily.
parent e0527170c718
Pipeline #31367 passed with stages
in 8 minutes and 5 seconds
...@@ -110,11 +110,8 @@ ...@@ -110,11 +110,8 @@
if ctx is None: if ctx is None:
return FindMergeBaseResponse() return FindMergeBaseResponse()
ctxs.append(ctx) ctxs.append(ctx)
# 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). # Some of the changesets may be obsolete (if addressed by SHAs).
# The GCA may be obsolete as well (meaning that one of ctxs is # The GCA may be obsolete as well (meaning that one of ctxs is
# also obsolete). TODO add test for obsolete cases # also obsolete). TODO add test for obsolete cases
repo = repo.unfiltered() repo = repo.unfiltered()
...@@ -116,11 +113,9 @@ ...@@ -116,11 +113,9 @@
# Some of the changesets may be obsolete (if addressed by SHAs). # Some of the changesets may be obsolete (if addressed by SHAs).
# The GCA may be obsolete as well (meaning that one of ctxs is # The GCA may be obsolete as well (meaning that one of ctxs is
# also obsolete). TODO add test for obsolete cases # also obsolete). TODO add test for obsolete cases
repo = repo.unfiltered() repo = repo.unfiltered()
gca = repo.revs( gca = repo.revs(b"ancestor(%ld)", ctxs).first()
b"ancestor(%d, %d)" % (ctx_from.rev(), ctx_to.rev())
).first()
base = repo[gca].hex() if gca is not None else '' base = repo[gca].hex() if gca is not None else ''
return FindMergeBaseResponse(base=base) return FindMergeBaseResponse(base=base)
......
...@@ -303,6 +303,13 @@ ...@@ -303,6 +303,13 @@
wrapper.amend_file('foo', message='amended foo') wrapper.amend_file('foo', message='amended foo')
assert do_rpc([sha1, sha2]) == sha0 assert do_rpc([sha1, sha2]) == sha0
# cases with more than 2 changesets
# (in a previous version, only the 2 first arguments would have been
# considered, giving wrong results but no error)
assert do_rpc([sha1, sha1, sha2]) == sha0
assert do_rpc([sha1, sha2, sha3]) == b''
def test_create_repository(grpc_channel, server_repos_root): def test_create_repository(grpc_channel, server_repos_root):
rel_path = 'sample_repo' rel_path = 'sample_repo'
default_storage = 'default' default_storage = 'default'
......
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