# Buggy code
def revert_actions(prefix, revision=-1, index=None):
    # TODO: If revision raise a revision error, should always go back to a safe revision
    # change
    h = History(prefix)
    h.update()
    user_requested_specs = itervalues(h.get_requested_specs_map())
    try:
        state = h.get_state(revision)
    except IndexError:
        raise CondaIndexError("no such revision: %d" % revision)

    curr = h.get_state()
    if state == curr:
        return {}  # TODO: return txn with nothing_to_do

    _supplement_index_with_prefix(index, prefix)
    r = Resolve(index)

    state = r.dependency_sort({d.name: d for d in (Dist(s) for s in state)})
    curr = set(Dist(s) for s in curr)

    link_dists = tuple(d for d in state if not is_linked(prefix, d))
    unlink_dists = set(curr) - set(state)

    # dists = (Dist(s) for s in state)
    # actions = ensure_linked_actions(dists, prefix)
    # for dist in curr - state:
    #     add_unlink(actions, Dist(dist))

    # check whether it is a safe revision
    for dist in concatv(link_dists, unlink_dists):
        if dist not in index:
            from .exceptions import CondaRevisionError

            msg = "Cannot revert to {}, since {} is not in repodata".format(
                revision, dist
            )
            raise CondaRevisionError(msg)

    unlink_precs = tuple(index[d] for d in unlink_dists)
    link_precs = tuple(index[d] for d in link_dists)
    stp = PrefixSetup(prefix, unlink_precs, link_precs, (), user_requested_specs)
    txn = UnlinkLinkTransaction(stp)
    return txn


# Traceback (AttributeError)
error: AttributeError("'dict' object has no attribute 'get_pfe'",)
command: C:\Program Files\Anaconda3\Scripts\conda install --revision 4
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.5.2 Windows/8.1 Windows/6.3.9600
_messageid: -9223372036843575560
_messagetime: 1514442489595 / 2017-12-28 00:28:09

Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 78, in _main
exit_code = do_call(args, p)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main_install.py", line 11, in execute
install(args, parser, 'install')
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\install.py", line 232, in install
progressive_fetch_extract = unlink_link_transaction.get_pfe()
AttributeError: 'dict' object has no attribute 'get_pfe'

# Fixed code
def revert_actions(prefix, revision=-1, index=None):
    # TODO: If revision raise a revision error, should always go back to a safe revision
    # change
    h = History(prefix)
    user_requested_specs = itervalues(h.get_requested_specs_map())
    try:
        state = h.get_state(revision)
    except IndexError:
        raise CondaIndexError("no such revision: %d" % revision)

    curr = h.get_state()
    if state == curr:
        return UnlinkLinkTransaction()

    _supplement_index_with_prefix(index, prefix)
    r = Resolve(index)

    state = r.dependency_sort({d.name: d for d in (Dist(s) for s in state)})
    curr = set(Dist(s) for s in curr)

    link_dists = tuple(d for d in state if not is_linked(prefix, d))
    unlink_dists = set(curr) - set(state)

    # check whether it is a safe revision
    for dist in concatv(link_dists, unlink_dists):
        if dist not in index:
            from .exceptions import CondaRevisionError

            msg = "Cannot revert to {}, since {} is not in repodata".format(
                revision, dist
            )
            raise CondaRevisionError(msg)

    unlink_precs = tuple(index[d] for d in unlink_dists)
    link_precs = tuple(index[d] for d in link_dists)
    stp = PrefixSetup(prefix, unlink_precs, link_precs, (), user_requested_specs)
    txn = UnlinkLinkTransaction(stp)
    return txn