def rev_list(repository, to_ref, from_ref=None, path=None, skip=0,
             max_count=0, author=None, query=None, first_parent=None,
             since=0, no_merges=None):
    """git rev-list command, pygit2 wrapper.
    But this returns a commit list"""

    if repository.is_empty:
        return []

    commits_index_list = []
    commits_dict = {}
    # TODO: use resolve_version
    to_commit = repository.revparse_single(to_ref)

    walk_order = GIT_SORT_TOPOLOGICAL if first_parent else GIT_SORT_TIME
    if to_commit.type == GIT_OBJ_TAG:
        to_commit = repository[to_commit.target]
    next_commit = None
    walker = repository.walk(to_commit.id, walk_order)
    if from_ref:
        try:
            from_commit = repository.revparse_single(from_ref)
            if from_commit.type == GIT_OBJ_TAG:
                from_commit = repository[from_commit.target]
            walker.hide(from_commit.id)
        except (KeyError, __HOLE__):
            from_commit = None

    if max_count:
        length = max_count + skip if skip else max_count
    else:
        length = 0
    for c in walker:
        if all([_check_author(c, author),
                _check_file_change(c, path),
                _check_message(c, query),
                _check_date(c, since),
                _check_no_merges(c, no_merges)]):
            index = c.hex
            if first_parent:
                if next_commit and next_commit.hex != c.hex:
                    continue
                if len(c.parents) == 0:
                    next_commit = None
                elif len(c.parents) >= 1:
                    next_commit = c.parents[0]
                else:
                    continue
            if index not in commits_index_list:
                commits_index_list.append(index)
            commits_dict[index] = c
        if length and len(commits_index_list) >= length:
            break
    if skip:
        commits_index_list = commits_index_list[skip:]
    return [format_commit(commits_dict[i], repository)
            for i in commits_index_list]
dataset/ETHPy150Open douban/ellen/ellen/git/rev_list.py/rev_list