1 import sys
   2 results = {}
   3 buf = ''
   4 fname = ''
   5 for line in sys.stdin:
   6     if line.startswith('---'):
   7         if buf:
   8             if buf in results:
   9                 results[buf].extend([fname])
  10             else:
  11                 results[buf] = [fname]
  12         buf = ''
  13         fname = line.split(' ')[1]
  14     elif line.startswith('+++'):
  15         pass
  16     elif line.startswith('@@'):
  17         if buf:
  18             if buf in results:
  19                 results[buf].extend([fname])
  20             else:
  21                 results[buf] = [fname]
  22         buf = ''
  23     else:
  24         buf += line
  25 
  26 for key in results.iterkeys():
  27     print "From %s" % ', '.join(results[key])
  28     print "="*68
  29     print '   %s' % '\n   '.join(key.splitlines())
  30     print