import re


def ParseRevision(lines):
  """Parse the revision number out of the raw lines of the patch.

  Returns 0 (new file) if no revision number was found.
  """
  for line in lines[:10]:
    if line.startswith('@'):
      break
    m = re.match(r'---\s.*\(.*\s(\d+)\)\s*$', line)
    if m:
      return int(m.group(1))
  return 0