|
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\SVNBuddy\Cache\CacheManager; |
|
15
|
|
|
use ConsoleHelpers\SVNBuddy\Database\MigrationManager; |
|
16
|
|
|
use ConsoleHelpers\SVNBuddy\Database\StatementProfiler; |
|
17
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\DateHelper; |
|
18
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\SizeHelper; |
|
19
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\ClassicMergeSourceDetector; |
|
20
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\InPortalMergeSourceDetector; |
|
21
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\MergeSourceDetectorAggregator; |
|
22
|
|
|
use ConsoleHelpers\SVNBuddy\Process\ProcessFactory; |
|
23
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector; |
|
24
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\UrlResolver; |
|
25
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\LogMessageParserFactory; |
|
26
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\RevisionListParser; |
|
27
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLogFactory; |
|
28
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
|
29
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
30
|
|
|
|
|
31
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
|
32
|
|
|
{ |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
|
|
|
|
|
35
|
|
|
* {@inheritdoc} |
|
|
|
|
|
|
36
|
|
|
*/ |
|
37
|
23 |
|
public function __construct(array $values = array()) |
|
38
|
|
|
{ |
|
39
|
23 |
|
parent::__construct($values); |
|
40
|
|
|
|
|
41
|
23 |
|
$this['app_name'] = 'SVN-Buddy'; |
|
42
|
23 |
|
$this['app_version'] = '@git-version@'; |
|
43
|
|
|
|
|
44
|
23 |
|
$this['working_directory_sub_folder'] = '.svn-buddy'; |
|
45
|
|
|
|
|
46
|
23 |
|
$this['config_defaults'] = array( |
|
47
|
23 |
|
'repository-connector.username' => '', |
|
48
|
23 |
|
'repository-connector.password' => '', |
|
49
|
23 |
|
'repository-connector.last-revision-cache-duration' => '10 minutes', |
|
50
|
23 |
|
); |
|
51
|
|
|
|
|
52
|
|
|
$this->extend('output', function ($output, $c) { |
|
53
|
|
|
/** @var OutputInterface $output */ |
|
54
|
23 |
|
$output->getFormatter()->setStyle('debug', new OutputFormatterStyle('white', 'magenta')); |
|
55
|
|
|
|
|
56
|
6 |
|
return $output; |
|
57
|
23 |
|
}); |
|
58
|
|
|
|
|
59
|
|
|
$this['process_factory'] = function () { |
|
60
|
4 |
|
return new ProcessFactory(); |
|
61
|
|
|
}; |
|
62
|
|
|
|
|
63
|
|
|
$this['merge_source_detector'] = function () { |
|
64
|
1 |
|
$merge_source_detector = new MergeSourceDetectorAggregator(0); |
|
65
|
1 |
|
$merge_source_detector->add(new ClassicMergeSourceDetector(0)); |
|
66
|
1 |
|
$merge_source_detector->add(new InPortalMergeSourceDetector(50)); |
|
67
|
|
|
|
|
68
|
1 |
|
return $merge_source_detector; |
|
69
|
|
|
}; |
|
70
|
|
|
|
|
71
|
|
|
$this['repository_url_resolver'] = function ($c) { |
|
72
|
1 |
|
return new UrlResolver($c['repository_connector']); |
|
73
|
|
|
}; |
|
74
|
|
|
|
|
75
|
|
|
$this['cache_manager'] = function ($c) { |
|
76
|
4 |
|
return new CacheManager($c['working_directory'], $c['size_helper'], $c['io']); |
|
77
|
|
|
}; |
|
78
|
|
|
|
|
79
|
|
|
$this['statement_profiler'] = function () { |
|
80
|
1 |
|
$statement_profiler = new StatementProfiler(); |
|
81
|
|
|
|
|
82
|
|
|
// The "AbstractPlugin::getLastRevision" method. |
|
83
|
1 |
|
$statement_profiler->ignoreDuplicateStatement('SELECT LastRevision FROM PluginData WHERE Name = :name'); |
|
84
|
|
|
|
|
85
|
|
|
// The "AbstractPlugin::getProject" method. |
|
86
|
1 |
|
$statement_profiler->ignoreDuplicateStatement('SELECT Id FROM Projects WHERE Path = :path'); |
|
87
|
|
|
|
|
88
|
|
|
// The "AbstractDatabaseCollectorPlugin::getProjects" method. |
|
89
|
1 |
|
$statement_profiler->ignoreDuplicateStatement( |
|
90
|
|
|
'SELECT Path, Id AS PathId, RevisionAdded, RevisionDeleted, RevisionLastSeen |
|
91
|
|
|
FROM Paths |
|
92
|
|
|
WHERE PathHash IN (:path_hashes)' |
|
93
|
1 |
|
); |
|
94
|
|
|
|
|
95
|
1 |
|
$statement_profiler->setActive(true); |
|
96
|
|
|
|
|
97
|
1 |
|
return $statement_profiler; |
|
98
|
|
|
}; |
|
99
|
|
|
|
|
100
|
|
|
$this['migration_manager'] = function ($c) { |
|
101
|
1 |
|
$migrations_directory = dirname(dirname(__DIR__)) . '/migrations'; |
|
102
|
|
|
|
|
103
|
1 |
|
return new MigrationManager($migrations_directory, $c); |
|
104
|
|
|
}; |
|
105
|
|
|
|
|
106
|
|
|
$this['revision_log_factory'] = function ($c) { |
|
107
|
1 |
|
return new RevisionLogFactory($c['repository_connector'], $c['cache_manager']); |
|
108
|
|
|
}; |
|
109
|
|
|
|
|
110
|
|
|
$this['log_message_parser_factory'] = function () { |
|
111
|
1 |
|
return new LogMessageParserFactory(); |
|
112
|
|
|
}; |
|
113
|
|
|
|
|
114
|
|
|
$this['revision_list_parser'] = function () { |
|
115
|
1 |
|
return new RevisionListParser(); |
|
116
|
|
|
}; |
|
117
|
|
|
|
|
118
|
|
|
$this['repository_connector'] = function ($c) { |
|
119
|
3 |
|
return new Connector($c['config_editor'], $c['process_factory'], $c['io'], $c['cache_manager']); |
|
120
|
|
|
}; |
|
121
|
|
|
|
|
122
|
|
|
$this['date_helper'] = function () { |
|
123
|
1 |
|
return new DateHelper(); |
|
124
|
|
|
}; |
|
125
|
|
|
|
|
126
|
|
|
$this['size_helper'] = function () { |
|
127
|
4 |
|
return new SizeHelper(); |
|
128
|
|
|
}; |
|
129
|
|
|
|
|
130
|
1 |
|
$this['editor'] = function () { |
|
131
|
1 |
|
return new InteractiveEditor(); |
|
132
|
|
|
}; |
|
133
|
23 |
|
} |
|
134
|
|
|
|
|
135
|
|
|
} |
|
136
|
|
|
|