remote-hg: simplify branch_tip()

It simply picks the last head that is not closed, but we have a stored list of open heads. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed May 24, 2013 at 21:29 UTC 611024e606c8019d348ab1821a1fbb1898384a25
1 file changed +4 -8
contrib/remote-helpers/git-remote-hg
+4 -8
@@ -560,12 +560,8 @@ def do_capabilities(parser):
560
561 print
562
563 -def branch_tip(repo, branch):
564 - # older versions of mercurial don't have this
565 - if hasattr(repo, 'branchtip'):
566 - return repo.branchtip(branch)
567 - else:
568 - return repo.branchtags()[branch]
563 +def branch_tip(branch):
564 + return branches[branch][-1]
565
566 def get_branch_tip(repo, branch):
567 global branches
@@ -577,7 +573,7 @@ def get_branch_tip(repo, branch):
573 # verify there's only one head
574 if (len(heads) > 1):
575 warn("Branch '%s' has more than one head, consider merging" % branch)
580 - return branch_tip(repo, hgref(branch))
576 + return branch_tip(hgref(branch))
577
578 return heads[0]
579
@@ -828,7 +824,7 @@ def parse_tag(parser):
824
825 def write_tag(repo, tag, node, msg, author):
826 branch = repo[node].branch()
831 - tip = branch_tip(repo, branch)
827 + tip = branch_tip(branch)
828 tip = repo[tip]
829
830 def getfilectx(repo, memctx, f):