/** * Switch branch of external modules * * @param WorkingCopy $wc Working copy * @param string $branch Branch name * @param string $path Path to change the svn:externals property of * @param OutputInterface $output Output interface * * @return void */ protected function switchExternal(WorkingCopy $wc, $branch, $path, OutputInterface $output) { $properties = $wc->listProperties($path); if (!isset($properties["svn:externals"])) { return; } $this->out($output, "Switching svn:externals of '<b>{$path}</b>' to '<b>{$branch}</b>' ..."); $externals = preg_split("/[\r\n]+/", $properties["svn:externals"]); foreach ($externals as $_i => $_external) { $matches = array(); if (preg_match("@(.*)\\s+(.*)@", trim($_external), $matches)) { array_shift($matches); foreach ($matches as &$_match) { $_match = preg_replace("@(/trunk/|/branches/[^/]+/)@", "/{$branch}/", $_match); } unset($_match); $externals[$_i] = implode(" ", $matches); } } $multiline = implode("\n", $externals) . "\n"; $wc->setProperty($path, "svn:externals", $multiline); $this->out($output, "Properties updated on '<b>{$path}</b>'"); }