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_install_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 58
Drush PM CVS extension

Code

function drush_pm_cvs($project, $release) {
  // By default we assume a module
  $repos = 'drupal-contrib';
  $cvsdir = 'contributions/modules/';

  switch ($project['project_type']) {
    case 'theme':
      $cvsdir = 'contributions/themes/';
      break;
    case 'theme engine':
      $cvsdir = 'contributions/theme-engines/';
      break;
    case 'translation':
      drush_set_error('DRUSH_PM_CVS_NO_TRANSLATIONS', 'You cannot install translations with CVS, because they require processing (normally done on drupal.org to produce the tar.gz files).');
      exit();
    case 'profile':
      $cvsdir = 'contributions/profiles/';
      break;
    case 'core':
      $cvsdir = '';
      $repos = 'drupal';
  }

  $cvsmethod = drush_get_option('cvsmethod', FALSE);
  $cvsparams = drush_get_option('cvsparams', FALSE);
  // Determine reasonable defaults, based on context.
  if (empty($cvsmethod)) {
    $cvsmethod = 'checkout';
    // If we have an existing working copy we update.
    if (is_dir($project['full_project_path'] . '/CVS')) {
      $cvsmethod = 'update';
      // 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 SVN is competent enough to deal with this!
      // TODO: Make this work with BZR etc.
      if (!file_exists($path . '/.svn') && $cvsparams === FALSE) {
        $cvsparams = '-dPC';
      }
    }
  }
  if ($cvsparams === FALSE) {
    $cvsparams = '-dP';
  }

  // CVS only accepts relative paths. We will cd in the checkout path right
  // before running the cvs command.
  $checkout_path = $project['base_project_path'];

  $cvsparts = array();
  $cvsparts[] = '-z6';
  $cvsparts[] = $cvsparams;
  $cvsparts[] = '-d:pserver:' . drush_get_option('cvscredentials', 'anonymous:anonymous') . '@cvs.drupal.org:/cvs/' . $repos;
  $cvsparts[] = $cvsmethod;
  $cvsparts[] = '-r ' . $release['tag'];
  if ($cvsmethod == 'checkout') {
    $cvsparts[] = '-d ' . $project['name'];
    $cvsparts[] = $cvsdir . $project['name'];
  }
  else {
    $cvsparts[] = $project['name'];
  }

  if (!drush_shell_exec('cd ' . $checkout_path . ' ; cvs ' . implode(' ', $cvsparts))) {
    drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to checkout ' . $project['name'] . ' from cvs.drupal.org.');
  }
}