Skip to content

Commit

Permalink
Increase repository scanning speed (wrong match fix + tests fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Oct 24, 2024
1 parent ba48abe commit 48c00ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/SVNBuddy/Repository/RevisionLog/RevisionLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:'
);
Expand All @@ -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}'),
Expand Down
10 changes: 5 additions & 5 deletions tests/SVNBuddy/Repository/RevisionLog/RevisionLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 48c00ed

Please sign in to comment.