Skip to content
Snippets Groups Projects
Commit 2e458e28 authored by Georges Racinet's avatar Georges Racinet
Browse files

Gitaly Comparison tests: improve RpcHelper request conversion to Git

It is now able to handle `..` and `...` ranges.
Also, an incoming non-sha revision is now returned untouched:
this will be useful for arguments that can be either symbolic
(e.g., refs) and direct SHAs.
parent db50a206
No related branches found
No related tags found
2 merge requests!81Merge stable into default,!80Switching Gitaly Comparison test_ref and test_commit to new style
......@@ -141,5 +141,5 @@
git_kwargs = hg_kwargs.copy()
for sha_attr in self.request_sha_attrs:
sha = hg_kwargs.get(sha_attr)
if sha is None or len(sha) != 40:
if sha is None:
continue
......@@ -145,4 +145,4 @@
continue
git_kwargs[sha_attr] = self.hg2git(sha)
git_kwargs[sha_attr] = self.revspec_to_git(sha)
return git_kwargs
......@@ -147,5 +147,23 @@
return git_kwargs
def revspec_to_git(self, revspec):
"""Convert revision specifications, including ranges to Git.
This is to be improved as new cases arise.
"""
is_bytes = isinstance(revspec, bytes)
symdiff_sep = b'...' if is_bytes else '...'
only_sep = b'..' if is_bytes else '..'
for sep in (symdiff_sep, only_sep):
if sep in revspec:
# hg2git() defaulting rule will let symbolic revisions, such
# as refs go through untouched
return sep.join(self.hg2git(rev)
for rev in revspec.split(sep))
# TODO implement caret, tilda etc.
return self.hg2git(revspec)
def response_to_git(self, resp):
sha_attr_paths = [path.split('.') for path in self.response_sha_attrs]
if self.streaming:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment