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; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor; |
15
|
|
|
use ConsoleHelpers\SVNBuddy\Cache\CacheManager; |
16
|
|
|
use ConsoleHelpers\DatabaseMigration\MigrationManager; |
17
|
|
|
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner; |
18
|
|
|
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner; |
19
|
|
|
use ConsoleHelpers\SVNBuddy\Config\CommandConfig; |
20
|
|
|
use ConsoleHelpers\SVNBuddy\Database\StatementProfiler; |
21
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\DateHelper; |
22
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\OutputHelper; |
23
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\SizeHelper; |
24
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\ClassicMergeSourceDetector; |
25
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\InPortalMergeSourceDetector; |
26
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\MergeSourceDetectorAggregator; |
27
|
|
|
use ConsoleHelpers\SVNBuddy\Process\ProcessFactory; |
28
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\CommitMessageBuilder; |
29
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\EmptyMergeTemplate; |
30
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\GroupByBugMergeTemplate; |
31
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\GroupByRevisionMergeTemplate; |
32
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\MergeTemplateFactory; |
33
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\SummaryMergeTemplate; |
34
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector; |
35
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\UrlResolver; |
36
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\LogMessageParserFactory; |
37
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\RevisionListParser; |
38
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\DatabaseManager; |
39
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLogFactory; |
40
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionPrinter; |
41
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\WorkingCopyConflictTracker; |
42
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\WorkingCopyResolver; |
43
|
|
|
use ConsoleHelpers\SVNBuddy\Updater\UpdateManager; |
44
|
|
|
use ConsoleHelpers\SVNBuddy\Updater\Updater; |
45
|
|
|
use ConsoleHelpers\SVNBuddy\Updater\VersionUpdateStrategy; |
46
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
47
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
48
|
|
|
|
49
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
50
|
|
|
{ |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritdoc} |
54
|
|
|
*/ |
55
|
179 |
|
public function __construct(array $values = array()) |
56
|
|
|
{ |
57
|
179 |
|
parent::__construct($values); |
58
|
|
|
|
59
|
179 |
|
$this['app_name'] = 'SVN-Buddy'; |
60
|
179 |
|
$this['app_version'] = '@git-version@'; |
61
|
|
|
|
62
|
179 |
|
$this['working_directory_sub_folder'] = '.svn-buddy'; |
63
|
|
|
|
64
|
179 |
|
$this['config_defaults'] = array( |
65
|
|
|
'repository-connector.username' => '', |
66
|
|
|
'repository-connector.password' => '', |
67
|
|
|
'repository-connector.last-revision-cache-duration' => '10 minutes', |
68
|
|
|
'update-channel' => 'stable', |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
$this->extend('output', function ($output) { |
72
|
|
|
/** @var OutputInterface $output */ |
73
|
11 |
|
$output->getFormatter()->setStyle('debug', new OutputFormatterStyle('white', 'magenta')); |
74
|
|
|
|
75
|
11 |
|
return $output; |
76
|
179 |
|
}); |
77
|
|
|
|
78
|
|
|
$this['process_factory'] = function () { |
79
|
9 |
|
return new ProcessFactory(); |
80
|
|
|
}; |
81
|
|
|
|
82
|
|
|
$this['merge_source_detector'] = function () { |
83
|
1 |
|
$merge_source_detector = new MergeSourceDetectorAggregator(0); |
84
|
1 |
|
$merge_source_detector->add(new ClassicMergeSourceDetector(0)); |
85
|
1 |
|
$merge_source_detector->add(new InPortalMergeSourceDetector(50)); |
86
|
|
|
|
87
|
1 |
|
return $merge_source_detector; |
88
|
|
|
}; |
89
|
|
|
|
90
|
|
|
$this['repository_url_resolver'] = function ($c) { |
91
|
1 |
|
return new UrlResolver($c['repository_connector']); |
92
|
|
|
}; |
93
|
|
|
|
94
|
|
|
$this['cache_manager'] = function ($c) { |
95
|
9 |
|
return new CacheManager($c['working_directory'], $c['size_helper'], $c['io']); |
96
|
|
|
}; |
97
|
|
|
|
98
|
|
|
$this['statement_profiler'] = function () { |
99
|
20 |
|
$statement_profiler = new StatementProfiler(); |
100
|
|
|
|
101
|
|
|
// The "AbstractPlugin::getLastRevision" method. |
102
|
20 |
|
$statement_profiler->ignoreDuplicateStatement('SELECT LastRevision FROM PluginData WHERE Name = :name'); |
103
|
|
|
|
104
|
|
|
// The "AbstractPlugin::getProject" method. |
105
|
20 |
|
$statement_profiler->ignoreDuplicateStatement('SELECT Id FROM Projects WHERE Path = :path'); |
106
|
|
|
|
107
|
|
|
// The "AbstractDatabaseCollectorPlugin::getProjects" method. |
108
|
20 |
|
$statement_profiler->ignoreDuplicateStatement( |
109
|
20 |
|
'SELECT Path, Id AS PathId, RevisionAdded, RevisionDeleted, RevisionLastSeen |
110
|
|
|
FROM Paths |
111
|
|
|
WHERE PathHash IN (:path_hashes)' |
112
|
|
|
); |
113
|
|
|
|
114
|
|
|
// The "ProjectsPlugin::createRepositoryWideProject" method. |
115
|
20 |
|
$statement_profiler->ignoreDuplicateStatement( |
116
|
20 |
|
'SELECT Id FROM Paths WHERE ProjectPath = :project_path LIMIT 100' |
117
|
|
|
); |
118
|
|
|
|
119
|
20 |
|
$statement_profiler->setActive(true); |
120
|
20 |
|
$statement_profiler->trackDuplicates(false); |
121
|
|
|
|
122
|
20 |
|
return $statement_profiler; |
123
|
|
|
}; |
124
|
|
|
|
125
|
|
|
$this['project_root_folder'] = function () { |
126
|
150 |
|
return dirname(dirname(__DIR__)); |
127
|
|
|
}; |
128
|
|
|
|
129
|
|
|
$this['migration_manager'] = function ($c) { |
130
|
150 |
|
$migrations_directory = $c['project_root_folder'] . '/migrations'; |
131
|
150 |
|
$migration_manager = new MigrationManager($migrations_directory, $c); |
132
|
150 |
|
$migration_manager->registerMigrationRunner(new SqlMigrationRunner()); |
133
|
150 |
|
$migration_manager->registerMigrationRunner(new PhpMigrationRunner()); |
134
|
|
|
|
135
|
150 |
|
return $migration_manager; |
136
|
|
|
}; |
137
|
|
|
|
138
|
|
|
$this['db_manager'] = function ($c) { |
139
|
2 |
|
return new DatabaseManager($c['working_directory'], $c['migration_manager'], $c['statement_profiler']); |
140
|
|
|
}; |
141
|
|
|
|
142
|
|
|
$this['revision_log_factory'] = function ($c) { |
143
|
2 |
|
return new RevisionLogFactory( |
144
|
2 |
|
$c['repository_connector'], |
145
|
2 |
|
$c['db_manager'], |
146
|
2 |
|
$c['log_message_parser_factory'] |
147
|
|
|
); |
148
|
|
|
}; |
149
|
|
|
|
150
|
|
|
$this['log_message_parser_factory'] = function () { |
151
|
3 |
|
return new LogMessageParserFactory(); |
152
|
|
|
}; |
153
|
|
|
|
154
|
|
|
$this['revision_list_parser'] = function () { |
155
|
9 |
|
return new RevisionListParser(); |
156
|
|
|
}; |
157
|
|
|
|
158
|
|
|
$this['revision_printer'] = function ($c) { |
159
|
1 |
|
return new RevisionPrinter($c['date_helper'], $c['output_helper']); |
160
|
|
|
}; |
161
|
|
|
|
162
|
|
|
$this['repository_connector'] = function ($c) { |
163
|
8 |
|
return new Connector( |
164
|
8 |
|
$c['config_editor'], |
165
|
8 |
|
$c['process_factory'], |
166
|
8 |
|
$c['io'], |
167
|
8 |
|
$c['cache_manager'], |
168
|
8 |
|
$c['revision_list_parser'] |
169
|
|
|
); |
170
|
|
|
}; |
171
|
|
|
|
172
|
|
|
$this['commit_message_builder'] = function ($c) { |
173
|
1 |
|
return new CommitMessageBuilder($c['working_copy_conflict_tracker']); |
174
|
|
|
}; |
175
|
|
|
|
176
|
|
|
$this['working_copy_resolver'] = function ($c) { |
177
|
4 |
|
return new WorkingCopyResolver($c['repository_connector']); |
178
|
|
|
}; |
179
|
|
|
|
180
|
|
|
$this['working_copy_conflict_tracker'] = function ($c) { |
181
|
2 |
|
return new WorkingCopyConflictTracker($c['repository_connector'], $c['command_config']); |
182
|
|
|
}; |
183
|
|
|
|
184
|
|
|
$this['merge_template_factory'] = function ($c) { |
185
|
1 |
|
$factory = new MergeTemplateFactory(); |
186
|
1 |
|
$repository_connector = $c['repository_connector']; |
187
|
1 |
|
$revision_log_factory = $c['revision_log_factory']; |
188
|
|
|
|
189
|
1 |
|
$factory->add(new GroupByBugMergeTemplate($repository_connector, $revision_log_factory)); |
190
|
1 |
|
$factory->add(new GroupByRevisionMergeTemplate($repository_connector, $revision_log_factory)); |
191
|
1 |
|
$factory->add(new SummaryMergeTemplate($repository_connector, $revision_log_factory)); |
192
|
1 |
|
$factory->add(new EmptyMergeTemplate($repository_connector, $revision_log_factory)); |
193
|
|
|
|
194
|
1 |
|
return $factory; |
195
|
|
|
}; |
196
|
|
|
|
197
|
|
|
$this['command_config'] = function ($c) { |
198
|
3 |
|
return new CommandConfig($c['config_editor'], $c['working_copy_resolver']); |
199
|
|
|
}; |
200
|
|
|
|
201
|
|
|
$this['date_helper'] = function () { |
202
|
2 |
|
return new DateHelper(); |
203
|
|
|
}; |
204
|
|
|
|
205
|
|
|
$this['size_helper'] = function () { |
206
|
10 |
|
return new SizeHelper(); |
207
|
|
|
}; |
208
|
|
|
|
209
|
|
|
$this['output_helper'] = function () { |
210
|
2 |
|
return new OutputHelper(); |
211
|
|
|
}; |
212
|
|
|
|
213
|
|
|
$this['editor'] = function () { |
214
|
1 |
|
return new InteractiveEditor(); |
215
|
|
|
}; |
216
|
|
|
|
217
|
|
|
$this['updater'] = function ($c) { |
218
|
|
|
/** @var ConfigEditor $config_editor */ |
219
|
1 |
|
$config_editor = $c['config_editor']; |
220
|
|
|
|
221
|
1 |
|
$update_strategy = new VersionUpdateStrategy(); |
222
|
1 |
|
$update_strategy->setStability($config_editor->get('update-channel')); |
223
|
1 |
|
$update_strategy->setCurrentLocalVersion($c['app_version']); |
224
|
|
|
|
225
|
1 |
|
$updater = new Updater(null, false); |
226
|
1 |
|
$updater->setStrategyObject($update_strategy); |
227
|
|
|
|
228
|
1 |
|
return $updater; |
229
|
|
|
}; |
230
|
|
|
|
231
|
|
|
$this['update_manager'] = function ($c) { |
232
|
|
|
return new UpdateManager( |
233
|
|
|
$c['updater'], |
234
|
|
|
$c['config_editor'], |
235
|
|
|
$c['process_factory'], |
236
|
|
|
$c['working_directory'] |
237
|
|
|
); |
238
|
|
|
}; |
239
|
179 |
|
} |
240
|
|
|
|
241
|
|
|
} |
242
|
|
|
|