def map_to_filtered(rev):
  """Gets hash of rev after filtering.

  If rev hasn't been filtered (yet), returns None.

  Equivalent to the `map` function exposed by git-filter-branch, except that
  function returns rev if the revision hasn't yet been filtered, and that this
  function raises an error if rev maps to multiple commits.
  """
  #if not workdir:
  #  raise RuntimeError("workdir environment variable is empty?")
  mapfile = '../map/%s' % rev
  try:
    with open(mapfile, 'r') as f:
      lines = f.read().strip().split('\n')
      if len(lines) != 1:
        raise RuntimeError("mapfile %s doesn't contain a single line: %s" % (mapfile, str(lines)))
      return lines[0]
  except IOError:
    return None