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

RepositoryService: using invalid_argument()

This error helper was introduced after these early service
methods.
parent 9a83d1db
No related branches found
No related tags found
1 merge request!46RepositoryService: refactoring to put on par with current code base
......@@ -17,6 +17,7 @@
from hgext3rd.heptapod.git import git_branch_from_ref
from ..errors import (
invalid_argument,
not_implemented,
)
from ..branch import (
......@@ -87,9 +88,8 @@
try:
path = validate_relative_path(repo, path)
except InvalidPath:
context.set_code(StatusCode.INVALID_ARGUMENT)
context.set_details("Invalid path: '%s'" % path)
return GetArchiveResponse()
return invalid_argument(context, GetArchiveResponse,
"Invalid path: '%s'" % path)
patterns.append(b"path:" + path)
match = scmutil.match(ctx, pats=patterns, opts={})
......@@ -132,7 +132,7 @@
request: WriteRefRequest,
context) -> WriteRefResponse:
if request.ref != b'HEAD':
context.set_code(StatusCode.INVALID_ARGUMENT)
context.set_details(
return invalid_argument(
context, WriteRefResponse,
"Moving a GitLab branch is not implemented in Mercurial "
"and would at most make sense for bookmarks.")
......@@ -137,6 +137,5 @@
"Moving a GitLab branch is not implemented in Mercurial "
"and would at most make sense for bookmarks.")
return WriteRefResponse()
target = git_branch_from_ref(request.revision)
if target is None:
......@@ -140,7 +139,7 @@
target = git_branch_from_ref(request.revision)
if target is None:
context.set_code(StatusCode.INVALID_ARGUMENT)
context.set_details(
return invalid_argument(
context, WriteRefResponse,
"The default GitLab branch can only be set "
"to a branch ref, got %r" % request.revision)
......@@ -145,6 +144,5 @@
"The default GitLab branch can only be set "
"to a branch ref, got %r" % request.revision)
return WriteRefResponse()
repo = self.load_repo(request.repository, context)
# TODO that part and the constant should go to hgext3rd.heptapod, since
......
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