Skip to content

Commit 0c2b1cf

Browse files
committed
Merge branch 'fc/remote-hg' (early part)
* 'fc/remote-hg' (early part): remote-hg: update bookmarks when pulling remote-hg: don't push fake 'master' bookmark remote-hg: disable forced push by default remote-hg: fix new branch creation remote-hg: add new get_config_bool() helper remote-hg: enable track-branches in hg-git mode remote-hg: get rid of unused exception checks remote-hg: trivial cleanups
2 parents 6a3ac18 + 24317ef commit 0c2b1cf

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ def get_config(config):
8787
output, _ = process.communicate()
8888
return output
8989

90+
def get_config_bool(config, default=False):
91+
value = get_config(config).rstrip('\n')
92+
if value == "true":
93+
return True
94+
elif value == "false":
95+
return False
96+
else:
97+
return default
98+
9099
class Marks:
91100

92101
def __init__(self, path):
@@ -327,11 +336,8 @@ def get_repo(url, alias):
327336
myui.setconfig('ui', 'interactive', 'off')
328337
myui.fout = sys.stderr
329338

330-
try:
331-
if get_config('remote-hg.insecure') == 'true\n':
332-
myui.setconfig('web', 'cacerts', '')
333-
except subprocess.CalledProcessError:
334-
pass
339+
if get_config_bool('remote-hg.insecure'):
340+
myui.setconfig('web', 'cacerts', '')
335341

336342
try:
337343
mod = extensions.load(myui, 'hgext.schemes', None)
@@ -357,6 +363,9 @@ def get_repo(url, alias):
357363
die('Repository error')
358364
repo.pull(peer, heads=None, force=True)
359365

366+
rb = peer.listkeys('bookmarks')
367+
bookmarks.updatefromremote(myui, repo, rb, url)
368+
360369
return repo
361370

362371
def rev_to_mark(rev):
@@ -538,7 +547,7 @@ def list_head(repo, cur):
538547
g_head = (head, node)
539548

540549
def do_list(parser):
541-
global branches, bmarks, mode, track_branches
550+
global branches, bmarks, track_branches
542551

543552
repo = parser.repo
544553
for bmark, node in bookmarks.listbookmarks(repo).iteritems():
@@ -850,7 +859,7 @@ def do_export(parser):
850859
continue
851860

852861
if peer:
853-
parser.repo.push(peer, force=force_push)
862+
parser.repo.push(peer, force=force_push, newbranch=True)
854863

855864
# handle bookmarks
856865
for bmark, node in p_bmarks:
@@ -867,7 +876,8 @@ def do_export(parser):
867876

868877
if bmark == 'master' and 'master' not in parser.repo._bookmarks:
869878
# fake bookmark
870-
pass
879+
print "ok %s" % ref
880+
continue
871881
elif bookmarks.pushbookmark(parser.repo, bmark, old, new):
872882
# updated locally
873883
pass
@@ -906,20 +916,9 @@ def main(args):
906916
url = args[2]
907917
peer = None
908918

909-
hg_git_compat = False
910-
track_branches = True
911-
force_push = True
912-
913-
try:
914-
if get_config('remote-hg.hg-git-compat') == 'true\n':
915-
hg_git_compat = True
916-
track_branches = False
917-
if get_config('remote-hg.track-branches') == 'false\n':
918-
track_branches = False
919-
if get_config('remote-hg.force-push') == 'false\n':
920-
force_push = False
921-
except subprocess.CalledProcessError:
922-
pass
919+
hg_git_compat = get_config_bool('remote-hg.hg-git-compat')
920+
track_branches = get_config_bool('remote-hg.track-branches', True)
921+
force_push = get_config_bool('remote-hg.force-push')
923922

924923
if hg_git_compat:
925924
mode = 'hg'

contrib/remote-helpers/test-hg-hg-git.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ setup () {
102102
) >> "$HOME"/.hgrc &&
103103
git config --global receive.denycurrentbranch warn
104104
git config --global remote-hg.hg-git-compat true
105+
git config --global remote-hg.track-branches false
105106

106107
HGEDITOR=/usr/bin/true
107108

@@ -455,8 +456,6 @@ test_expect_success 'hg author' '
455456
git_log gitrepo-$x > git-log-$x
456457
done &&
457458
458-
test_cmp git-log-hg git-log-git &&
459-
460459
test_cmp hg-log-hg hg-log-git &&
461460
test_cmp git-log-hg git-log-git
462461
'

0 commit comments

Comments
 (0)