remote-hg: add branch_tip() helper
Idea from gitifyhg, the backwards compatibility is how Mercurial used to do it. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
7e31e1fea5
commit
aeebca0bd2
|
@ -457,6 +457,13 @@ def do_capabilities(parser):
|
||||||
|
|
||||||
print
|
print
|
||||||
|
|
||||||
|
def branch_tip(repo, branch):
|
||||||
|
# older versions of mercurial don't have this
|
||||||
|
if hasattr(repo, 'branchtip'):
|
||||||
|
return repo.branchtip(branch)
|
||||||
|
else:
|
||||||
|
return repo.branchtags()[branch]
|
||||||
|
|
||||||
def get_branch_tip(repo, branch):
|
def get_branch_tip(repo, branch):
|
||||||
global branches
|
global branches
|
||||||
|
|
||||||
|
@ -467,9 +474,7 @@ def get_branch_tip(repo, branch):
|
||||||
# verify there's only one head
|
# verify there's only one head
|
||||||
if (len(heads) > 1):
|
if (len(heads) > 1):
|
||||||
warn("Branch '%s' has more than one head, consider merging" % branch)
|
warn("Branch '%s' has more than one head, consider merging" % branch)
|
||||||
# older versions of mercurial don't have this
|
return branch_tip(repo, branch)
|
||||||
if hasattr(repo, "branchtip"):
|
|
||||||
return repo.branchtip(branch)
|
|
||||||
|
|
||||||
return heads[0]
|
return heads[0]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue