[PATCH 05/16] remote-hg: add branch_tip() helper
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- Apr 22, 2013, 21:55 UTC
- Message-ID
- <1366667724-567-6-git-send-email-felipe.contreras@gmail.com>
- In-Reply-To
- <1366667724-567-1-git-send-email-felipe.contreras@gmail.com>
Idea from gitifyhg, the backwards compatibility is how Mercurial used to do it.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- contrib/remote-helpers/git-remote-hg | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index a4db5b0..bd93f82 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -457,6 +457,13 @@ def do_capabilities(parser): 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): global branches @@ -467,9 +474,7 @@ def get_branch_tip(repo, branch): # verify there's only one head if (len(heads) > 1): warn("Branch '%s' has more than one head, consider merging" % branch) - # older versions of mercurial don't have this - if hasattr(repo, "branchtip"): - return repo.branchtip(branch) + return branch_tip(repo, branch) return heads[0]
-- 1.8.2.1.790.g4588561