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

Gitlab mirror: refusing to make tagged changesets obsolete

This is a more common trap than with bookmarks, due to
the separate changeset introducing the tag.

Closes heptapod#393

Like the whole refs update analysis, will have to be kept
when we don't mirror to Git.
parent 3840ed59
No related branches found
No related tags found
2 merge requests!45Validate obsolescence,!44config: add option to never exchange bookmarks
......@@ -275,6 +275,18 @@
obsolete_ctx.hex())
raise error.Abort(msg, hint=hint)
tags = obsolete_ctx.tags()
if tags:
hint = _(b"If this isn't a mistake, you may need to also "
b"update the tag(s).")
msg = _(b"Refusing these changes, as they would make "
b"tag(s) %s point to the "
b"obsolete changeset %s") % (
util.format_bytes_list(tags),
obsolete_ctx.hex())
raise error.Abort(msg, hint=hint)
def get_exportable(self):
"""Heptapod version, including named branches and topics.
......
......@@ -26,6 +26,7 @@
WildHeadResolved,
)
from mercurial_testhelpers.repo_wrapper import NULL_ID
from mercurial_testhelpers.util import as_bytes
from heptapod.testhelpers import (
RepoWrapper,
)
......@@ -302,6 +303,38 @@
# Removal not supported in Heptapod 0.8. TODO later
def test_tags_obsolete(tmpdir, monkeypatch):
notifs = []
patch_gitlab_hooks(monkeypatch, notifs)
# we'll need to perform a pull in order to amend a tagged changeset
# and rebase the tagging changeset in a single transaction.
src_path = tmpdir / 'src.hg'
src = RepoWrapper.init(src_path, config=common_config())
dest = make_empty_repo(tmpdir / 'dest.hg')
activate_mirror(dest)
def dest_pull():
dest.command('pull', source=as_bytes(src_path), force=True)
# Creation
src.commit_file('foo')
src.command('tag', b'v1.2.3')
tag_ctx = scmutil.revsingle(src.repo, b'.')
dest_pull()
tagged = scmutil.revsingle(src.repo, b'v1.2.3')
src.update_bin(tagged.node())
src_path.join("foo", "amending")
src.command('amend', message=b'amend')
src.command('rebase', rev=[tag_ctx.hex()])
with pytest.raises(error.Abort) as exc_info:
dest_pull()
assert re.search(br'tag.*v1\.2\.3.*obsolete', exc_info.value.args[0])
def test_share(tmpdir, monkeypatch):
notifs = []
patch_gitlab_hooks(monkeypatch, notifs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment