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

pull-force-topic: exit 1 if no changesets have been pulled

This is necessary for heptapod#169: the caller needs a
clear indication that the pull was empty.

The choice of return code is consistent with `push` exiting
also in code 1 if there is no changeset to push (but still
pushing phase changes)
parent bba4bd48
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -88,7 +88,7 @@
if not inc_nodes:
ui.status(_("Empty pull, nothing to do\n"))
cleanupfn()
return
return 1
try:
bundle = os.fdopen(fd, 'rb')
......@@ -96,6 +96,7 @@
with repo.transaction('pull-force-topic') as txn:
unbundle(ui, repo, bundle, txn)
change_topic(ui, repo, topic, inc_nodes)
return 0
finally:
cleanupfn()
cleanup_tmp_bundle(ui, bundle, bundlepath)
......
......@@ -53,11 +53,13 @@
parent=base_ctx.node())
fork.set_phase('public', ['.'])
main.command('pull-force-topic', 'zetop',
source=str(fork_path), rev=[node.hex(fork_node)])
code = main.command('pull-force-topic', 'zetop',
source=str(fork_path), rev=[node.hex(fork_node)])
assert code == 0
# TODO better lookup ?
imported = main.repo['tip']
assert imported.topic() == 'zetop' # implied draft
assert imported.description() == 'in fork 1'
......@@ -58,9 +60,31 @@
# TODO better lookup ?
imported = main.repo['tip']
assert imported.topic() == 'zetop' # implied draft
assert imported.description() == 'in fork 1'
def test_empty_pull(tmpdir):
"""Case where the pull turns out to be empty.
See also heptapod#169
"""
main_path = tmpdir.join('main')
fork_path = tmpdir.join('fork')
main, base_ctx = make_main_repo(main_path)
fork = LocalRepoWrapper.init(fork_path)
fork.command('pull', str(main_path), rev=[base_ctx.hex()])
fork_node = fork.write_commit('bar', content='bar1', message="in fork 1",
parent=base_ctx.node())
fork.set_phase('public', ['.'])
main.command('pull', source=str(fork_path))
code = main.command('pull-force-topic', 'zetop',
source=str(fork_path), rev=[node.hex(fork_node)])
assert code == 1
def test_change_topic_sanity(tmpdir):
wrapper, base_ctx = make_main_repo(tmpdir)
repo = wrapper.repo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment