user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 09/29] import: only pass Inbox object to SearchIdx->new
  @ 2019-11-15  9:50  5% ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2019-11-15  9:50 UTC (permalink / raw)
  To: meta

SearchIdx->new no longer accepts a GIT_DIR path as its argument
since commit 585314673236d664729fe3ab2d4fb229d1c0f2d5
("searchidx: require PublicInbox::Inbox (or InboxWritable) ref")
---
 lib/PublicInbox/Import.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index e1f48771..cb25215d 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -179,9 +179,9 @@ sub _update_git_info ($$) {
 		run_die([@cmd, qw(read-tree -m -v -i), $self->{ref}], $env);
 	}
 	run_die([@cmd, 'update-server-info'], undef);
-	($self->{path_type} eq '2/38') and eval {
+	my $ibx = $self->{-inbox};
+	($ibx && $self->{path_type} eq '2/38') and eval {
 		require PublicInbox::SearchIdx;
-		my $ibx = $self->{-inbox} || $git_dir;
 		my $s = PublicInbox::SearchIdx->new($ibx);
 		$s->index_sync({ ref => $self->{ref} });
 	};

^ permalink raw reply	[relevance 5%]

* [PATCH 1/2] searchidx: require PublicInbox::Inbox (or InboxWritable) ref
  2019-06-14 17:17  6% [PATCH 0/2] search*: require Inbox refs for ->new Eric Wong
@ 2019-06-14 17:17  7% ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2019-06-14 17:17 UTC (permalink / raw)
  To: meta

PublicInbox::Inbox objects have minimal dependencies, so
drop code to support old tests which existed before the
PublicInbox::Inbox object came into existence.
---
 lib/PublicInbox/SearchIdx.pm | 35 +++++++++++++----------------------
 t/nntpd.t                    |  4 ++--
 t/psgi_search.t              |  4 +++-
 t/search-thr-index.t         |  4 +++-
 t/search.t                   |  7 ++++---
 5 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 7cd67f1..a088ce7 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -30,31 +30,22 @@ my $xapianlevels = qr/\A(?:full|medium)\z/;
 
 sub new {
 	my ($class, $ibx, $creat, $part) = @_;
+	ref $ibx or die "BUG: expected PublicInbox::Inbox object: $ibx";
 	my $levels = qr/\A(?:full|medium|basic)\z/;
-	my $mainrepo = $ibx; # for "public-inbox-index" w/o entry in config
-	my $git_dir = $mainrepo;
-	my ($altid, $git);
-	my $version = 1;
+	my $mainrepo = $ibx->{mainrepo};
+	my $version = $ibx->{version} || 1;
 	my $indexlevel = 'full';
-	if (ref $ibx) {
-		$mainrepo = $ibx->{mainrepo};
-		$altid = $ibx->{altid};
-		$version = $ibx->{version} || 1;
-		if ($altid) {
-			require PublicInbox::AltId;
-			$altid = [ map {
-				PublicInbox::AltId->new($ibx, $_);
-			} @$altid ];
-		}
-		if ($ibx->{indexlevel}) {
-			if ($ibx->{indexlevel} =~ $levels) {
-				$indexlevel = $ibx->{indexlevel};
-			} else {
-				die("Invalid indexlevel $ibx->{indexlevel}\n");
-			}
+	my $altid = $ibx->{altid};
+	if ($altid) {
+		require PublicInbox::AltId;
+		$altid = [ map { PublicInbox::AltId->new($ibx, $_); } @$altid ];
+	}
+	if ($ibx->{indexlevel}) {
+		if ($ibx->{indexlevel} =~ $levels) {
+			$indexlevel = $ibx->{indexlevel};
+		} else {
+			die("Invalid indexlevel $ibx->{indexlevel}\n");
 		}
-	} else { # FIXME: old tests: old tests
-		$ibx = { mainrepo => $git_dir, version => 1 };
 	}
 	$ibx = PublicInbox::InboxWritable->new($ibx);
 	my $self = bless {
diff --git a/t/nntpd.t b/t/nntpd.t
index a95fb6f..c37880b 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -91,7 +91,7 @@ EOF
 		$im->add($mime);
 		$im->done;
 		if ($version == 1) {
-			my $s = PublicInbox::SearchIdx->new($mainrepo, 1);
+			my $s = PublicInbox::SearchIdx->new($ibx, 1);
 			$s->index_sync;
 		}
 	}
@@ -243,7 +243,7 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
 		$im->add($for_leafnode);
 		$im->done;
 		if ($version == 1) {
-			my $s = PublicInbox::SearchIdx->new($mainrepo, 1);
+			my $s = PublicInbox::SearchIdx->new($ibx, 1);
 			$s->index_sync;
 		}
 		my $hdr = $n->head("<$long_hdr>");
diff --git a/t/psgi_search.t b/t/psgi_search.t
index a650767..bbf5a96 100644
--- a/t/psgi_search.t
+++ b/t/psgi_search.t
@@ -6,6 +6,7 @@ use Test::More;
 use File::Temp qw/tempdir/;
 use Email::MIME;
 use PublicInbox::Config;
+use PublicInbox::Inbox;
 use PublicInbox::WWW;
 use bytes (); # only for bytes::length
 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
@@ -19,7 +20,8 @@ my $tmpdir = tempdir('pi-psgi-search.XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $git_dir = "$tmpdir/a.git";
 
 is(0, system(qw(git init -q --bare), $git_dir), "git init (main)");
-my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
+my $ibx = PublicInbox::Inbox->new({mainrepo => $git_dir});
+my $rw = PublicInbox::SearchIdx->new($ibx, 1);
 ok($rw, "search indexer created");
 my $digits = '10010260936330';
 my $ua = 'Pine.LNX.4.10';
diff --git a/t/search-thr-index.t b/t/search-thr-index.t
index 1872af8..0f593c2 100644
--- a/t/search-thr-index.t
+++ b/t/search-thr-index.t
@@ -13,11 +13,13 @@ foreach my $mod (@mods) {
 	plan skip_all => "missing $mod for $0" if $@;
 }
 require PublicInbox::SearchIdx;
+require PublicInbox::Inbox;
 my $tmpdir = tempdir('pi-search-thr-index.XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $git_dir = "$tmpdir/a.git";
 
 is(0, system(qw(git init -q --bare), $git_dir), "git init (main)");
-my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
+my $ibx = PublicInbox::Inbox->new({mainrepo => $git_dir});
+my $rw = PublicInbox::SearchIdx->new($ibx, 1);
 ok($rw, "search indexer created");
 my $data = <<'EOF';
 Subject: [RFC 00/14]
diff --git a/t/search.t b/t/search.t
index 538baef..d4c1e15 100644
--- a/t/search.t
+++ b/t/search.t
@@ -9,18 +9,19 @@ foreach my $mod (@mods) {
 	plan skip_all => "missing $mod for $0" if $@;
 };
 require PublicInbox::SearchIdx;
+require PublicInbox::Inbox;
 use File::Temp qw/tempdir/;
 use Email::MIME;
 my $tmpdir = tempdir('pi-search-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $git_dir = "$tmpdir/a.git";
+my $ibx = PublicInbox::Inbox->new({ mainrepo => $git_dir });
 my ($root_id, $last_id);
 
 is(0, system(qw(git init --shared -q --bare), $git_dir), "git init (main)");
 eval { PublicInbox::Search->new($git_dir)->xdb };
 ok($@, "exception raised on non-existent DB");
 
-my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
-my $ibx = $rw->{-inbox};
+my $rw = PublicInbox::SearchIdx->new($ibx, 1);
 $ibx->with_umask(sub {
 	$rw->_xdb_acquire;
 	$rw->_xdb_release;
@@ -29,7 +30,7 @@ $rw = undef;
 my $ro = PublicInbox::Search->new($git_dir);
 my $rw_commit = sub {
 	$rw->commit_txn_lazy if $rw;
-	$rw = PublicInbox::SearchIdx->new($git_dir, 1);
+	$rw = PublicInbox::SearchIdx->new($ibx, 1);
 	$rw->{qp_flags} = 0; # quiet a warning
 	$rw->begin_txn_lazy;
 };
-- 
EW


^ permalink raw reply	[relevance 7%]

* [PATCH 0/2] search*: require Inbox refs for ->new
@ 2019-06-14 17:17  6% Eric Wong
  2019-06-14 17:17  7% ` [PATCH 1/2] searchidx: require PublicInbox::Inbox (or InboxWritable) ref Eric Wong
  0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2019-06-14 17:17 UTC (permalink / raw)
  To: meta

Just removing some old cruft which predated the use of the
PublicInbox::Inbox object.  Diffstat says this is a win, too.

Eric Wong (2):
  searchidx: require PublicInbox::Inbox (or InboxWritable) ref
  search: require PublicInbox::Inbox ref here

 lib/PublicInbox/Inbox.pm     |  2 +-
 lib/PublicInbox/Search.pm    | 15 +++++----------
 lib/PublicInbox/SearchIdx.pm | 35 +++++++++++++----------------------
 t/altid.t                    |  5 +++--
 t/nntpd.t                    |  4 ++--
 t/psgi_search.t              |  4 +++-
 t/search-thr-index.t         |  4 +++-
 t/search.t                   | 11 ++++++-----
 8 files changed, 36 insertions(+), 44 deletions(-)

-- 
EW


^ permalink raw reply	[relevance 6%]

Results 1-3 of 3 | reverse | sort options + mbox downloads above
-- links below jump to the message on this page --
2019-06-14 17:17  6% [PATCH 0/2] search*: require Inbox refs for ->new Eric Wong
2019-06-14 17:17  7% ` [PATCH 1/2] searchidx: require PublicInbox::Inbox (or InboxWritable) ref Eric Wong
2019-11-15  9:50     [PATCH 00/29] speed up tests by preloading Eric Wong
2019-11-15  9:50  5% ` [PATCH 09/29] import: only pass Inbox object to SearchIdx->new Eric Wong

Code repositories for project(s) associated with this 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).