def _compact_repr(m):
  """Returns a compact representation of message 'm'.

  Args:
    m: A protocol buffer message instance.

  Returns:
    A compact string representation of 'm' with all newlines replaced with
    spaces, and stringd multiple spaces replaced with just one.
  """
  s = repr(m).replace('\n', ' ')
  while '  ' in s:
    s = s.replace('  ', ' ')
  return s.strip()