Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
hgitaly
Commits
9808129595b8
Commit
98081295
authored
Jan 21, 2022
by
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
Changes
2
Pipelines
3
Show whitespace changes
Inline
Side-by-side
hgitaly/service/repository.py
View file @
98081295
...
...
@@ -110,11 +110,8 @@
if
ctx
is
None
:
return
FindMergeBaseResponse
()
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).
# The GCA may be obsolete as well (meaning that one of ctxs is
# also obsolete). TODO add test for obsolete cases
repo
=
repo
.
unfiltered
()
...
...
@@ -116,11 +113,9 @@
# 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
()
gca
=
repo
.
revs
(
b
"ancestor(%ld)"
,
ctxs
).
first
()
base
=
repo
[
gca
].
hex
()
if
gca
is
not
None
else
''
return
FindMergeBaseResponse
(
base
=
base
)
...
...
hgitaly/service/tests/test_repository_service.py
View file @
98081295
...
...
@@ -303,6 +303,13 @@
wrapper
.
amend_file
(
'foo'
,
message
=
'amended foo'
)
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
):
rel_path
=
'sample_repo'
default_storage
=
'default'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment