def require_existing_rev(func):
    """
        Checks to see if requested revision exists in repository.
            Raises 404 if not.
    """

    @wraps(func)
    def _decorator(request, *args, **kwargs):
        try:
            repo = Repo(Repo.get_repository_location(kwargs['username'], kwargs['repository']))
            branches = repo.get_branches()
            if 'rev' not in kwargs or kwargs['rev'] in branches + ['HEAD']:
                return func(request, *args, **kwargs)
            else:
                raise Http404()
        except:
            raise Http404()
    return _decorator
dataset/ETHPy150Open Djacket/djacket/core/backend/repository/decorators.py/require_existing_rev/original