From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9BFB41F723 for ; Mon, 13 Nov 2023 13:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1699881354; bh=cQ3/Xio5lRWhp+5ndqNxkljvhbOYQAiqS+XLu5WsTEA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=taZXaoHGwcwEdVcWPzJIl0dTDHei7w4Aob2HI5g2JBZlqK1MrE7FPQECMOqoRV5Wr Rca0Jtmi/dnrCNaiNj0TD1I7DbrcbyiIj+uN66tb8wWiuuvklw8v5FLTbVMbAzY735 MrbuLvq3j9hHF8ToCJ4h6c6FLh3f0b5VSof7giJc= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/18] cindex: imply --all with --associate w/o -I/--only Date: Mon, 13 Nov 2023 13:15:43 +0000 Message-Id: <20231113131551.843230-11-e@80x24.org> In-Reply-To: <20231113131551.843230-1-e@80x24.org> References: <20231113131551.843230-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: I just forgot to use --all with --associate and it wasn't easily apparent what was wrong. We'll also show some extra progress while we're at it. --- lib/PublicInbox/CodeSearchIdx.pm | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index 3601176c..0bd26af2 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -1033,7 +1033,8 @@ sub init_associate_prefork ($) { $self->{-pi_cfg} = PublicInbox::Config->new; my @unknown; my @pfx = @{$self->{-opt}->{'associate-prefixes'} // [ 'patchid' ]}; - for (map { split(/\s*,\s*/) } @pfx) { + @pfx = map { split(/\s*,\s*/) } @pfx; + for (@pfx) { my $v = $PublicInbox::Search::PATCH_BOOL_COMMON{$_} // push(@unknown, $_); push(@ASSOC_PFX, split(/ /, $v)); @@ -1045,13 +1046,28 @@ EOM my %incl = map { rel2abs_collapsed($_) => undef; } (@{$self->{-opt}->{include} // []}); - $self->{-pi_cfg}->each_inbox(\&_prep_ibx, $self, \%incl); + my $all = $self->{-opt}->{all}; + if (my $only = $self->{-opt}->{only}) { + die <<'' if $all; +E: --all is incompatible with --only + + $incl{rel2abs_collapsed($_)} = undef for @$only; + } + unless (keys(%incl)) { + $all = 1; + warn <{opt}->{quiet}; +# --all implied since no inboxes were specified with --only or --include +EOM + } + $self->{-pi_cfg}->each_inbox(\&_prep_ibx, $self, \%incl, $all); + my $nr = scalar(@IBX) or die "E: no inboxes to associate\n"; + progress($self, "will associate $nr inboxes in ", + $self->{-pi_cfg}->{-f}, " using: @pfx"); } sub _prep_ibx { # each_inbox callback - my ($ibx, $self, $incl) = @_; - ($self->{-opt}->{all} || exists($incl->{$ibx->{inboxdir}})) and - push @IBX, $ibx; + my ($ibx, $self, $incl, $all) = @_; + ($all || exists($incl->{$ibx->{inboxdir}})) and push @IBX, $ibx; } sub show_roots { # for diagnostics