1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the SVN-Buddy library. |
4
|
|
|
* For the full copyright and license information, please view |
5
|
|
|
* the LICENSE file that was distributed with this source code. |
6
|
|
|
* |
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
8
|
|
|
* @link https://github.com/console-helpers/svn-buddy |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\SVNBuddy\Command; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\WorkingCopyConflictTracker; |
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Input\InputOption; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
|
20
|
|
|
class UpdateCommand extends AbstractCommand implements IAggregatorAwareCommand |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Working copy conflict tracker. |
25
|
|
|
* |
26
|
|
|
* @var WorkingCopyConflictTracker |
27
|
|
|
*/ |
28
|
|
|
private $_workingCopyConflictTracker; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Prepare dependencies. |
32
|
|
|
* |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
protected function prepareDependencies() |
36
|
|
|
{ |
37
|
|
|
parent::prepareDependencies(); |
38
|
|
|
|
39
|
|
|
$container = $this->getContainer(); |
40
|
|
|
|
41
|
|
|
$this->_workingCopyConflictTracker = $container['working_copy_conflict_tracker']; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
protected function configure() |
48
|
|
|
{ |
49
|
|
|
$this |
50
|
|
|
->setName('update') |
51
|
|
|
->setDescription('Bring changes from the repository into the working copy') |
52
|
|
|
->setAliases(array('up')) |
53
|
|
|
->addArgument( |
54
|
|
|
'path', |
55
|
|
|
InputArgument::OPTIONAL, |
56
|
|
|
'Working copy path', |
57
|
|
|
'.' |
58
|
|
|
) |
59
|
|
|
->addOption( |
60
|
|
|
'ignore-externals', |
61
|
|
|
null, |
62
|
|
|
InputOption::VALUE_NONE, |
63
|
|
|
'Ignore externals definitions' |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
parent::configure(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
73
|
|
|
{ |
74
|
|
|
$wc_path = $this->getWorkingCopyPath(); |
75
|
|
|
|
76
|
|
|
$this->io->writeln('Updating working copy ... '); |
77
|
|
|
|
78
|
|
|
$param_string = '{' . $wc_path . '}'; |
79
|
|
|
|
80
|
|
|
if ( $this->io->getOption('ignore-externals') ) { |
81
|
|
|
$param_string .= ' --ignore-externals'; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$command = $this->repositoryConnector->getCommand('update', $param_string); |
85
|
|
|
$command->runLive(array( |
86
|
|
|
$wc_path => '.', |
87
|
|
|
)); |
88
|
|
|
|
89
|
|
|
if ( $this->_workingCopyConflictTracker->getNewConflicts($wc_path) ) { |
90
|
|
|
$this->_workingCopyConflictTracker->add($wc_path); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$this->io->writeln('<info>Done</info>'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Returns option names, that makes sense to use in aggregation mode. |
98
|
|
|
* |
99
|
|
|
* @return array |
100
|
|
|
*/ |
101
|
|
|
public function getAggregatedOptions() |
102
|
|
|
{ |
103
|
|
|
return array('ignore-externals'); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
} |
107
|
|
|
|