Skip to content

Commit 0955350

Browse files
committed
Increase repository scanning speed
1 parent 3ec7ec4 commit 0955350

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2020
- The `config` command groups configuration settings by a command.
2121
- The `changelog` command will show actually used app version instead of `Unreleased` word, when used version isn't mentioned in a changelog.
2222
- The executed SVN command idle timeout changed from 20 minutes to 3 minutes.
23-
- The `commit` command remove empty lines of merged commits, when building grouped merge commit message.
23+
- The `commit` command remove empty lines of merged commits, when building grouped merge commit message.
24+
- Increased repository scanning speed from 200 to 500 revisions per run.
2425

2526
### Fixed
2627
- The non-merged revision table was shown after a successful auto-commit, when merge conflict was resolved.

src/SVNBuddy/Repository/RevisionLog/RevisionLog.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,12 @@ private function _queryRevisionData($from_revision, $to_revision, $overwrite = f
267267
*/
268268
private function _useRepositoryCollectorPlugins($from_revision, $to_revision, $overwrite = false)
269269
{
270+
$batch_size = 500; // Revision count to query in one go.
271+
270272
// The "io" isn't set during autocomplete.
271273
if ( isset($this->_io) ) {
272274
// Create progress bar for repository plugins, where data amount is known upfront.
273-
$progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / 200) + 1);
275+
$progress_bar = $this->_io->createProgressBar(ceil(($to_revision - $from_revision) / $batch_size) + 1);
274276
$progress_bar->setMessage(
275277
$overwrite ? '* Reparsing revisions:' : ' * Reading missing revisions:'
276278
);
@@ -291,7 +293,7 @@ private function _useRepositoryCollectorPlugins($from_revision, $to_revision, $o
291293
$log_command_arguments = $this->_getLogCommandArguments($plugins);
292294

293295
while ( $range_start <= $to_revision ) {
294-
$range_end = min($range_start + 199, $to_revision);
296+
$range_end = min($range_start + ($batch_size - 1), $to_revision);
295297

296298
$command_arguments = str_replace(
297299
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)