You are here

function drush_hacked_lock_modified in Hacked! 6.2

Same name and namespace in other branches
  1. 8.2 hacked.drush.inc \drush_hacked_lock_modified()
  2. 7.2 hacked.drush.inc \drush_hacked_lock_modified()

Lock all of the modified files so that pm-updatecode will not touch them.

1 call to drush_hacked_lock_modified()
drush_hacked_pre_pm_updatecode in ./hacked.drush.inc
Add a --lock-modified flag to pm-updatecode

File

./hacked.drush.inc, line 194
Hacked drush command.

Code

function drush_hacked_lock_modified() {
  $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');
  module_load_include('inc', 'update', 'update.report');
  if (isset($drupal_root) && ($available = update_get_available(TRUE))) {
    module_load_include('inc', 'update', 'update.compare');
    $data = update_calculate_project_data($available);
    $projects = hacked_calculate_project_data_drush($data, TRUE);
    foreach ($projects as $project) {
      $row = array(
        empty($project['title']) ? $project['name'] : $project['title'],
        $project['name'],
        $project['existing_version'],
      );

      // Lock the file if it is not already locked.
      switch ($project['status']) {
        case HACKED_STATUS_HACKED:
          $project_ob = NULL;
          $project_ob = hacked_project_load($project['project_name']);
          $lockfile = $project_ob
            ->file_get_location('local', '.drush-lock-update');
          if (!file_exists($lockfile)) {
            drush_op('file_put_contents', $lockfile, dt("Locked: modified."));
            drush_print(dt("Locked: @project", array(
              '@project' => $project['name'],
            )));
          }
          else {
            drush_print(dt("@project is modified and already locked", array(
              '@project' => $project['name'],
            )));
          }
          break;
        case HACKED_STATUS_UNHACKED:
        case HACKED_STATUS_UNCHECKED:
        default:
          break;
      }
    }
  }
}