remote-hg: force remote push

Ideally we shouldn't do this, as it's not recommended in mercurial documentation, but there's no other way to push multiple bookmarks (on the same branch), which would be the behavior most similar to git. At the same time, add a configuration option for the people that don't want to risk creating new remote heads. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Apr 11, 2013 at 07:23 UTC b0c3db860cac2215f07deeb9e91cbd2597fe41d0
1 file changed +9 -2
contrib/remote-helpers/git-remote-hg
+9 -2
@@ -27,6 +27,9 @@ import urllib
27 # named branches:
28 # git config --global remote-hg.track-branches false
29 #
30 +# If you don't want to force pushes (and thus risk creating new remote heads):
31 +# git config --global remote-hg.force-push false
32 +#
33 # git:
34 # Sensible defaults for git.
35 # hg bookmarks are exported as git branches, hg branches are prefixed
@@ -730,7 +733,7 @@ def do_export(parser):
733 continue
734
735 if peer:
733 - parser.repo.push(peer, force=False)
736 + parser.repo.push(peer, force=force_push)
737
738 # handle bookmarks
739 for bmark, node in p_bmarks:
@@ -773,7 +776,7 @@ def main(args):
776 global prefix, dirname, branches, bmarks
777 global marks, blob_marks, parsed_refs
778 global peer, mode, bad_mail, bad_name
776 - global track_branches
779 + global track_branches, force_push
780
781 alias = args[1]
782 url = args[2]
@@ -781,12 +784,16 @@ def main(args):
784
785 hg_git_compat = False
786 track_branches = True
787 + force_push = True
788 +
789 try:
790 if get_config('remote-hg.hg-git-compat') == 'true\n':
791 hg_git_compat = True
792 track_branches = False
793 if get_config('remote-hg.track-branches') == 'false\n':
794 track_branches = False
795 + if get_config('remote-hg.force-push') == 'false\n':
796 + force_push = False
797 except subprocess.CalledProcessError:
798 pass
799