Returns the set of line numbers corresponding to the lines that were
 changed in a specified file.
548945
def modified_lines_in_file(file)
      subcmd = 'show --format=%n'
      @modified_lines ||= {}
      @modified_lines[file] ||=
        Overcommit::GitRepo.extract_modified_lines(file, subcmd: subcmd)
    end
80560
def copy_all_lines_from_to(inputFile, outputFile):
    """"""
    currentLine = inputFile.readline()
    while currentLine:
        outputFile.write(currentLine)
        currentLine = inputFile.readline()
345945
def get_line_numbers(self, buffer):
        
        # Get absolute cursor positions from the text object.
        from_, to = self.operator_range(buffer.document)
        from_ += buffer.cursor_position
        to += buffer.cursor_position

        # Take the start of the lines.
        from_, _ = buffer.document.translate_index_to_position(from_)
        to, _ = buffer.document.translate_index_to_position(to)

        return from_, to
498337
def lines(self) -> str:
        """"""
        if self.definition is None:
            return ''
        source = ''
        lines = self.definition.source
        offset = self.definition.start  # type: ignore
        lines_stripped = list(reversed(list(dropwhile(is_blank,
                                                      reversed(lines)))))
        numbers_width = len(str(offset + len(lines_stripped)))
        line_format = '{{:{}}}:{{}}'.format(numbers_width)
        for n, line in enumerate(lines_stripped):
            if line:
                line = ' ' + line
            source += line_format.format(n + offset, line)
            if n > 5:
                source += '        ...\n'
                break
        return source
1287436
def files_changed():
    
    with chdir(get_root()):
        result = run_command('git diff --name-only master...', capture='out')
    changed_files = result.stdout.splitlines()

    # Remove empty lines
    return [f for f in changed_files if f]
779971
def diff_texts(a, b, filename):
    """"""
    a = a.splitlines()
    b = b.splitlines()
    return difflib.unified_diff(a, b, filename, filename,
                                "(original)", "(refactored)",
                                lineterm="")
671950
public static ArrayList<String> getFilteredLinesFromFile(final String fileName, final String filter)
      throws IOException {
    return getFilteredLinesFromFile(fileName, filter, null, null);
  }
892068
def getlines(filename, opts=default_opts):
    
    if get_option('reload_on_change', opts): checkcache(filename)
    fmt = get_option('output', opts)
    highlight_opts = {'bg': fmt}
    cs = opts.get('style')

    # Colorstyle of Terminal255Formatter takes precidence over
    # light/dark colorthemes of TerminalFormatter
    if cs:
        highlight_opts['style'] = cs
        fmt = cs

    if filename not in file_cache:
        update_cache(filename, opts)
        filename = pyc2py(filename)
        if filename not in file_cache: return None
        pass
    lines = file_cache[filename].lines
    if fmt not in lines.keys():
        lines[fmt] = highlight_array(lines['plain'], **highlight_opts)
        pass
    return lines[fmt]
612631
def _file_lines(self, filename):
        """"""
        try:
            return self._file_lines_cache[filename]
        except KeyError:
            if os.path.isfile(filename):
                with open(filename) as python_file:
                    self._file_lines_cache[filename] = python_file.readlines()
            else:
                self._file_lines_cache[filename] = ""

            return self._file_lines_cache[filename]
21256
def modified_lines_in_file(file)
      @modified_lines ||= {}
      unless @modified_lines[file]
        @modified_lines[file] =
          Overcommit::GitRepo.extract_modified_lines(file, staged: true)

        # Include lines modified in last commit if amending
        if amendment?
          subcmd = 'show --format=%n'
          @modified_lines[file] +=
            Overcommit::GitRepo.extract_modified_lines(file, subcmd: subcmd)
        end
      end
      @modified_lines[file]
    end
520745
def process_lines_with_differences(oldline, newline)
        start, ending = get_change_extent(oldline, newline)
        
        if start.zero? && ending.zero?
          process_line(oldline, :rem, false) # -
          process_line(newline, :add, false) # +
        else
          # -
          line = inline_diff(oldline, start, ending)
          process_line(line, :rem, true)
          # +
          line = inline_diff(newline, start, ending)
          process_line(line, :add, true)
        end
      end
248522
def get_user_modified_lines(self):
        
        # I assume that git diff:
        # - doesn't mix diffs from different files,
        # - diffs are not overlapping
        # - diffs are sorted based on line numbers
        output = {}

        FILE_NAME_RE = r'^\+\+\+ (.+)$'
        CHANGED_LINES_RE = r'^@@ -[0-9,]+ \+([0-9]+)(?:,([0-9]+))? @@'
        current_file_name = None

        for line in self.git_wrapper.get_min_diff(self.remote_sha1, self.local_sha1).split('\n'):
            file_name_match = re.match(FILE_NAME_RE, line)
            if file_name_match:
                current_file_name, = file_name_match.groups()
                output[current_file_name] = []
                continue

            line_number_match = re.match(CHANGED_LINES_RE, line)
            if line_number_match:
                assert current_file_name
                if current_file_name == '/dev/null':
                    continue
                line_start, diff_len = line_number_match.groups()
                line_start, diff_len = int(line_start), int(diff_len or 0)
                output[current_file_name].append(LinesRange(line_start, line_start + diff_len))
                continue

        return output
27046
def get_line_number (s, index):
    """
    i = 0
    if index < 0:
        return 0
    line = 1
    while i < index:
        if s[i] == '\n':
            line += 1
        i += 1
    return line
615527
def read_set_from_file(filename: str) -> Set[str]:
    
    collection = set()
    with open(filename, 'r') as file_:
        for line in file_:
            collection.add(line.rstrip())
    return collection
945583
def extract_modified_lines(file_path, options)
      lines = Set.new

      flags = '--cached' if options[:staged]
      refs = options[:refs]
      subcmd = options[:subcmd] || 'diff'

      `git #{subcmd} --no-color --no-ext-diff -U0 #{flags} #{refs} -- "#{file_path}"`.
        scan(DIFF_HUNK_REGEX) do |start_line, lines_added|
        lines_added = (lines_added || 1).to_i # When blank, one line was added
        cur_line = start_line.to_i

        lines_added.times do
          lines.add cur_line
          cur_line += 1
        end
      end

      lines
    end
1012743
function(lines) {
		let output = [];
		let newlineCount = 0;
		for (let i = 0; i < lines.length; i++) {
			const line = lines[i];
			if (!line.trim()) {
				newlineCount++;
			} else {
				newlineCount = 0;
			}

			if (newlineCount >= 2) continue;

			output.push(line);
		}
		return output;
	}
311039
def get_unaligned_lines(self):
    """"""
    sys.stderr.write("error unimplemented get_unaligned_lines\n")
    sys.exit()
    return [self._lines[x-1] for x in self._unaligned]