def walk_branches(self, sort, *branches):
        """
        Simple iterator which take a sorting strategy and some branch and
        iterates through those branches one commit at a time, yielding a list
        of commits

        :param sort: a sorting option `GIT_SORT_NONE, GIT_SORT_TOPOLOGICAL,
        GIT_SORT_TIME, GIT_SORT_REVERSE`. Default is 'GIT_SORT_TOPOLOGICAL'
        :param branches: branch to iterate through
        :type branches: list
        :returns: yields a list of commits corresponding to given branches
        :rtype: list

        """

        iterators = [self._repo.walk(branch.target, sort)
                     for branch in branches]
        stop_iteration = [False for branch in branches]

        commits = []
        for iterator in iterators:
            try:
                commit = next(iterator)
            except StopIteration:
                commit = None
            commits.append(commit)

        yield (commit for commit in commits)

        while not all(stop_iteration):
            for index, iterator in enumerate(iterators):
                try:
                    commit = next(iterator)
                    commits[index] = commit
                except __HOLE__:
                    stop_iteration[index] = True

            if not all(stop_iteration):
                yield (commit for commit in commits)
dataset/ETHPy150Open PressLabs/gitfs/gitfs/repository.py/Repository.walk_branches