def branch_scheme(version):
    """
    Local version scheme that adds the branch name for absolute reproducibility.

    If and when this is added to setuptools_scm this function and file can be removed.
    """
    if version.exact or version.node is None:
        return version.format_choice('', '+d{time:{time_format}}',
            time_format='%Y%m%d')
    elif version.branch == 'master':
        return version.format_choice('+{node}', '+{node}.dirty')
    else:
        return version.format_choice('+{node}.{branch}',
            '+{node}.{branch}.dirty')
