Commit 7d3045af authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Tests for implicit bookmarks moves

See heptapod#143: since bookmarks are implicitely
pushed, we have to honour that.

It's also the occasion to test what happens with
bookmarks deletions, which should also be allowed at
all time (this is also important for people that have
bookmarks because they have been using regular hg-git
for a while)
parent 9afe6ccc85d3
......@@ -158,3 +158,78 @@ def test_push_bookmarks_non_default_branch(test_project, tmpdir):
assert branches['book1']['commit']['title'] == 'Commit 1'
assert branches['book2']['commit']['title'] == 'Commit 2'
assert branches['branch/other']['commit']['title'] == 'Not bookmarked'
@needs.fs_access
def test_implicit_move(test_project, tmpdir):
repo_path = tmpdir.join('repo1')
url = test_project.owner_basic_auth_url
repo = LocalRepo.init(repo_path)
# As usual, let's make a first public changeset
repo_path.join('foo').write('foo default')
repo.hg('commit', '-Am', "Commit on default")
repo.hg('phase', '-p', ".")
repo.hg('push', url)
repo.hg('branch', 'other')
repo_path.join('foo').write('foo branch')
repo.hg('commit', '-m', "Commit 1")
repo.hg('push', '--new-branch', url)
# Just to be sure
branches = test_project.api_branches()
assert set(branches) == {'branch/default', 'branch/other'}
repo_path.join('foo').write('foo1')
repo.hg('commit', '-m', "Commit 1")
repo.hg('bookmark', '-r', '.', 'book')
print(repo.graphlog())
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = yes")
repo.hg('push', '-B', 'book', url)
branches = test_project.api_branch_titles()
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = no")
repo_path.join('foo').write('foo2')
repo.hg('commit', '-m', "Commit 2")
repo.hg('bookmark', '-r', '.', 'book')
# notice how we dont explicitely push the bookmark
repo.hg('push', url)
# yet, it moved
assert test_project.api_branch_titles()['book'] == 'Commit 2'
# bookmark removal is possible and it restores the shadowed branch
repo.hg('bookmark', '-d', 'book')
code, out, err = repo.hg_unchecked('push', '-B', 'book', url)
assert 'deleting remote bookmark book' in out
assert test_project.api_branch_titles() == {
'branch/default': 'Commit on default',
'branch/other': 'Commit 2',
}
# now imagine a bookmark slides to the head of a branch
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = yes")
repo.hg('bookmark', '-r', '1', 'sliding')
code, out, err = repo.hg_unchecked('push', '-B', 'sliding', url)
assert code == 1 # "no changes"
test_project.extend_hgrc("[experimental]",
"hg-git.bookmarks-on-named-branches = no")
# let's move it to the head of 'other'
repo.hg('bookmark', '-r', 'other', 'sliding')
code, out, err = repo.hg_unchecked('push', '-B', 'sliding', url)
assert code == 1 # "no changes"
# it didn't shadow it
assert test_project.api_branch_titles() == {
'branch/default': 'Commit on default',
'branch/other': 'Commit 2',
'sliding': 'Commit 2',
}
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