Consolidate adjacent lines, if same commit ID.

        Will modify line number to be a range, when two or more lines with the
        same commit ID.

def sort(self):
        """Consolidate adjacent lines, if same commit ID.

        Will modify line number to be a range, when two or more lines with the
        same commit ID.
        """
        self.sorted_commits = []
        if not self.commits:
            return self.sorted_commits
        prev_commit = self.commits.pop(0)
        prev_line = prev_commit.line_number
        prev_uuid = prev_commit.uuid
        for commit in self.commits:
            if (commit.uuid != prev_uuid or
                    commit.line_number != (prev_line + 1)):
                prev_commit.lines = self.line_range(prev_commit.line_number,
                                                    prev_line)
                self.sorted_commits.append(prev_commit)
                prev_commit = commit
            prev_line = commit.line_number
            prev_uuid = commit.uuid
        # Take care of last commit
        prev_commit.lines = self.line_range(prev_commit.line_number, prev_line)
        self.sorted_commits.append(prev_commit)
        return self.sorted_commits