user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 04/10] v2writable: move {regen} into $sync state
Date: Wed, 29 May 2019 08:28:54 +0000	[thread overview]
Message-ID: <20190529082900.9312-5-e@80x24.org> (raw)
In-Reply-To: <20190529082900.9312-1-e@80x24.org>

regen is always enabled for index_sync nowadays (and has
been for a while).

Rename `index_prepare' to `sync_prepare' to show it's for
->index_sync; and not the online indexing we do for ->add.
---
 lib/PublicInbox/V2Writable.pm | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index e05dadc..e341d93 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -706,7 +706,7 @@ sub mark_deleted {
 }
 
 sub reindex_oid {
-	my ($self, $sync, $git, $oid, $regen) = @_;
+	my ($self, $sync, $git, $oid) = @_;
 	my $len;
 	my $msgref = $git->cat_file($oid, \$len);
 	my $mime = PublicInbox::MIME->new($$msgref);
@@ -727,8 +727,8 @@ sub reindex_oid {
 			$self->{mm}->mid_set($num, $mid0);
 		}
 	}
-	if (!defined($mid0) && $regen && !$del) {
-		$num = $$regen--;
+	if (!defined($mid0) && !$del) {
+		$num = $sync->{regen}--;
 		die "BUG: ran out of article numbers\n" if $num <= 0;
 		my $mm = $self->{mm};
 		foreach my $mid (reverse @$mids) {
@@ -749,7 +749,7 @@ sub reindex_oid {
 
 	if (!defined($mid0) || $del) {
 		if (!defined($mid0) && $del) { # expected for deletes
-			$num = $$regen--;
+			$num = $sync->{regen}--;
 			$self->{mm}->num_highwater($num) if !$sync->{reindex};
 			return
 		}
@@ -845,7 +845,7 @@ $range
 	$range;
 }
 
-sub index_prepare {
+sub sync_prepare {
 	my ($self, $opts, $epoch_max, $ranges) = @_;
 	my $pr = $opts->{-progress};
 	my $regen_max = 0;
@@ -879,7 +879,10 @@ sub index_prepare {
 		$pr->("$n\n") if $pr;
 		$regen_max += $n;
 	}
-	\$regen_max;
+	# reindex should NOT see new commits anymore, if we do,
+	# it's a problem and we need to notice it via die()
+	return -1 if $opts->{reindex};
+	$regen_max + $self->{mm}->num_highwater() || 0;
 }
 
 sub unindex_oid_remote {
@@ -968,16 +971,7 @@ sub index_sync {
 		reindex => $opts->{reindex},
 	};
 	my $ranges = sync_ranges($self, $sync, $epoch_max);
-
-	my $high = $self->{mm}->num_highwater();
-	my $regen = $self->index_prepare($opts, $epoch_max, $ranges);
-	if ($opts->{reindex}) {
-		# reindex should NOT see new commits anymore, if we do,
-		# it's a problem and we need to notice it via die()
-		$$regen = -1;
-	} else {
-		$$regen += $high;
-	}
+	$sync->{regen} = sync_prepare($self, $opts, $epoch_max, $ranges);
 
 	my @cmd = qw(log --raw -r --pretty=tformat:%H
 			--no-notes --no-color --no-abbrev --no-renames);
@@ -1000,7 +994,7 @@ sub index_sync {
 			if (/\A$x40$/o && !defined($cmt)) {
 				$cmt = $_;
 			} elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o) {
-				$self->reindex_oid($sync, $git, $1, $regen);
+				$self->reindex_oid($sync, $git, $1);
 			} elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\td$/o) {
 				$self->mark_deleted($sync, $git, $1);
 			}
-- 
EW


  parent reply	other threads:[~2019-05-29  8:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29  8:28 [PATCH 00/10] index: support progress output Eric Wong
2019-05-29  8:28 ` [PATCH 01/10] v2writable: introduce $sync state and put mm_tmp in it Eric Wong
2019-05-29  8:28 ` [PATCH 02/10] v2writable: sync: move delete markers into $sync state Eric Wong
2019-05-29  8:28 ` [PATCH 03/10] v2writable: move {reindex} field to " Eric Wong
2019-05-29  8:28 ` Eric Wong [this message]
2019-05-29  8:28 ` [PATCH 05/10] v2writable: move {ranges} into " Eric Wong
2019-05-29  8:28 ` [PATCH 06/10] v2writable: localize unindex-range.$EPOCH to " Eric Wong
2019-05-29  8:28 ` [PATCH 07/10] v2writable: use prototypes for internal subs Eric Wong
2019-05-29  8:28 ` [PATCH 08/10] v2writable: move index_sync options to sync state Eric Wong
2019-05-29  8:28 ` [PATCH 09/10] index: support --verbose option Eric Wong
2019-05-29  8:29 ` [PATCH 10/10] v2writable: show progress updates for index_sync Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190529082900.9312-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).