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

RepositoryService.WriteRef: renaming and early def of variables

In the forthcoming implementations, having both a `ref` and
a `revision` will make things a bit obscure. `target` will often
be a SHA, so let's called the parsed target branch `target_branch`
parent 49c82f51
No related branches found
Tags 0.8.1
1 merge request!46RepositoryService: refactoring to put on par with current code base
......@@ -131,9 +131,12 @@
self,
request: WriteRefRequest,
context) -> WriteRefResponse:
if request.ref != b'HEAD':
ref, target = request.ref, request.revision
repo = self.load_repo(request.repository, context)
if ref != b'HEAD':
return invalid_argument(
context, WriteRefResponse,
"Moving a GitLab branch is not implemented in Mercurial "
"and would at most make sense for bookmarks.")
......@@ -135,10 +138,10 @@
return invalid_argument(
context, WriteRefResponse,
"Moving a GitLab branch is not implemented in Mercurial "
"and would at most make sense for bookmarks.")
target = git_branch_from_ref(request.revision)
if target is None:
target_branch = git_branch_from_ref(target)
if target_branch is None:
return invalid_argument(
context, WriteRefResponse,
"The default GitLab branch can only be set "
......@@ -142,5 +145,5 @@
return invalid_argument(
context, WriteRefResponse,
"The default GitLab branch can only be set "
"to a branch ref, got %r" % request.revision)
"to a branch ref, got %r" % target)
......@@ -146,5 +149,4 @@
repo = self.load_repo(request.repository, context)
# TODO that part and the constant should go to hgext3rd.heptapod, since
# the default branch will have to be set by push reception.
with repo.wlock():
......@@ -148,7 +150,7 @@
# TODO that part and the constant should go to hgext3rd.heptapod, since
# the default branch will have to be set by push reception.
with repo.wlock():
repo.vfs.write(DEFAULT_BRANCH_FILE_NAME, target)
repo.vfs.write(DEFAULT_BRANCH_FILE_NAME, target_branch)
return WriteRefResponse()
def ApplyGitattributes(self, request: ApplyGitattributesRequest,
......
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