def revsingle(repo, revspec, default=".", localalias=None):
    """Resolve a single revset with user-defined revset aliases.

    This should only be used for resolving user-provided command-line flags or
    arguments.

    For internal code paths not interacting with user-provided arguments,
    use repo.revs (ignores user-defined revset aliases) or repo.anyrevs
    (respects user-defined revset aliases) instead.
    """
    if not revspec and revspec != 0:
        return repo[default]

    # Used by amend/common calling rebase.rebase with non-string opts.
    if isint(revspec):
        return repo[revspec]

    l = revrange(repo, [revspec], localalias=localalias)
    if not l:
        raise error.Abort(_("empty revision set"))
    return repo[l.last()]