Skip to content

Commit

Permalink
Increase repository scanning speed
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Oct 24, 2024
1 parent 3ec7ec4 commit 0955350
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- The `config` command groups configuration settings by a command.
- The `changelog` command will show actually used app version instead of `Unreleased` word, when used version isn't mentioned in a changelog.
- The executed SVN command idle timeout changed from 20 minutes to 3 minutes.
- The `commit` command remove empty lines of merged commits, when building grouped merge commit message.
- The `commit` command remove empty lines of merged commits, when building grouped merge commit message.
- Increased repository scanning speed from 200 to 500 revisions per run.

### Fixed
- The non-merged revision table was shown after a successful auto-commit, when merge conflict was resolved.
Expand Down
6 changes: 4 additions & 2 deletions src/SVNBuddy/Repository/RevisionLog/RevisionLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,12 @@ private function _queryRevisionData($from_revision, $to_revision, $overwrite = f
*/
private function _useRepositoryCollectorPlugins($from_revision, $to_revision, $overwrite = false)
{
$batch_size = 500; // Revision count to query in one go.

// 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) / 200) + 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 @@ -291,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 + 199, $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 0955350

Please sign in to comment.