def _get_revert_subject(original_subject):
  """Creates and returns a subject for the revert CL.

  If the original CL was a revert CL then 'Revert of' is replaced with
  'Reland of'.
  If the original CL was a reland CL then 'Reland of' is replaced
  with 'Revert of'.
  All other CLs get 'Revert of' prefixed to the subject.
  """
  if original_subject.startswith('Revert of '):
    # This is going to be a revert of a revert, i.e. a reland.
    original_subject = original_subject.lstrip('Revert of ')
    return 'Reland of %s' % original_subject
  elif original_subject.startswith('Reland of '):
    # This is going to be a revert of a reland, i.e. a revert.
    original_subject = original_subject.lstrip('Reland of ')
  return 'Revert of %s' % original_subject