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.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, 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 C7AD21F44D for ; Mon, 12 Feb 2024 11:02:07 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] WIP-join Date: Mon, 12 Feb 2024 11:02:07 +0000 Message-ID: <20240212110207.1253006-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: --- lib/PublicInbox/CodeSearch.pm | 16 +++++++++++++++- lib/PublicInbox/CodeSearchIdx.pm | 5 +++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/CodeSearch.pm b/lib/PublicInbox/CodeSearch.pm index 1f95a726..96732c79 100644 --- a/lib/PublicInbox/CodeSearch.pm +++ b/lib/PublicInbox/CodeSearch.pm @@ -227,7 +227,7 @@ BUG? (non-fatal) `$git_dir' not indexed in $self->{topdir} @ret; } -sub paths2roots { +sub paths2roots { # for diagnostics my ($self, $paths) = @_; my %ret; if ($paths) { @@ -243,6 +243,20 @@ sub paths2roots { \%ret; } +sub basename_roots { # for diagnostics + my ($self, $paths) = @_; + my $tmp = paths2roots($self, $paths); + my $ret = {}; + while (my ($git_dir, $roots) = each %$tmp) { + my $bn = substr($git_dir, rindex($git_dir, '/') + 1); + ++$ret->{$bn}->{$_} for @$roots; + } + # for my $bn (keys %$ret) { + # $ret->{$bn} + # } + $ret; +} + sub load_ct { # retry_reopen cb my ($self, $git_dir) = @_; my @ids = docids_of_git_dir $self, $git_dir or return; diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index 570ff64f..91c0146b 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -1250,10 +1250,11 @@ sub show_json { # for diagnostics (unstable output) my %ret; my @todo = @$s; while (defined(my $f = shift @todo)) { - if ($f =~ /\A(?:roots2paths|paths2roots|join_data)\z/) { + if ($f =~ /\A(?:roots2paths|paths2roots|join_data| + basename_roots)\z/x) { $ret{$f} = $self->$f; } elsif ($f eq '') { # default --show (no args) - push @todo, qw(roots2paths join_data); + push @todo, qw(basename_roots join_data); } else { warn "E: cannot show `$f'\n"; }