third_party/blink/tools/blinkpy/common/pretty_diff.py
def parse(lines):
        """Parses diff lines, and creates a DiffFile instance.

        Finds a file diff header, creates a single DiffFile instance, and
        returns a tuple of the DiffFile instance and unconsumed lines. If a file
        diff isn't found, (None, lines) is returned.
        """
        diff_command_re = r'diff (?:-[^ ]+ )*a/([^ ]+) b/([^ ]+)'
        old_name = None
        new_name = None
        info_lines = None
        found_diff_command_line = False
        for i, line in enumerate(lines):
            if not found_diff_command_line:
                match = re.match(diff_command_re, line)
                if not match:
                    continue
                old_name = match.group(1)
                new_name = match.group(2)
                info_lines = []
                found_diff_command_line = True
                continue

            match = re.match(r'(GIT binary patch|--- ([^ ]+).*)', line)
            if match:
                if match.group(0) == 'GIT binary patch':
                    return DiffFile._parse_binaries(lines[i + 1:], old_name,
                                                    new_name)
                return DiffFile._parse_text_hunks(lines[i:], old_name,
                                                  new_name)

            index_match = re.match(r'^index ([0-9a-f]+)\.\.([0-9a-f]+).*',
                                   line)
            if index_match:
                # Adjusts old_name and new_name for file addition/removal.
                old_name, new_name = DiffFile._adjust_names(
                    index_match, old_name, new_name)
                continue

            diff_match = re.match(diff_command_re, line)
            if diff_match:
                # There are no hunks. Renaming without any modification,
                # or adding/removing an empty file.
                return (DiffFile(old_name, new_name, info=info_lines),
                        lines[i:])

            # File mode, rename summary, etc.
            info_lines.append(line)

        if found_diff_command_line and info_lines:
            return (DiffFile(old_name, new_name, info=info_lines), [])
        return (None, lines)
Parses diff lines, and creates a DiffFile instance.

        Finds a file diff header, creates a single DiffFile instance, and
        returns a tuple of the DiffFile instance and unconsumed lines. If a file
        diff isn't found, (None, lines) is returned.
        
Parses diff lines, and creates a DiffFile instance.
Finds a file diff header, creates a single DiffFile instance, and
returns a tuple of the DiffFile instance and unconsumed lines. If a file
diff isn't found, (None, lines) is returned.
Parses diff lines and creates a DiffFile instance . Finds a file diff header creates a single DiffFile instance and returns a tuple of the DiffFile instance and unconsumed lines . If a file diff isn ' t found ( None lines ) is returned .
def parse(lines):
        diff_command_re = r'diff (?:-[^ ]+ )*a/([^ ]+) b/([^ ]+)'
        old_name = None
        new_name = None
        info_lines = None
        found_diff_command_line = False
        for i, line in enumerate(lines):
            if not found_diff_command_line:
                match = re.match(diff_command_re, line)
                if not match:
                    continue
                old_name = match.group(1)
                new_name = match.group(2)
                info_lines = []
                found_diff_command_line = True
                continue
            match = re.match(r'(GIT binary patch|--- ([^ ]+).*)', line)
            if match:
                if match.group(0) == 'GIT binary patch':
                    return DiffFile._parse_binaries(lines[i + 1:], old_name,
                                                    new_name)
                return DiffFile._parse_text_hunks(lines[i:], old_name,
                                                  new_name)
            index_match = re.match(r'^index ([0-9a-f]+)\.\.([0-9a-f]+).*',
                                   line)
            if index_match:
                old_name, new_name = DiffFile._adjust_names(
                    index_match, old_name, new_name)
                continue
            diff_match = re.match(diff_command_re, line)
            if diff_match:
                return (DiffFile(old_name, new_name, info=info_lines),
                        lines[i:])
            info_lines.append(line)
        if found_diff_command_line and info_lines:
            return (DiffFile(old_name, new_name, info=info_lines), [])
        return (None, lines)
def parse ( lines ) : diff_command_re = r'diff (?:-[^ ]+ )*a/([^ ]+) b/([^ ]+)' old_name = None new_name = None info_lines = None found_diff_command_line = False for i , line in enumerate ( lines ) : if not found_diff_command_line : match = re . match ( diff_command_re , line ) if not match : continue old_name = match . group ( 1 ) new_name = match . group ( 2 ) info_lines = [ ] found_diff_command_line = True continue match = re . match ( r'(GIT binary patch|--- ([^ ]+).*)' , line ) if match : if match . group ( 0 ) == 'GIT binary patch' : return DiffFile . _parse_binaries ( lines [ i + 1 : ] , old_name , new_name ) return DiffFile . _parse_text_hunks ( lines [ i : ] , old_name , new_name ) index_match = re . match ( r'^index ([0-9a-f]+)\.\.([0-9a-f]+).*' , line ) if index_match : old_name , new_name = DiffFile . _adjust_names ( index_match , old_name , new_name ) continue diff_match = re . match ( diff_command_re , line ) if diff_match : return ( DiffFile ( old_name , new_name , info = info_lines ) , lines [ i : ] ) info_lines . append ( line ) if found_diff_command_line and info_lines : return ( DiffFile ( old_name , new_name , info = info_lines ) , [ ] ) return ( None , lines )
Parses diff lines, and creates a DiffFile instance.
Parses diff lines and creates a DiffFile instance .
"""Parses diff lines, and creates a DiffFile instance.

        Finds a file diff header, creates a single DiffFile instance, and
        returns a tuple of the DiffFile instance and unconsumed lines. If a file
        diff isn't found, (None, lines) is returned.
        """ # Adjusts old_name and new_name for file addition/removal. # There are no hunks. Renaming without any modification, # or adding/removing an empty file. # File mode, rename summary, etc.
lines