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

git_sync: testing actual mirroring

and this uncovers a funny phenomenon, that hook gives an infinite
loop when running on local Mercurial repos.

Most of the work of the git_sync hook is done indirectly by the fact
that `hg-git` rewraps the `push command`, but this still would catch
stupid mistakes in that glue code, and `py-heptadod` is now 100% covered.
parent 56e71c24fd63
No related branches found
No related tags found
1 merge request!3Full test coverage
Pipeline #
......@@ -33,6 +33,12 @@
def mirror(ui, repo, *args, **kwargs):
dest = mirror_path(ui, repo)
if dest == repo.root:
# avoid an infinite loop when pushing to a local Mercurial repo
# (our ui would be used in the inner push, hence triggering again
# for the destination repo)
return 0
repo.ui.note("Heptapod mirror starting, target is %r" % dest)
push = cmdutil.findcmd('push', commands.table)[1][0]
push(ui, repo, dest=dest, force=True)
......
......@@ -52,3 +52,18 @@
with pytest.raises(error.Abort) as exc_info:
mirror_path(repo.ui, repo)
assert "'proj.svn' is invalid" in exc_info.value.args[0]
def test_mirror(tmpdir):
dst_path = tmpdir.join('dst')
dst_wrapper = LocalRepoWrapper.init(dst_path)
src_wrapper = LocalRepoWrapper.init(
tmpdir.join('src'),
config=dict(
heptapod={'mirror-path': str(dst_path)},
hooks={'pretxnclose': 'python:heptapod.hooks.git_sync.mirror'},
))
src_wrapper.write_commit('foo', 'this should be mirrored')
assert dst_wrapper.repo['tip'].description() == 'this should be mirrored'
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