def _write_todo(self, commits, *args, **kwargs):
        todo_file = os.path.join(self.repo.git_dir, REBASE_EDITOR_TODO)
        if os.path.exists(todo_file):
            os.remove(todo_file)

        if not os.path.exists(os.path.dirname(todo_file)):
            os.mkdir(os.path.dirname(todo_file))

        # see if onto is set in the args or kwargs
        onto = kwargs.get('onto', None)
        for idx, arg in enumerate(args):
            if arg.startswith("--onto"):
                # either onto is after the option in this arg, or it's the
                # next arg, or not providing it is an exception
                onto = arg[7:] or args[idx + 1]
                break

        root = None
        with codecs.open(todo_file, "w", "utf-8") as todo:
            for commit in commits:
                if not root:
                    root = commit.parents[0]
                subject = commit.message.splitlines()[0]
                todo.write("pick %s %s\n" % (self._shorten(commit), subject))

            # if root isn't set at this point, then there were no commits
            if not root:
                todo.write("noop\n")

            todo.write(TODO_EPILOGUE %
                       {'shortrevisions': "%s..%s" % (self._shorten(root),
                                                      self._shorten(commit)),
                        'shortonto': self._shorten(onto or root)})

        return todo_file
dataset/ETHPy150Open openstack/git-upstream/git_upstream/lib/rebaseeditor.py/RebaseEditor._write_todo/original