/** * @expectedException \LogicException * @expectedExceptionMessage The working copy at "/path/to/working-copy" has no conflicts to be added. */ public function testAddError() { $wc_path = '/path/to/working-copy'; $this->expectRecordedConflicts($wc_path); $this->repositoryConnector->getWorkingCopyConflicts($wc_path)->willReturn(array()); $this->workingCopyConflictTracker->add($wc_path); }
/** * {@inheritdoc} * * @throws \RuntimeException When invalid mode is specified. */ protected function execute(InputInterface $input, OutputInterface $output) { $mode = $this->io->getOption('mode'); if (!in_array($mode, $this->getModes())) { throw new \RuntimeException('The "' . $mode . '" mode is unknown.'); } $wc_path = $this->getWorkingCopyPath(); switch ($mode) { case self::MODE_SHOW: $recorded_conflicts = $this->_workingCopyConflictTracker->getRecordedConflicts($wc_path); if (!$recorded_conflicts) { $this->io->writeln('<info>The working copy doesn\'t have any recorded conflicts.</info>'); } else { $this->io->writeln('<error>Recorded Conflicts (' . count($recorded_conflicts) . ' paths):</error>'); foreach ($recorded_conflicts as $conflicted_path) { $this->io->writeln(' * ' . $conflicted_path); } } break; case self::MODE_ADD: $this->_workingCopyConflictTracker->add($wc_path); $this->io->writeln('<info>Conflicts updated.</info>'); break; case self::MODE_REPLACE: $this->_workingCopyConflictTracker->replace($wc_path); $this->io->writeln('<info>Conflicts updated.</info>'); break; case self::MODE_ERASE: $this->_workingCopyConflictTracker->erase($wc_path); $this->io->writeln('<info>Conflicts erased.</info>'); break; } }
/** * Ensures, that there are no unresolved conflicts in working copy. * * @param string $source_url Source url. * @param string $wc_path Working copy path. * @param integer $largest_suggested_revision Largest revision, that is suggested in error message. * * @return void * @throws CommandException When merge conflicts detected. */ protected function ensureWorkingCopyWithoutConflicts($source_url, $wc_path, $largest_suggested_revision = null) { $this->io->write(' * Previous Merge Status ... '); $conflicts = $this->_workingCopyConflictTracker->getNewConflicts($wc_path); if (!$conflicts) { $this->io->writeln('<info>Successful</info>'); return; } $this->_workingCopyConflictTracker->add($wc_path); $this->io->writeln('<error>' . count($conflicts) . ' conflict(-s)</error>'); $table = new Table($this->io->getOutput()); if ($largest_suggested_revision) { $table->setHeaders(array('Path', 'Associated Revisions (before ' . $largest_suggested_revision . ')')); } else { $table->setHeaders(array('Path', 'Associated Revisions')); } $revision_log = $this->getRevisionLog($source_url); $source_path = $this->repositoryConnector->getRelativePath($source_url) . '/'; /** @var OutputHelper $output_helper */ $output_helper = $this->getHelper('output'); foreach ($conflicts as $conflict_path) { $path_revisions = $revision_log->find('paths', $source_path . $conflict_path); $path_revisions = array_intersect($this->_unmergedRevisions, $path_revisions); if ($path_revisions && isset($largest_suggested_revision)) { $path_revisions = $this->limitRevisions($path_revisions, $largest_suggested_revision); } $table->addRow(array($conflict_path, $path_revisions ? $output_helper->formatArray($path_revisions, 4) : '-')); } $table->render(); throw new CommandException('Working copy contains unresolved merge conflicts.'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $wc_path = $this->getWorkingCopyPath(); $revision = $this->io->getOption('revision'); $ignore_externals = $this->io->getOption('ignore-externals'); $show_revision = $revision ? $revision : 'HEAD'; $show_externals = $ignore_externals ? '(excluding externals)' : '(including externals)'; $this->io->writeln('Updating working copy to <info>' . $show_revision . '</info> revision ' . $show_externals . ' ... '); $param_string = '{' . $wc_path . '}'; if ($revision) { $param_string .= ' --revision ' . $revision; } if ($ignore_externals) { $param_string .= ' --ignore-externals'; } $command = $this->repositoryConnector->getCommand('update', $param_string); $command->runLive(array($wc_path => '.')); if ($this->_workingCopyConflictTracker->getNewConflicts($wc_path)) { $this->_workingCopyConflictTracker->add($wc_path); } $this->io->writeln('<info>Done</info>'); }