function drush_pm_cvs

3.x cvs.inc drush_pm_cvs($project, $release)
4.x cvs.inc drush_pm_cvs(&$project, $release)

General CVS helper function.

Parameters

$project The project array with name, base and full (final) paths.:

$release The release details array from drupal.org:

2 calls to drush_pm_cvs()
package_handler_download_project in commands/pm/package_handler/cvs.inc
Install a project.
package_handler_update_project in commands/pm/package_handler/cvs.inc
Update a project (so far, only modules are supported).

File

commands/pm/package_handler/cvs.inc, line 75
Drush PM CVS extension

Code

function drush_pm_cvs(&$project, $release) {
  // Build the cvs command to execute.
  $command = array('cvs');

  // Global options.
  $command[] = '-z6';
  // cvs root.
  $cvsroot = '-d:pserver:' . drush_get_option('cvscredentials', 'anonymous:anonymous') . '@cvs.drupal.org:/cvs/';
  $cvsroot .= ($project['project_type'] == 'core') ? 'drupal' : 'drupal-contrib';
  $command[] = $cvsroot;

  // CVS command ("cvs method").
  $cvsmethod = drush_get_option('cvsmethod', FALSE);
  if (empty($cvsmethod)) {
    $cvsmethod = 'checkout';
    // If we have an existing working copy we update.
    if (is_dir($project['full_project_path'] . '/CVS')) {
      $cvsmethod = 'update';
    }
  }
  $command[] = $cvsmethod;

  // CVS command options.
  $cvsparams = drush_get_option('cvsparams', FALSE);
  // common options for any command.
  $command[] = '-r ' . $release['tag'];
  // command specific options.
  if ($cvsmethod == 'checkout') {
    // checkout dir.
    $command[] = '-d ' . $project['project_dir'];
    // path to cvs 'module' to check out.
    if ($project['project_type'] == 'core') {
      $command[] = $project['name']; // drupal
    }
    else {
      // strtr for 'theme engine' type.
      $command[] = 'contributions/' . strtr($project['project_type'], ' ', '-') . 's/' . $project['name'];
    }
  }
  else {
    if ($cvsparams === FALSE) {
      // By default we update overwriting changes, however if we have an
      // existing CVS checkout that is version controlled then the default is
      // to update in place, which will attempt to merge changes but we assume
      // anyone using a VCS is competent enough to deal with this!
      $reserved_files = drush_version_control_reserved_files();
      $overwrite = TRUE;
      foreach ($reserved_files as $file) {
        if (file_exists($project['full_project_path'] . '/' . $file)) {
          $overwrite = FALSE;
          break;
        }
      }
      $command[] = $overwrite ? '-dPC' : '-dP';
    }
    // Directory to work on.
    $command[] = $project['project_dir'];
  }

  // CVS only accepts relative paths. We will cd in the checkout path right
  // before running the cvs command.
  if (!drush_shell_cd_and_exec($project['base_project_path'], implode(' ', $command))) {
    return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', dt('Unable to !op !project from cvs.drupal.org.', array('!op' => $cvsmethod, '!project' => $project['name'])));
  }
}