def get_user_commit_message_parts(base_commit, head_commit, remote_branch=None):
    """Allows a user to choose a commit message for a patch set.

    If there have been no commits between base_commit and head_commit, then
    returns None. If there have been exactly one, returns that commit message,
    otherwise let's the user choose.

    Args:
        base_commit: String containing hash of the most recently used commit in
            a review.
        head_commit: String containing hash of the HEAD commit in the current
            review.
        remote_branch: String {remote}/{branch} where remote is the name of the
            remote and branch the name of a branch in that remote that this
            review is compared against. Defaults to None.

    Returns:
        Tuple of string containing the commit subject and remaining description
            as strings. This pair will have been chosen by the user.

    Raises:
        GitRvException: If there have been no commits since the last review.
    """
    commits = get_commits(base_commit, head_commit)
    if len(commits) == 0:
        raise GitRvException(NO_COMMIT_TEMPLATE % (base_commit,))

    commit_choices = {}
    for commit_hash in commits:
        commit_message_parts = get_commit_message_parts(commit_hash=commit_hash)
        single_value = '\n\n'.join(commit_message_parts)
        # Uniqueness is not an issue, since we only care about values.
        commit_choices[single_value] = commit_message_parts

    error_message_none = 'This error should never occur.'
    if remote_branch is None:
        pre_prompt_message = MESSAGE_PROMPT_IN_REVIEW
    else:
        pre_prompt_message = MESSAGE_PROMPT_PRE_REVIEW_TEMPLATE % remote_branch

    commit_choice = user_choice_from_list(
            commit_choices.keys(), pre_prompt_message, MESSAGE_CHOICE_PROMPT,
            error_message_none, INVALID_MESSAGE_CHOICE)
    return commit_choices[commit_choice]
dataset/ETHPy150Open googlearchive/git-rv/utils.py/get_user_commit_message_parts/original