def stat_ahead_behind(git, local_ref, remote_ref):
    """ Returns a tuple (ahead, behind) describing how far
    from the remote ref the local ref is

    """
    behind = 0
    ahead = 0
    (ret, out) = git.call("rev-list", "--left-right",
                          "%s..%s" % (remote_ref, local_ref), raises=False)
    if ret == 0:
        ahead = len(out.split())
    (ret, out) = git.call("rev-list", "--left-right",
                          "%s..%s" % (local_ref, remote_ref), raises=False)
    if ret == 0:
        behind = len(out.split())
    return (ahead, behind)
dataset/ETHPy150Open aldebaran/qibuild/python/qisrc/status.py/stat_ahead_behind/original