def branch_tip(repo, branch):
    """HG has a lovely branch_tip method, but it requires mercurial 2.4
    This function provides backwards compatibility. If we ever get to
    drop older versions, we can drop this function."""
    if hasattr(repo, 'branchtip'):
        return repo.branchtip(branch)
    else:
        return repo.branchtags()[branch]
