public function drush_version_control_svn::pre_update

8.0.x svn.inc public drush_version_control_svn::pre_update(&$project, $items_to_test = array())
6.x svn.inc public drush_version_control_svn::pre_update(&$project, $items_to_test = array())
7.x svn.inc public drush_version_control_svn::pre_update(&$project, $items_to_test = array())
5.x svn.inc public drush_version_control_svn::pre_update(&$project, $items_to_test = array())
master svn.inc public drush_version_control_svn::pre_update(&$project, $items_to_test = array())

Implementation of pre_update().

Overrides drush_version_control::pre_update

File

commands/pm/version_control/svn.inc, line 13
Drush pm SVN extension

Class

drush_version_control_svn

Code

public function pre_update(&$project, $items_to_test = array()) {
  // If items to test is empty, test everything; otherwise, pass just
  // the list of files to test to svn status.
  $args = array_keys($items_to_test);
  array_unshift($args, 'svn status ' . drush_get_option('svnstatusparams') . str_repeat('%s ', count($args)));
  array_unshift($args, $project['full_project_path']);
  if (call_user_func_array('drush_shell_cd_and_exec', $args)) {
    $output = preg_grep('/^[ ACDMRX?!~][ CM][ L][ +][ SX][ K]/', drush_shell_exec_output());
    if (!empty($output)) {
      return drush_set_error('DRUSH_PM_SVN_LOCAL_CHANGES', dt("The SVN working copy at !path appears to have uncommitted changes (see below). Please commit or revert these changes before continuing:\n!output", array('!path' => $project['full_project_path'], '!output' => implode("\n", $output))));
    }
  }
  else {
    return drush_set_error('DRUSH_PM_SVN_NOT_FOUND', dt("Drush was unable to get the svn status on !path.\nThe specific errors are below:\n!errors", array('!path' => $project['full_project_path'], '!errors' => implode("\n", drush_shell_exec_output()))));
  }

  // Check for incoming updates
  $args = array_keys($items_to_test);
  array_unshift($args, 'svn status -u ' . drush_get_option('svnstatusparams') . str_repeat('%s ', count($args)));
  array_unshift($args, $project['full_project_path']);
  if (call_user_func_array('drush_shell_cd_and_exec', $args)) {
    $output = preg_grep('/\*/', drush_shell_exec_output());
    if (!empty($output)) {
      return drush_set_error('DRUSH_PM_SVN_REMOTE_CHANGES', dt("The SVN working copy at !path appears to be out of date with the repository (see below). Please run 'svn update' to pull down changes before continuing:\n!output", array('!path' => $project['full_project_path'], '!output' => implode("\n", $output))));
    }
  }
  else {
    return drush_set_error('DRUSH_PM_SVN_NOT_FOUND', dt("Drush was unable to get the svn remote status on !path. Check that you have connectivity to the repository.\nThe specific errors are below:\n!errors", array('!path' => $project['full_project_path'], '!errors' => implode("\n", drush_shell_exec_output()))));
  }
  return TRUE;
}