remote-hg: check diverged bookmarks

So that we can report a proper error. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed May 24, 2013 at 21:29 UTC d3c460b5b43ab67de894c9d3b6d6ce20f3f00070
2 files changed +25 -1
contrib/remote-helpers/git-remote-hg
+24
@@ -859,6 +859,23 @@ def write_tag(repo, tag, node, msg, author):
859
860 return (tagnode, branch)
861
862 +def checkheads_bmark(repo, ref, ctx):
863 + if force_push:
864 + return True
865 +
866 + bmark = ref[len('refs/heads/'):]
867 + if not bmark in bmarks:
868 + # new bmark
869 + return True
870 +
871 + ctx_old = bmarks[bmark]
872 + ctx_new = ctx
873 + if not repo.changelog.descendant(ctx_old.rev(), ctx_new.rev()):
874 + print "error %s non-fast forward" % ref
875 + return False
876 +
877 + return True
878 +
879 def checkheads(repo, remote, p_revs):
880
881 remotemap = remote.branchmap()
@@ -875,6 +892,13 @@ def checkheads(repo, remote, p_revs):
892 if not branch in remotemap:
893 # new branch
894 continue
895 + if not ref.startswith('refs/heads/branches'):
896 + if ref.startswith('refs/heads/'):
897 + if not checkheads_bmark(repo, ref, ctx):
898 + ret = False
899 +
900 + # only check branches
901 + continue
902 new.setdefault(branch, []).append(ctx.rev())
903
904 for branch, heads in new.iteritems():
contrib/remote-helpers/test-hg.sh
+1 -1
@@ -380,7 +380,7 @@ test_expect_success 'remote update bookmark diverge' '
380 check_bookmark hgrepo diverge "bump bookmark"
381 '
382
383 -test_expect_failure 'remote new bookmark multiple branch head' '
383 +test_expect_success 'remote new bookmark multiple branch head' '
384 test_when_finished "rm -rf gitrepo*" &&
385
386 (