def get_upstream(version_str):
    """Given a version string that could potentially contain both an upstream
    revision and a debian revision, return a tuple of both.  If there is no
    debian revision, return 0 as the second tuple element."""
    try:
        d_index = version_str.rindex('-')
    except ValueError:
        # no hyphens means no debian version, also valid.
        return version_str, '0'

    return version_str[0:d_index], version_str[d_index+1:]