<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def commit(self, changeset_id: uuid.UUID) -> None: """ Commits a given changeset. This merges the given changeset and all subsequent changesets into the previous changeset giving precidence to later changesets in case of any conflicting keys. If this is the base changeset then all changes will be written to the underlying database and the Journal starts a new recording. Typically, callers won't have access to the base changeset, because it is dropped during .reset() which is called in JournalDB(). """

        self._validate_changeset(changeset_id)
        journal_data = self.journal.commit_changeset(changeset_id)

        if self.journal.is_empty():
            # Ensure the journal automatically restarts recording after
            # it has been persisted to the underlying db
            self.reset()

            for key, value in journal_data.items():
                try:
                    if value is DELETED_ENTRY:
                        del self.wrapped_db[key]
                    elif value is ERASE_CREATED_ENTRY:
                        pass
                    else:
                        self.wrapped_db[key] = cast(bytes, value)
                except Exception:
                    self._reapply_changeset_to_journal(changeset_id, journal_data)
                    raise