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\ConsoleKit\Exception\CommandException; |
15
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\RevisionListParser; |
16
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLog; |
17
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
18
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
19
|
|
|
use Symfony\Component\Console\Input\InputOption; |
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
21
|
|
|
|
22
|
|
|
class ReparseCommand extends AbstractCommand |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Revision log |
27
|
|
|
* |
28
|
|
|
* @var RevisionLog |
29
|
|
|
*/ |
30
|
|
|
private $_revisionLog; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Revision list parser. |
34
|
|
|
* |
35
|
|
|
* @var RevisionListParser |
36
|
|
|
*/ |
37
|
|
|
private $_revisionListParser; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
protected function configure() |
43
|
|
|
{ |
44
|
|
|
$this |
45
|
|
|
->setName('reparse') |
46
|
|
|
->setDescription('Reparses given revision') |
47
|
|
|
->addArgument( |
48
|
|
|
'path', |
49
|
|
|
InputArgument::OPTIONAL, |
50
|
|
|
'Working copy path', |
51
|
|
|
'.' |
52
|
|
|
) |
53
|
|
|
->addOption( |
54
|
|
|
'revisions', |
55
|
|
|
'r', |
56
|
|
|
InputOption::VALUE_REQUIRED, |
57
|
|
|
'List of revision(-s) and/or revision range(-s) to reparse, e.g. <comment>53324</comment>, <comment>1224-4433</comment> or <comment>all</comment>' |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
parent::configure(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Prepare dependencies. |
65
|
|
|
* |
66
|
|
|
* @return void |
67
|
|
|
*/ |
68
|
|
|
protected function prepareDependencies() |
69
|
|
|
{ |
70
|
|
|
parent::prepareDependencies(); |
71
|
|
|
|
72
|
|
|
$container = $this->getContainer(); |
73
|
|
|
|
74
|
|
|
$this->_revisionListParser = $container['revision_list_parser']; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* {@inheritdoc} |
79
|
|
|
*/ |
80
|
|
|
public function initialize(InputInterface $input, OutputInterface $output) |
81
|
|
|
{ |
82
|
|
|
parent::initialize($input, $output); |
83
|
|
|
|
84
|
|
|
$this->_revisionLog = $this->getRevisionLog($this->getWorkingCopyUrl()); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* {@inheritdoc} |
89
|
|
|
* |
90
|
|
|
* @throws CommandException When mandatory "revision" option wasn't given. |
91
|
|
|
*/ |
92
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
93
|
|
|
{ |
94
|
|
|
$revisions = $this->io->getOption('revisions'); |
95
|
|
|
|
96
|
|
|
if ( !$revisions ) { |
97
|
|
|
throw new CommandException('The "revisions" option is mandatory.'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
// FIXME: Not checking, that given revisions belong to a working copy. |
101
|
|
|
$revisions = $this->_revisionListParser->expandRanges($this->getList($revisions)); |
102
|
|
|
|
103
|
|
|
foreach ( $this->_revisionListParser->collapseRanges($revisions) as $revision_range ) { |
104
|
|
|
if ( strpos($revision_range, '-') === false ) { |
105
|
|
|
$this->_revisionLog->reparse($revision_range, $revision_range); |
106
|
|
|
} |
107
|
|
|
else { |
108
|
|
|
list($from_revision, $to_revision) = explode('-', $revision_range, 2); |
109
|
|
|
$this->_revisionLog->reparse($from_revision, $to_revision); |
|
|
|
|
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
} |
115
|
|
|
|