Special refs for native Mercurial repositories
Special refs in GitLab
GitLab stores interesting pointers, related as special refs in the Git repository, at least these prefixes:
class Repository
REF_MERGE_REQUEST = 'merge-requests'
REF_KEEP_AROUND = 'keep-around'
REF_ENVIRONMENTS = 'environments'
REF_PIPELINES = 'pipelines'
ARCHIVE_CACHE_TIME = 60 # Cache archives referred to by a (mutable) ref for 1 minute
(from the Repository model)
Here's an example usage in Merge Requests:
def ref_path
"refs/#{Repository::REF_MERGE_REQUEST}/#{iid}/head"
end
def merge_ref_path
"refs/#{Repository::REF_MERGE_REQUEST}/#{iid}/merge"
end
def train_ref_path
"refs/#{Repository::REF_MERGE_REQUEST}/#{iid}/train"
end
(from the MergeRequest model)
What to do for native Mercurial repositories
We don't have Mercurial equivalents. This is not a problem for hg-git based repositories, because those refs will be entirely managed within the Git repository, but it leads to problems with native repositories, such as #423 (closed) (cleanup of obsolete head
and merge
MR refs).
Also, we don't have currently a practical problem: clearly the Rails app has fallbacks if, e.g, the merge
MR ref is nil
, on a merged MR, but we shouldn't rely on such resilience for a condition that is clearly exceptional from upstream GitLab point of view.
Perhaps we could use local tags to represent them. Bookmarks are probably not appropriate, because they could be mixed with regular, user set, ones. That would be a bit as if the special refs were in the refs/heads
namespace for a Git repository.
The case of "keep-arounds" is special. There sole purpose is to avoid the target Git commits to be garbage collected. we don't need them We need them just in case some kind of garbage collecting is introduced in the future for Mercurial obsolete changesets. What we do need right now is HGitaly being able to serve obsolete changesets if specified by a full hash, and that's what we are doing already.
Sub Tasks
(only for native projects in Heptapod 0.20 series)
-
py-heptapod!52 (merged): primitives to store/manage/ensure from Git all special refs -
py-heptapod: ensure from Git in all Mercurial transactions. Edit: only for branches and tags -
#439 (closed) (Rails): backup and restore all GitLab ref state files -
heptapod (Rails): ensure all GitLab ref state files from Git prior to backups -
hgitaly#52 (closed): RefExists
for special refs -
hgitaly#48 (closed): WriteRef
for special refs -
hgitaly#49 (closed): DeleteRefs
for special refs -
hgitaly#50 (closed): ensure from Git in all read operations involving any kind of ref -
heptapod (Rails): perform all special ref writes and deletions on both sides by calling Gitaly and HGitaly. Special case for Merge Request creation ( FetchSourceBranch
)