def change_from_change_spec(change):
  """Converts a change in change_spec format to buildbucket format.

  For more info on change_spec format, see
  master.chromium_step.AnnotationObserver.insertSourceStamp.

  Buildbucket change format is described in README.md.
  """
  create_ts = None
  if 'when_timestamp' in change:
    # Convert from seconds to microseconds since Unix Epoch.
    assert isinstance(change['when_timestamp'], (int, float))
    create_ts = change['when_timestamp'] * 1000 * 1000

  return {
      'revision': change.get('revision'),
      'author': {
          # Assuming author is email.
          'email': change.get('author'),
      },
      'create_ts': create_ts,
      'files': [{'path': f} for f in change.get('files', [])],
      'message': change.get('comments'),
      'branch': change.get('branch'),
      'url': change.get('revlink'),
      'project': change.get('project'),
  }