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\Repository\RevisionLog; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use ConsoleHelpers\ConsoleKit\ConsoleIO; |
15
|
|
|
use ConsoleHelpers\SVNBuddy\Database\DatabaseCache; |
16
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector; |
17
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\LogMessageParserFactory; |
18
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\BugsPlugin; |
19
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\MergesPlugin; |
20
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\PathsPlugin; |
21
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\ProjectsPlugin; |
22
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\RefsPlugin; |
23
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\SummaryPlugin; |
24
|
|
|
|
25
|
|
|
class RevisionLogFactory |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Repository connector. |
30
|
|
|
* |
31
|
|
|
* @var Connector |
32
|
|
|
*/ |
33
|
|
|
private $_repositoryConnector; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Database manager. |
37
|
|
|
* |
38
|
|
|
* @var DatabaseManager |
39
|
|
|
*/ |
40
|
|
|
private $_databaseManager; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Log message parser factory |
44
|
|
|
* |
45
|
|
|
* @var LogMessageParserFactory |
46
|
|
|
*/ |
47
|
|
|
private $_logMessageParserFactory; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Create revision log. |
51
|
|
|
* |
52
|
|
|
* @param Connector $repository_connector Repository connector. |
53
|
|
|
* @param DatabaseManager $database_manager Database manager. |
54
|
|
|
* @param LogMessageParserFactory $log_message_parser_factory Log message parser factory. |
55
|
|
|
*/ |
56
|
2 |
|
public function __construct( |
57
|
|
|
Connector $repository_connector, |
58
|
|
|
DatabaseManager $database_manager, |
59
|
|
|
LogMessageParserFactory $log_message_parser_factory |
60
|
|
|
) { |
61
|
2 |
|
$this->_repositoryConnector = $repository_connector; |
62
|
2 |
|
$this->_databaseManager = $database_manager; |
63
|
2 |
|
$this->_logMessageParserFactory = $log_message_parser_factory; |
64
|
2 |
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Returns revision log for url. |
68
|
|
|
* |
69
|
|
|
* @param string $repository_url Repository url. |
70
|
|
|
* @param ConsoleIO $io Console IO. |
71
|
|
|
* |
72
|
|
|
* @return RevisionLog |
73
|
|
|
*/ |
74
|
1 |
|
public function getRevisionLog($repository_url, ConsoleIO $io = null) |
75
|
|
|
{ |
76
|
|
|
// Gets database for given repository url. |
77
|
1 |
|
$root_url = $this->_repositoryConnector->getRootUrl($repository_url); |
78
|
1 |
|
$database = $this->_databaseManager->getDatabase($root_url, $io); |
79
|
|
|
|
80
|
|
|
// Create dependencies. |
81
|
1 |
|
$database_cache = new DatabaseCache($database); |
82
|
1 |
|
$repository_filler = new RepositoryFiller($database, $database_cache); |
83
|
|
|
|
84
|
|
|
// Create blank revision log. |
85
|
1 |
|
$revision_log = new RevisionLog($repository_url, $this->_repositoryConnector, $io); |
86
|
|
|
|
87
|
|
|
// Add plugins to revision log. |
88
|
1 |
|
$revision_log->registerPlugin(new SummaryPlugin($database, $repository_filler)); |
89
|
1 |
|
$revision_log->registerPlugin(new PathsPlugin( |
90
|
1 |
|
$database, |
91
|
1 |
|
$repository_filler, |
92
|
1 |
|
$database_cache, |
93
|
1 |
|
$this->_repositoryConnector, |
94
|
1 |
|
new PathCollisionDetector() |
95
|
1 |
|
)); |
96
|
1 |
|
$revision_log->registerPlugin(new ProjectsPlugin($database, $repository_filler)); |
97
|
1 |
|
$revision_log->registerPlugin(new BugsPlugin( |
98
|
1 |
|
$database, |
99
|
1 |
|
$repository_filler, |
100
|
1 |
|
$root_url, |
101
|
1 |
|
$this->_repositoryConnector, |
102
|
1 |
|
$this->_logMessageParserFactory |
103
|
1 |
|
)); |
104
|
1 |
|
$revision_log->registerPlugin(new MergesPlugin($database, $repository_filler)); |
105
|
1 |
|
$revision_log->registerPlugin(new RefsPlugin($database, $repository_filler)); |
106
|
|
|
|
107
|
|
|
// Run migrations (includes initial schema creation). |
108
|
1 |
|
$context = new MigrationContext($database, clone $revision_log); |
109
|
1 |
|
$this->_databaseManager->runMigrations($context); |
110
|
|
|
|
111
|
1 |
|
$revision_log->refresh(false); |
112
|
|
|
|
113
|
1 |
|
return $revision_log; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
} |
117
|
|
|
|