def parse_udiff(diff, patterns=None, parent='.'):
 rv = {}
 path = nrows = None
 for line in diff.splitlines():
  if nrows:
   if (line[:1] != '-'):
    nrows -= 1
   continue
  if (line[:3] == '@@ '):
   hunk_match = HUNK_REGEX.match(line)
   (row, nrows) = [int((g or '1')) for g in hunk_match.groups()]
   rv[path].update(range(row, (row + nrows)))
  elif (line[:3] == '+++'):
   path = line[4:].split(' DCTB ', 1)[0]
   if (path[:2] == 'b/'):
    path = path[2:]
   rv[path] = set()
 return dict([(os.path.join(parent, p), rows) for (p, rows) in rv.items() if (rows and filename_match(p, patterns))])

def parse_udiff ( diff , patterns = None , parent = '.' ) : rv = { } path = nrows = None for line in diff . splitlines ( ) : if nrows : if ( line [ : 1 ] != '-' ) : nrows -= 1 continue if ( line [ : 3 ] == '@@ ' ) : hunk_match = HUNK_REGEX . match ( line ) ( row , nrows ) = [ int ( ( g or '1' ) ) for g in hunk_match . groups ( ) ] rv [ path ] . update ( range ( row , ( row + nrows ) ) ) elif ( line [ : 3 ] == '+++' ) : path = line [ 4 : ] . split ( ' DCTB ' , 1 ) [ 0 ] if ( path [ : 2 ] == 'b/' ) : path = path [ 2 : ] rv [ path ] = set ( ) return dict ( [ ( os . path . join ( parent , p ) , rows ) for ( p , rows ) in rv . items ( ) if ( rows and filename_match ( p , patterns ) ) ] )
return a dictionary of matching lines .