remote-hg: add option to not track branches

Some people prefer it this way. % git config --global remote-hg.track-branches false Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jeff King <peff@peff.net>

Felipe Contreras committed Nov 4, 2012 at 03:13 UTC e30473c185442a9ac137f3841fe2d05e0e5ec81a
1 file changed +14 -8
contrib/remote-helpers/git-remote-hg
+14 -8
@@ -449,14 +449,9 @@ def list_head(repo, cur):
449 g_head = (head, node)
450
451 def do_list(parser):
452 - global branches, bmarks, mode
452 + global branches, bmarks, mode, track_branches
453
454 repo = parser.repo
455 - for branch in repo.branchmap():
456 - heads = repo.branchheads(branch)
457 - if len(heads):
458 - branches[branch] = heads
459 -
455 for bmark, node in bookmarks.listbookmarks(repo).iteritems():
456 bmarks[bmark] = repo[node]
457
@@ -464,7 +459,12 @@ def do_list(parser):
459
460 list_head(repo, cur)
461
467 - if mode != 'hg':
462 + if track_branches:
463 + for branch in repo.branchmap():
464 + heads = repo.branchheads(branch)
465 + if len(heads):
466 + branches[branch] = heads
467 +
468 for branch in branches:
469 print "? refs/heads/branches/%s" % branch
470
@@ -713,16 +713,22 @@ def main(args):
713 global prefix, dirname, branches, bmarks
714 global marks, blob_marks, parsed_refs
715 global peer, mode, bad_mail, bad_name
716 + global track_branches
717
718 alias = args[1]
719 url = args[2]
720 peer = None
721
721 - cmd = ['git', 'config', '--get', 'remote-hg.hg-git-compat']
722 hg_git_compat = False
723 + track_branches = True
724 try:
725 + cmd = ['git', 'config', '--get', 'remote-hg.hg-git-compat']
726 if subprocess.check_output(cmd) == 'true\n':
727 hg_git_compat = True
728 + track_branches = False
729 + cmd = ['git', 'config', '--get', 'remote-hg.track-branches']
730 + if subprocess.check_output(cmd) == 'false\n':
731 + track_branches = False
732 except subprocess.CalledProcessError:
733 pass
734