Skip to content

Commit 48c00ed

Browse files
committed
Increase repository scanning speed (wrong match fix + tests fix)
1 parent ba48abe commit 48c00ed

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/SVNBuddy/Repository/RevisionLog/RevisionLog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private function _useRepositoryCollectorPlugins($from_revision, $to_revision, $o
272272
// The "io" isn't set during autocomplete.
273273
if ( isset($this->_io) ) {
274274
// Create progress bar for repository plugins, where data amount is known upfront.
275-
$progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / $batch_size - 1) + 1);
275+
$progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / $batch_size) + 1);
276276
$progress_bar->setMessage(
277277
$overwrite ? '* Reparsing revisions:' : ' * Reading missing revisions:'
278278
);
@@ -293,7 +293,7 @@ private function _useRepositoryCollectorPlugins($from_revision, $to_revision, $o
293293
$log_command_arguments = $this->_getLogCommandArguments($plugins);
294294

295295
while ( $range_start <= $to_revision ) {
296-
$range_end = min($range_start + $batch_size, $to_revision);
296+
$range_end = min($range_start + ($batch_size - 1), $to_revision);
297297

298298
$command_arguments = str_replace(
299299
array('{revision_range}', '{repository_url}'),

tests/SVNBuddy/Repository/RevisionLog/RevisionLogTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public static function refreshWithoutCacheWithOutputDataProvider()
284284

285285
public function testRefreshWithoutCacheWithoutOutput(ConsoleIO $io = null, ProgressBar $database_progress_bar = null, $is_verbose = false)
286286
{
287-
$this->repositoryConnector->getLastRevision('svn://localhost')->willReturn(400)->shouldBeCalled();
287+
$this->repositoryConnector->getLastRevision('svn://localhost')->willReturn(1000)->shouldBeCalled();
288288

289289
// Create revision log (part 1).
290290
$revision_log = $this->createRevisionLog('svn://localhost/projects/project-name/trunk', $io);
@@ -300,9 +300,9 @@ public function testRefreshWithoutCacheWithoutOutput(ConsoleIO $io = null, Progr
300300
->willReturn(array(RevisionLog::FLAG_MERGE_HISTORY, RevisionLog::FLAG_VERBOSE))
301301
->shouldBeCalled();
302302

303-
$repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(0, 199)))->shouldBeCalled();
304-
$repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(200, 399)))->shouldBeCalled();
305-
$repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(400, 400)))->shouldBeCalled();
303+
$repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(0, 499)))->shouldBeCalled();
304+
$repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(500, 999)))->shouldBeCalled();
305+
$repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(1000, 1000)))->shouldBeCalled();
306306

307307
if ( $is_verbose ) {
308308
$repository_collector_plugin->getStatistics()->willReturn(array('rp1' => 10, 'rp2' => 20))->shouldBeCalled();
@@ -317,7 +317,7 @@ public function testRefreshWithoutCacheWithoutOutput(ConsoleIO $io = null, Progr
317317
$database_collector_plugin->whenDatabaseReady()->shouldBeCalled();
318318
$database_collector_plugin->getLastRevision()->willReturn(0)->shouldBeCalled();
319319
$database_collector_plugin
320-
->process(0, 400, $database_progress_bar)
320+
->process(0, 1000, $database_progress_bar)
321321
->will(function (array $args) {
322322
if ( isset($args[2]) ) {
323323
$args[2]->advance();

0 commit comments

Comments
 (0)