'Set the commit message to match the observed model'

def set_commit_message(self, message):

    lines = message.splitlines()
    num_lines = len(lines)
    if (num_lines == 0):
        summary = u''
        description = u''
    elif (num_lines == 1):
        summary = lines[0]
        description = u''
    elif (num_lines == 2):
        summary = lines[0]
        description = lines[1]
    else:
        summary = lines[0]
        if lines[1]:
            description_lines = lines[1:]
        else:
            description_lines = lines[2:]
        description = u'\n'.join(description_lines)
    focus_summary = (not summary)
    focus_description = (not description)
    self.summary.set_value(summary, block=True)
    self.description.set_value(description, block=True)
    self.refresh_palettes()
    if focus_summary:
        self.summary.setFocus()
    elif focus_description:
        self.description.setFocus()
    else:
        self.summary.cursor_position.emit()
    self.update_actions()
