Skip to content

Commit e30473c

Browse files
felipecpeff
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent aefc605 commit e30473c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,22 +449,22 @@ def list_head(repo, cur):
449449
g_head = (head, node)
450450

451451
def do_list(parser):
452-
global branches, bmarks, mode
452+
global branches, bmarks, mode, track_branches
453453

454454
repo = parser.repo
455-
for branch in repo.branchmap():
456-
heads = repo.branchheads(branch)
457-
if len(heads):
458-
branches[branch] = heads
459-
460455
for bmark, node in bookmarks.listbookmarks(repo).iteritems():
461456
bmarks[bmark] = repo[node]
462457

463458
cur = repo.dirstate.branch()
464459

465460
list_head(repo, cur)
466461

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+
468468
for branch in branches:
469469
print "? refs/heads/branches/%s" % branch
470470

@@ -713,16 +713,22 @@ def main(args):
713713
global prefix, dirname, branches, bmarks
714714
global marks, blob_marks, parsed_refs
715715
global peer, mode, bad_mail, bad_name
716+
global track_branches
716717

717718
alias = args[1]
718719
url = args[2]
719720
peer = None
720721

721-
cmd = ['git', 'config', '--get', 'remote-hg.hg-git-compat']
722722
hg_git_compat = False
723+
track_branches = True
723724
try:
725+
cmd = ['git', 'config', '--get', 'remote-hg.hg-git-compat']
724726
if subprocess.check_output(cmd) == 'true\n':
725727
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
726732
except subprocess.CalledProcessError:
727733
pass
728734

0 commit comments

Comments
 (0)