Hard error upon push if remote Git has more topic changesets
In Heptapod context, this should never happen, since the inner Git repository is just a mirror of the Mercurial repository. Nevertheless, we've seen it happen in the wild.
It ends with this error on Heptapod 0.4.2:
File ".../heptapod/hg-git-heptapod/hggit/git_handler.py", line 1121, in upload_pack
progress=callback)
File ".../heptapod/hggit-venv/lib/python2.7/site-packages/dulwich/client.py", line 779, in send_pack
proto, negotiated_capabilities, old_refs, new_refs)
File ".../heptapod/hggit-venv/lib/python2.7/site-packages/dulwich/client.py", line 511, in _handle_receive_pack_head
raise TypeError('old sha1 for %s is not a bytestring %r' %
TypeError: old sha1 for refs/heads/topic/default/topic1 is not a bytestring None
and this one on the current latest
(has hg-git e56a2af414e9)
[2019-08-10 11:00:27 +0000] [9869] [INFO] repo:/var/opt/gitlab/git-data/repositories/root/test_project.hg [hg] finding hg commits to export
[2019-08-10 11:00:28 +0000] [9869] [WARNING] repo:/var/opt/gitlab/git-data/repositories/root/test_project.hg [hg] error: pretxnclose hook failed: branch 'refs/heads/topic/default/topic1' changed on the server, please pull and merge before pushing
[2019-08-10 11:00:28 +0000] [9869] [INFO] repo:/var/opt/gitlab/git-data/repositories/root/test_project.hg [hg.pythonhook] pythonhook-pretxnclose: heptapod_hooks.git_sync.mirror finished in 0.43 seconds
[2019-08-10 11:00:28 +0000] [9869] [WARNING] repo:/var/opt/gitlab/git-data/repositories/root/test_project.hg [hg] transaction abort!
[2019-08-10 11:00:28 +0000] [9869] [WARNING] repo:/var/opt/gitlab/git-data/repositories/root/test_project.hg [hg] rollback completed
and all subsequent pushes to the Mercurial repository including the topic fail.
Because of this, I've had to manually repair a corrupted repo, which amounted to remove those unknown commits from the Git repo (Mercurial being the reference anyway).
The proper behaviour here, if this is a forced push (Heptapod internal Git pushes are) is simply to override the Git remote. We should issue a warning, though.
Edited by Georges Racinet