Read about our upcoming Code of Conduct on this issue

Commit f0717d66 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Mercurial native: different rules for implicit bookmark push

For native repos, the shadowing happens at read time, so we
can't make a difference between sliding (not a new bookmark)
or not.

Also, we cannot just let the bookmark at a previous position
for the non-shadowed case of the default GitLab branch. This
latter case is done identically for non-native repos because
it was arguably a logical discrepancy.
parent 13eb36a56335
......@@ -29,9 +29,10 @@ def test_push_bookmarks_default_branch(test_project, tmpdir):
branches = test_project.api_branches()
# even though the 'default' named branch only has bookmarked heads,
# the 'branch/default' GitLab branch should not be pruned, because it is
# also GitLab's default branch (hence also the HEAD of the inner Git repo)
# also GitLab's default branch (hence also the HEAD of the inner Git
# repo)
assert set(branches) == {'branch/default', 'book1'}
assert branches['branch/default']['commit']['title'] == 'Commit 0'
assert branches['branch/default']['commit']['title'] == 'Commit 1'
assert branches['book1']['commit']['title'] == 'Commit 1'
# on the other hand, bookmarks on topics are still refused
......@@ -59,7 +60,7 @@ def test_push_bookmarks_default_branch(test_project, tmpdir):
branches = test_project.api_branches()
assert set(branches) == {'branch/default', 'book1', 'book2'}
assert branches['branch/default']['commit']['title'] == 'Commit 0'
assert branches['branch/default']['commit']['title'] == 'Commit 2'
assert branches['book1']['commit']['title'] == 'Commit 1'
assert branches['book2']['commit']['title'] == 'Commit 2'
......@@ -209,9 +210,30 @@ def test_implicit_move(test_project, tmpdir):
repo.hg('bookmark', '-r', 'other', 'sliding')
repo.hg('push', '-B', 'sliding', url, expected_return_code=1)
# it didn't shadow it
assert test_project.api_branch_titles() == {
gl_branches = {
'branch/default': 'Commit on default',
'branch/other': 'Commit 2',
'sliding': 'Commit 2',
}
if not test_project.hg_native:
# not shadowing the branch is a divergence of state
# between hg and git that cannot sanely be reproduced
# in the native case. See heptapod#143 for the origin of this
# non-shadowing feature
gl_branches['branch/other'] = 'Commit 2'
assert test_project.api_branch_titles() == gl_branches
if test_project.hg_native:
# additional test to check that sliding to the head of
# the GitLab default branch has no ill effects
# verifying our assumptions
assert test_project.api_default_branch() == 'branch/default'
repo.hg('bookmark', '--force', '-r', 'default', 'sliding')
repo.hg('push', '-B', 'sliding', url, expected_return_code=1)
assert test_project.api_branch_titles() == {
'branch/default': 'Commit on default',
'branch/other': 'Commit 2',
'sliding': 'Commit on default',
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment