Skip to content

Commit b0c3db8

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 11dc88f commit b0c3db8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import urllib
2727
# named branches:
2828
# git config --global remote-hg.track-branches false
2929
#
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+
#
3033
# git:
3134
# Sensible defaults for git.
3235
# hg bookmarks are exported as git branches, hg branches are prefixed
@@ -730,7 +733,7 @@ def do_export(parser):
730733
continue
731734

732735
if peer:
733-
parser.repo.push(peer, force=False)
736+
parser.repo.push(peer, force=force_push)
734737

735738
# handle bookmarks
736739
for bmark, node in p_bmarks:
@@ -773,20 +776,24 @@ def main(args):
773776
global prefix, dirname, branches, bmarks
774777
global marks, blob_marks, parsed_refs
775778
global peer, mode, bad_mail, bad_name
776-
global track_branches
779+
global track_branches, force_push
777780

778781
alias = args[1]
779782
url = args[2]
780783
peer = None
781784

782785
hg_git_compat = False
783786
track_branches = True
787+
force_push = True
788+
784789
try:
785790
if get_config('remote-hg.hg-git-compat') == 'true\n':
786791
hg_git_compat = True
787792
track_branches = False
788793
if get_config('remote-hg.track-branches') == 'false\n':
789794
track_branches = False
795+
if get_config('remote-hg.force-push') == 'false\n':
796+
force_push = False
790797
except subprocess.CalledProcessError:
791798
pass
792799

0 commit comments

Comments
 (0)