public function drush_version_control_bzr::pre_update

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

Implementation of pre_update().

Check that the project or drupal core directory looks clean

Overrides drush_version_control::pre_update

File

commands/pm/version_control/bzr.inc, line 15
Drush pm Bazaar extension

Class

drush_version_control_bzr

Code

public function pre_update(&$project, $items_to_test = array()) {
  // Bazaar needs a list of items to test within the given project.
  // If $items_to_test is empty we need to force it to test the project
  // directory itself --once we've cd'ed to it.
  if (empty($items_to_test)) {
    $items_to_test = array('.' => '.');
  }
  $args = array_keys($items_to_test);
  array_unshift($args, 'bzr status --short' . 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('/^[\sRCP][\sNDKM][\s\*]/', drush_shell_exec_output());
    if (!empty($output)) {
      return drush_set_error('DRUSH_PM_BZR_LOCAL_CHANGES', dt("The Bazaar 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_BZR_NOT_FOUND', dt("Drush was unable to get the bzr status on !path. Check that you have Bazaar \ninstalled and that this directory is a Bazaar working copy.\nThe specific errors are below:\n!errors", array('!path' => $project['full_project_path'], '!errors' => implode("\n", drush_shell_exec_output()))));
  }
  return TRUE;
}