nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, for_statement; 13, comment:# Take care of last commit; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, comment:"""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.
          """; 18, assignment; 19, not_operator; 20, block; 21, assignment; 22, assignment; 23, assignment; 24, identifier:commit; 25, attribute; 26, block; 27, assignment; 28, call; 29, attribute; 30, attribute; 31, list; 32, attribute; 33, return_statement; 34, identifier:prev_commit; 35, call; 36, identifier:prev_line; 37, attribute; 38, identifier:prev_uuid; 39, attribute; 40, identifier:self; 41, identifier:commits; 42, if_statement; 43, expression_statement; 44, expression_statement; 45, attribute; 46, call; 47, attribute; 48, argument_list; 49, identifier:self; 50, identifier:sorted_commits; 51, identifier:self; 52, identifier:sorted_commits; 53, identifier:self; 54, identifier:commits; 55, attribute; 56, attribute; 57, argument_list; 58, identifier:prev_commit; 59, identifier:line_number; 60, identifier:prev_commit; 61, identifier:uuid; 62, parenthesized_expression; 63, block; 64, assignment; 65, assignment; 66, identifier:prev_commit; 67, identifier:lines; 68, attribute; 69, argument_list; 70, attribute; 71, identifier:append; 72, identifier:prev_commit; 73, identifier:self; 74, identifier:sorted_commits; 75, attribute; 76, identifier:pop; 77, integer:0; 78, boolean_operator; 79, expression_statement; 80, expression_statement; 81, expression_statement; 82, identifier:prev_line; 83, attribute; 84, identifier:prev_uuid; 85, attribute; 86, identifier:self; 87, identifier:line_range; 88, attribute; 89, identifier:prev_line; 90, identifier:self; 91, identifier:sorted_commits; 92, identifier:self; 93, identifier:commits; 94, comparison_operator:commit.uuid != prev_uuid; 95, comparison_operator:commit.line_number != (prev_line + 1); 96, assignment; 97, call; 98, assignment; 99, identifier:commit; 100, identifier:line_number; 101, identifier:commit; 102, identifier:uuid; 103, identifier:prev_commit; 104, identifier:line_number; 105, attribute; 106, identifier:prev_uuid; 107, attribute; 108, parenthesized_expression; 109, attribute; 110, call; 111, attribute; 112, argument_list; 113, identifier:prev_commit; 114, identifier:commit; 115, identifier:commit; 116, identifier:uuid; 117, identifier:commit; 118, identifier:line_number; 119, binary_operator:prev_line + 1; 120, identifier:prev_commit; 121, identifier:lines; 122, attribute; 123, argument_list; 124, attribute; 125, identifier:append; 126, identifier:prev_commit; 127, identifier:prev_line; 128, integer:1; 129, identifier:self; 130, identifier:line_range; 131, attribute; 132, identifier:prev_line; 133, identifier:self; 134, identifier:sorted_commits; 135, identifier:prev_commit; 136, identifier:line_number
code: 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