private function drush_version_control_bzr::sync

8.0.x bzr.inc private drush_version_control_bzr::sync($project)
6.x bzr.inc private drush_version_control_bzr::sync($project)
7.x bzr.inc private drush_version_control_bzr::sync($project)
5.x bzr.inc private drush_version_control_bzr::sync($project)
master bzr.inc private drush_version_control_bzr::sync($project)

Automatically add any unversioned files to Bazaar and remove any files that have been deleted on the file system

2 calls to drush_version_control_bzr::sync()
drush_version_control_bzr::post_download in commands/pm/version_control/bzr.inc
Implementation of post_download().
drush_version_control_bzr::post_update in commands/pm/version_control/bzr.inc
Implementation of post_update().

File

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

Class

drush_version_control_bzr

Code

private function sync($project) {
  if (drush_get_option('bzrsync')) {
    $errors = '';
    $root = array();
    if (drush_shell_exec('bzr status --short %s', $project['full_project_path'])) {
      $output = drush_shell_exec_output();
      // All paths returned by bzr status are relative to the repository root.
      if (drush_shell_exec('bzr root %s', $project['full_project_path'])) {
        $root = drush_shell_exec_output();
      }
      foreach ($output as $line) {
        if (preg_match('/^\?\s+(.*)/', $line, $matches)) {
          $path = $root[0] . '/' . $matches[1];
          if (!drush_shell_exec('bzr add --no-recurse %s', $path)) {
            $errors .= implode("\n", drush_shell_exec_output());
          }
        }
        else if (preg_match('/^\s+D\s+(.*)/', $line, $matches)) {
          $path = $root[0] . '/' . $matches[1];
          if (!drush_shell_exec('bzr remove %s', $path)) {
            $errors .= implode("\n", drush_shell_exec_output());
          }
        }
      }
      if (!empty($errors)) {
        return drush_set_error('DRUSH_PM_BZR_SYNC_PROBLEMS', dt("Problems were encountered adding or removing files to/from Bazaar.\nThe specific errors are below:\n!errors", array('!errors' => $errors)));
      }
    }
    else {
      return drush_set_error('DRUSH_PM_BZR_NOT_FOUND', dt("Drush was unable to get the bzr status. Check that you have Bazaar \ninstalled and that the site is a Bazaar working copy.\nThe specific errors are below:\n!errors", array('!errors' => implode("\n", drush_shell_exec_output()))));
    }
    return TRUE;
  }
}