]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiQuery.pm
lei q: -I/--include overrides --no-(external|local|remote)
[public-inbox.git] / lib / PublicInbox / LeiQuery.pm
index c630d62809a38fa1184cdcb71b7f8cd0e4d87b80..532668aebf4a71d4480bbc222b3bc906a7eeb046 100644 (file)
@@ -52,7 +52,7 @@ sub lei_q {
        my $sto = $self->_lei_store(1);
        my $lse = $sto->search;
        if (($opt->{'import-remote'} //= 1) |
-                       ($opt->{'import-augment'} //= 1)) {
+                       (($opt->{'import-before'} //= \1) ? 1 : 0)) {
                $sto->write_prepare($self);
        }
        if ($opt->{'local'} //= scalar(@only) ? 0 : 1) {
@@ -64,9 +64,12 @@ sub lei_q {
                        $lxs->prepare_external($_) for @loc;
                }
        } else {
+               my (@ilocals, @iremotes);
                for my $loc (@{$opt->{include} // []}) {
                        my @loc = $self->get_externals($loc) or return;
                        $lxs->prepare_external($_) for @loc;
+                       @ilocals = @{$lxs->{locals} // []};
+                       @iremotes = @{$lxs->{remotes} // []};
                }
                # --external is enabled by default, but allow --no-external
                if ($opt->{external} //= 1) {
@@ -78,9 +81,9 @@ sub lei_q {
                        my $ne = $self->externals_each(\&prep_ext, $lxs, \%x);
                        $opt->{remote} //= !($lxs->locals - $opt->{'local'});
                        if ($opt->{'local'}) {
-                               delete($lxs->{remotes}) if !$opt->{remote};
+                               $lxs->{remotes} = \@iremotes if !$opt->{remote};
                        } else {
-                               delete($lxs->{locals});
+                               $lxs->{locals} = \@ilocals;
                        }
                }
        }