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\Plugin\RepositoryCollectorPlugin; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\AbstractPlugin; |
15
|
|
|
|
16
|
|
|
abstract class AbstractRepositoryCollectorPlugin extends AbstractPlugin implements IRepositoryCollectorPlugin |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Parse log entries. |
21
|
|
|
* |
22
|
|
|
* @param \SimpleXMLElement $log Log. |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
27 |
|
public function parse(\SimpleXMLElement $log) |
27
|
|
|
{ |
28
|
27 |
|
$this->database->beginTransaction(); |
29
|
|
|
|
30
|
27 |
|
$last_processed_revision = null; |
31
|
27 |
|
$last_revision = $this->getLastRevision(); |
32
|
|
|
|
33
|
27 |
|
foreach ( $log->logentry as $log_entry ) { |
34
|
27 |
|
$revision = (int)$log_entry['revision']; |
35
|
|
|
|
36
|
|
|
// Don't handle same revision twice. |
37
|
27 |
|
if ( $revision <= $last_revision ) { |
38
|
3 |
|
continue; |
39
|
|
|
} |
40
|
|
|
|
41
|
24 |
|
$this->doParse($revision, $log_entry); |
|
|
|
|
42
|
24 |
|
$last_processed_revision = $revision; |
43
|
|
|
} |
44
|
|
|
|
45
|
27 |
|
if ( isset($last_processed_revision) ) { |
46
|
24 |
|
$this->setLastRevision($last_processed_revision); |
47
|
|
|
} |
48
|
|
|
|
49
|
27 |
|
$this->database->commit(); |
50
|
|
|
|
51
|
27 |
|
$this->freeMemoryAutomatically(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Does actual parsing. |
56
|
|
|
* |
57
|
|
|
* @param integer $revision Revision. |
58
|
|
|
* @param \SimpleXMLElement $log_entry Log Entry. |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
abstract protected function doParse($revision, \SimpleXMLElement $log_entry); |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Returns revision query flags. |
66
|
|
|
* |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
1 |
|
public function getRevisionQueryFlags() |
70
|
|
|
{ |
71
|
1 |
|
return array(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|