docs: def modified_lines(filename, extra_data, commit=None):
      """Returns the lines that have been modifed for this file.
  
      Args:
        filename: the file to check.
        extra_data: is the extra_data returned by modified_files. Additionally, a
          value of None means that the file was not modified.
        commit: the complete sha1 (40 chars) of the commit. Note that specifying
          this value will only work (100%) when commit == last_commit (with
          respect to the currently checked out revision), otherwise, we could miss
          some lines.
  
      Returns: a list of lines that were modified, or None in case all lines are
        new.
      """
      if extra_data is None:
          return []
      if extra_data != 'M':
          return None
  
      command = ['hg', 'diff', '-U', '0']
      if commit:
          command.append('--change=%s' % commit)
      command.append(filename)
  
      # Split as bytes, as the output may have some non unicode characters.
      diff_lines = subprocess.check_output(command).split(
          os.linesep.encode('utf-8'))
      diff_line_numbers = utils.filter_lines(
          diff_lines,
          br'@@ -\d+,\d+ \+(?P<start_line>\d+),(?P<lines>\d+) @@',
          groups=('start_line', 'lines'))
      modified_line_numbers = []
      for start_line, lines in diff_line_numbers:
          start_line = int(start_line)
          lines = int(lines)
          modified_line_numbers.extend(range(start_line, start_line + lines))
  
      return modified_line_numbers