Drupal 7 revert feature programatically

Sometimes we need to revert feature programatically, for example using hook_update_N().

/**
 * Revert feature.
 */
function mymodule_update_7001() {
  //Need to revert this feature to make something later (example delete field).
  $feature = features_get_features('feature_name');
  if (!empty($feature->info['features'])) {
    $components = array_keys($feature->info['features']);
    features_revert(array('feature_name' => $components));
  }
}