Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2013-04-23 01:55:13 +0400
committerJunio C Hamano <gitster@pobox.com>2013-04-23 02:25:53 +0400
commitaeebca0bd280a67003545d36f1886bfdcd9318fe (patch)
tree298651b8a5452293b70d05d90c73dafa1350a2ca /contrib
parent7e31e1fea5c827f392babacef1c8783313eb19c9 (diff)
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>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/remote-helpers/git-remote-hg11
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index a4db5b07bc..bd93f82857 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]