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 08/10] v2writable: move index_sync options to sync state
Date: Wed, 29 May 2019 08:28:58 +0000	[thread overview]
Message-ID: <20190529082900.9312-9-e@80x24.org> (raw)
In-Reply-To: <20190529082900.9312-1-e@80x24.org>

And use singular `opt' to be consistent with the common name
of 'getopt'.
---
 lib/PublicInbox/V2Writable.pm | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 045a9cc..aa180a2 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -851,15 +851,15 @@ $range
 	$range;
 }
 
-sub sync_prepare ($$$$) {
-	my ($self, $sync, $opts, $epoch_max) = @_;
-	my $pr = $opts->{-progress};
+sub sync_prepare ($$$) {
+	my ($self, $sync, $epoch_max) = @_;
+	my $pr = $sync->{-opt}->{-progress};
 	my $regen_max = 0;
 	my $head = $self->{-inbox}->{ref_head} || 'refs/heads/master';
 
 	# reindex stops at the current heads and we later rerun index_sync
 	# without {reindex}
-	my $reindex_heads = last_commits($self, $epoch_max) if $opts->{reindex};
+	my $reindex_heads = last_commits($self, $epoch_max) if $sync->{reindex};
 
 	for (my $i = $epoch_max; $i >= 0; $i--) {
 		die 'BUG: already indexing!' if $self->{reindex_pipe};
@@ -887,7 +887,7 @@ sub sync_prepare ($$$$) {
 	}
 	# 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};
+	return -1 if $sync->{reindex};
 	$regen_max + $self->{mm}->num_highwater() || 0;
 }
 
@@ -927,7 +927,7 @@ sub unindex_oid ($$$) {
 
 my $x40 = qr/[a-f0-9]{40}/;
 sub unindex ($$$$) {
-	my ($self, $opts, $git, $unindex_range) = @_;
+	my ($self, $sync, $git, $unindex_range) = @_;
 	my $un = $self->{unindexed} ||= {}; # num => removal count
 	my $before = scalar keys %$un;
 	my @cmd = qw(log --raw -r
@@ -940,7 +940,7 @@ sub unindex ($$$$) {
 	delete $self->{reindex_pipe};
 	$fh = undef;
 
-	return unless $opts->{prune};
+	return unless $sync->{-opt}->{prune};
 	my $after = scalar keys %$un;
 	return if $before == $after;
 
@@ -965,19 +965,20 @@ sub sync_ranges ($$$) {
 
 # public, called by public-inbox-index
 sub index_sync {
-	my ($self, $opts) = @_;
-	$opts ||= {};
+	my ($self, $opt) = @_;
+	$opt ||= {};
 	my $epoch_max;
 	my $latest = git_dir_latest($self, \$epoch_max);
 	return unless defined $latest;
-	$self->idx_init($opts); # acquire lock
+	$self->idx_init($opt); # acquire lock
 	my $sync = {
 		mm_tmp => $self->{mm}->tmp_clone,
 		D => {}, # "$mid\0$cid" => $oid
-		reindex => $opts->{reindex},
+		reindex => $opt->{reindex},
+		-opt => $opt
 	};
 	$sync->{ranges} = sync_ranges($self, $sync, $epoch_max);
-	$sync->{regen} = sync_prepare($self, $sync, $opts, $epoch_max);
+	$sync->{regen} = sync_prepare($self, $sync, $epoch_max);
 
 	my @cmd = qw(log --raw -r --pretty=tformat:%H
 			--no-notes --no-color --no-abbrev --no-renames);
@@ -990,7 +991,7 @@ sub index_sync {
 		fill_alternates($self, $i);
 		my $git = PublicInbox::Git->new($git_dir);
 		my $unindex_range = delete $sync->{"unindex-range.$i"};
-		unindex($self, $opts, $git, $unindex_range) if $unindex_range;
+		unindex($self, $sync, $git, $unindex_range) if $unindex_range;
 		defined(my $range = $sync->{ranges}->[$i]) or next;
 		my $fh = $self->{reindex_pipe} = $git->popen(@cmd, $range);
 		my $cmt;
@@ -1020,8 +1021,8 @@ sub index_sync {
 	$self->done;
 
 	# reindex does not pick up new changes, so we rerun w/o it:
-	if ($opts->{reindex}) {
-		my %again = %$opts;
+	if ($opt->{reindex}) {
+		my %again = %$opt;
 		$sync = undef;
 		delete @again{qw(reindex -skip_lock)};
 		index_sync($self, \%again);
-- 
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 ` [PATCH 04/10] v2writable: move {regen} into " Eric Wong
2019-05-29  8:28 ` [PATCH 05/10] v2writable: move {ranges} " 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 ` Eric Wong [this message]
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: https://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-9-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).