Skip to content

Commit 760ee1c

Browse files
felipecgitster
authored andcommitted
remote-hg: add new get_config_bool() helper
No functional changes. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 679e87c commit 760ee1c

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 13 additions & 11 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,7 +336,7 @@ def get_repo(url, alias):
327336
myui.setconfig('ui', 'interactive', 'off')
328337
myui.fout = sys.stderr
329338

330-
if get_config('remote-hg.insecure') == 'true\n':
339+
if get_config_bool('remote-hg.insecure'):
331340
myui.setconfig('web', 'cacerts', '')
332341

333342
try:
@@ -903,16 +912,9 @@ def main(args):
903912
url = args[2]
904913
peer = None
905914

906-
hg_git_compat = False
907-
track_branches = True
908-
force_push = True
909-
910-
if get_config('remote-hg.hg-git-compat') == 'true\n':
911-
hg_git_compat = True
912-
if get_config('remote-hg.track-branches') == 'false\n':
913-
track_branches = False
914-
if get_config('remote-hg.force-push') == 'false\n':
915-
force_push = False
915+
hg_git_compat = get_config_bool('remote-hg.hg-git-compat')
916+
track_branches = get_config_bool('remote-hg.track-branches', True)
917+
force_push = get_config_bool('remote-hg.force-push', True)
916918

917919
if hg_git_compat:
918920
mode = 'hg'

0 commit comments

Comments
 (0)