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

cleanup: removed unnecessary calls to hg_unchecked()

There are two categories:

- totally unneeded ones, most probably leftover from
  debugging sessions
- those that are about a push without changes, that
  can now be covered with `expected_return_code`
parent 2623d2c419c9
......@@ -191,7 +191,7 @@ def test_implicit_move(test_project, tmpdir):
# 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)
out = repo.hg('push', '-B', 'book', url, expected_return_code=1)
assert 'deleting remote bookmark book' in out
assert test_project.api_branch_titles() == {
'branch/default': 'Commit on default',
......@@ -202,14 +202,12 @@ def test_implicit_move(test_project, tmpdir):
# first, prepare it
test_project.owner_api_hgrc_set(allow_bookmarks=True)
repo.hg('bookmark', '-r', '1', 'sliding')
code, out, err = repo.hg_unchecked('push', '-B', 'sliding', url)
assert code == 1 # "no changes"
repo.hg('push', '-B', 'sliding', url, expected_return_code=1)
test_project.owner_api_hgrc_set(allow_bookmarks=False)
# 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"
repo.hg('push', '-B', 'sliding', url, expected_return_code=1)
# it didn't shadow it
assert test_project.api_branch_titles() == {
......
......@@ -122,7 +122,7 @@ def test_compat_closed_branch(test_project, tmpdir):
repo.hg('up', 'default')
repo_path.join('foo').write("more work on default branch")
repo.hg('commit', '-m', "More work 1")
code, out, err = repo.hg_unchecked('push')
repo.hg('push')
assert test_project.api_branch_titles() == {
'branch/default': 'More work 1',
......@@ -132,7 +132,7 @@ def test_compat_closed_branch(test_project, tmpdir):
test_project.extend_hgrc('hg-git.prune-previously-closed-branches=yes')
repo_path.join('foo').write("even more work on default branch")
repo.hg('commit', '-m', "More work 2")
code, out, err = repo.hg_unchecked('push')
repo.hg('push')
assert test_project.api_branch_titles() == {
'branch/default': 'More work 2',
......
......@@ -158,8 +158,7 @@ def test_import_bookmarks(public_project, tmpdir):
# Now let's put a bookmark on a non topic changeset
src_repo.hg('bookmark', '-r', '1', 'book1')
code = src_repo.hg_unchecked('push', '-B', 'book1')[0]
assert code in (0, 1) # no changeset to push
src_repo.hg('push', '-B', 'book1', expected_return_code=1)
print("Graph of source project after push:")
print(src_repo.graphlog())
......
......@@ -73,7 +73,7 @@ def prepare_named_branch(repo, needing_rebase=True, branch_name=None):
repo.path.join('gnu').write("A lion eats lots of gnu!\n")
repo.hg('commit', '-Am', "Le lion est prédateur du gnou !",
'--user', 'Raphaël <raphael@heptapod.test>')
code, out, err = repo.hg_unchecked('push', '--new-branch')
repo.hg('push', '--new-branch')
print("Graph after preparation of named branch:")
print(repo.graphlog())
return branch_name
......
......@@ -9,7 +9,7 @@ def test_push_multiple_heads_merge(test_project, tmpdir):
repo = LocalRepo.init(repo_path)
repo_path.join('foo').write('foo0')
repo.hg('commit', '-Am', "Commit 0")
repo.hg_unchecked('push', owner_url)
repo.hg('push', owner_url)
# first head on default branch
repo_path.join('foo').write('foo1')
......@@ -221,7 +221,7 @@ def test_push_multiple_heads_topic_merge(test_project, tmpdir):
repo = LocalRepo.init(repo_path)
repo_path.join('foo').write('foo0')
repo.hg('commit', '-Am', "Commit 0")
repo.hg_unchecked('push', owner_url)
repo.hg('push', owner_url)
# first head on topic
repo.hg('topic', 'zz')
......
......@@ -26,8 +26,7 @@ def test_prune_inside_topic(test_project, tmpdir):
repo.hg('prune', '-r', 's1')
# we don't need to force for pushing an orphan changeset: it's already in
# the remote.
code, _, err = repo.hg_unchecked('push', url)
assert 'abort' not in err.lower()
repo.hg('push', url, expected_return_code=1)
# now reclone and check hg log
clone = LocalRepo.clone(url, tmpdir.join('clone'))
......@@ -58,8 +57,7 @@ def test_prune_whole_topic(test_project, tmpdir):
repo.hg('push', url)
repo.hg('prune', '-r', '.')
code, _, err = repo.hg_unchecked('push', url)
assert 'abort' not in err.lower()
repo.hg('push', url, expected_return_code=1)
# now reclone and check hg log
clone = LocalRepo.clone(url, tmpdir.join('clone'))
......@@ -95,8 +93,7 @@ def test_prune_topic_successor_other_topic(test_project, tmpdir):
# can't use 'topic2' to access Commit 2 any more, it's been published
# and is now the head of default.
repo.hg('prune', '-r', 'topic1', '-s', 'default')
code, _, err = repo.hg_unchecked('push', url)
assert 'abort' not in err.lower()
repo.hg('push', url, expected_return_code=1)
# now reclone and check hg log
clone = LocalRepo.clone(url, tmpdir.join('clone'))
......
......@@ -37,7 +37,7 @@ def test_publish_perms(test_project, tmpdir):
# OTOH, maintainers can push the publication
test_project.grant_member_access(user_name='test_basic',
level=ProjectAccess.MAINTAINER)
repo.hg_unchecked('push', basic_user_url)
repo.hg('push', basic_user_url, expected_return_code=1)
clone = LocalRepo.clone(owner_url, tmpdir.join('repo2'))
log = clone.hg('log', '-T', '{desc}:{phase}:{topic}\n')
......
......@@ -107,8 +107,8 @@ def test_permissions(test_project, tmpdir):
# of course becoming a maintainer makes it finally possible to publish
test_project.grant_member_access(user_name='test_basic',
level=ProjectAccess.MAINTAINER)
code, out, err = user_clone.hg_unchecked('push', '--ssh', ssh_cmd, ssh_url)
assert err.strip() == ''
user_clone.hg('push', '--ssh', ssh_cmd, ssh_url,
expected_return_code=1)
assert test_project.api_branch_titles() == {
'branch/default': 'clone commit',
'topic/default/zetop': 'Commit 1',
......
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