From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4504D2008B for ; Tue, 27 Oct 2020 07:54:58 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 28/52] v2writable: make *last_commits and sync_prepare OO methods Date: Tue, 27 Oct 2020 07:54:29 +0000 Message-Id: <20201027075453.19163-29-e@80x24.org> In-Reply-To: <20201027075453.19163-1-e@80x24.org> References: <20201027075453.19163-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This will allow ExtSearchIdx to override or reuse them more easily. Unfortunately we lose prototype validation, but that seems to be discouraged anyways given the 'signatures' feature in Perl 5.20+. --- lib/PublicInbox/V2Writable.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 3d3c25ec..ca60f2a1 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -952,8 +952,9 @@ sub index_oid { # cat_async callback } # only update last_commit for $i on reindex iff newer than current +# $sync will be used by subclasses sub update_last_commit { - my ($self, $git, $i, $cmt) = @_; + my ($self, $sync, $git, $i, $cmt) = @_; my $last = last_epoch_commit($self, $i); if (defined $last && is_ancestor($git, $last, $cmt)) { my @cmd = (qw(rev-list --count), "$last..$cmt"); @@ -963,7 +964,7 @@ sub update_last_commit { last_epoch_commit($self, $i, $cmt); } -sub last_commits ($$) { +sub last_commits { my ($self, $sync) = @_; my $heads = []; for (my $i = $sync->{epoch_max}; $i >= 0; $i--) { @@ -1028,6 +1029,7 @@ sub artnum_max { $_[0]->{mm}->num_highwater } sub sync_prepare ($$) { my ($self, $sync) = @_; + $sync->{ranges} = sync_ranges($self, $sync); my $pr = $sync->{-opt}->{-progress}; my $regen_max = 0; my $head = $sync->{ibx}->{ref_head} || 'HEAD'; @@ -1232,7 +1234,7 @@ sub index_epoch ($$$) { } } $all->async_wait_all; - $self->update_last_commit($git, $i, $stk->{latest_cmt}); + $self->update_last_commit($sync, $git, $i, $stk->{latest_cmt}); } sub xapian_only { @@ -1294,7 +1296,6 @@ sub index_sync { ibx => $self->{ibx}, epoch_max => $epoch_max, }; - $sync->{ranges} = sync_ranges($self, $sync); if (sync_prepare($self, $sync)) { # tmp_clone seems to fail if inside a transaction, so # we rollback here (because we opened {mm} for reading)