From 48c00ed127b6b720f6d30a7f87331426d5bc90e5 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 24 Oct 2024 19:39:16 +0300 Subject: [PATCH] Increase repository scanning speed (wrong match fix + tests fix) --- src/SVNBuddy/Repository/RevisionLog/RevisionLog.php | 4 ++-- .../Repository/RevisionLog/RevisionLogTest.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SVNBuddy/Repository/RevisionLog/RevisionLog.php b/src/SVNBuddy/Repository/RevisionLog/RevisionLog.php index 30f832d..38b7ffa 100644 --- a/src/SVNBuddy/Repository/RevisionLog/RevisionLog.php +++ b/src/SVNBuddy/Repository/RevisionLog/RevisionLog.php @@ -272,7 +272,7 @@ private function _useRepositoryCollectorPlugins($from_revision, $to_revision, $o // The "io" isn't set during autocomplete. if ( isset($this->_io) ) { // Create progress bar for repository plugins, where data amount is known upfront. - $progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / $batch_size - 1) + 1); + $progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / $batch_size) + 1); $progress_bar->setMessage( $overwrite ? '* Reparsing revisions:' : ' * Reading missing revisions:' ); @@ -293,7 +293,7 @@ private function _useRepositoryCollectorPlugins($from_revision, $to_revision, $o $log_command_arguments = $this->_getLogCommandArguments($plugins); while ( $range_start <= $to_revision ) { - $range_end = min($range_start + $batch_size, $to_revision); + $range_end = min($range_start + ($batch_size - 1), $to_revision); $command_arguments = str_replace( array('{revision_range}', '{repository_url}'), diff --git a/tests/SVNBuddy/Repository/RevisionLog/RevisionLogTest.php b/tests/SVNBuddy/Repository/RevisionLog/RevisionLogTest.php index 14c82d1..2cf261f 100644 --- a/tests/SVNBuddy/Repository/RevisionLog/RevisionLogTest.php +++ b/tests/SVNBuddy/Repository/RevisionLog/RevisionLogTest.php @@ -284,7 +284,7 @@ public static function refreshWithoutCacheWithOutputDataProvider() public function testRefreshWithoutCacheWithoutOutput(ConsoleIO $io = null, ProgressBar $database_progress_bar = null, $is_verbose = false) { - $this->repositoryConnector->getLastRevision('svn://localhost')->willReturn(400)->shouldBeCalled(); + $this->repositoryConnector->getLastRevision('svn://localhost')->willReturn(1000)->shouldBeCalled(); // Create revision log (part 1). $revision_log = $this->createRevisionLog('svn://localhost/projects/project-name/trunk', $io); @@ -300,9 +300,9 @@ public function testRefreshWithoutCacheWithoutOutput(ConsoleIO $io = null, Progr ->willReturn(array(RevisionLog::FLAG_MERGE_HISTORY, RevisionLog::FLAG_VERBOSE)) ->shouldBeCalled(); - $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(0, 199)))->shouldBeCalled(); - $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(200, 399)))->shouldBeCalled(); - $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(400, 400)))->shouldBeCalled(); + $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(0, 499)))->shouldBeCalled(); + $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(500, 999)))->shouldBeCalled(); + $repository_collector_plugin->parse(new SimpleXMLElementToken($this->expectSvnLogQuery(1000, 1000)))->shouldBeCalled(); if ( $is_verbose ) { $repository_collector_plugin->getStatistics()->willReturn(array('rp1' => 10, 'rp2' => 20))->shouldBeCalled(); @@ -317,7 +317,7 @@ public function testRefreshWithoutCacheWithoutOutput(ConsoleIO $io = null, Progr $database_collector_plugin->whenDatabaseReady()->shouldBeCalled(); $database_collector_plugin->getLastRevision()->willReturn(0)->shouldBeCalled(); $database_collector_plugin - ->process(0, 400, $database_progress_bar) + ->process(0, 1000, $database_progress_bar) ->will(function (array $args) { if ( isset($args[2]) ) { $args[2]->advance();