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