From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 01/18] solver: create tmpdir lazily
Date: Mon, 29 Aug 2022 09:26:30 +0000 [thread overview]
Message-ID: <20220829092647.1512215-2-e@80x24.org> (raw)
In-Reply-To: <20220829092647.1512215-1-e@80x24.org>
"lei blob" doesn't currently need it at all in some cases, and
the next commit will allow viewvcs to share tmpdirs to show
commits as HTML.
---
lib/PublicInbox/SolverGit.pm | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index dbb9b739..52dfaf3d 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -106,6 +106,11 @@ sub solve_existing ($$) {
scalar(@$try);
}
+sub _tmp {
+ $_[0]->{tmp} //=
+ File::Temp->newdir("solver.$_[0]->{oid_want}-XXXX", TMPDIR => 1);
+}
+
sub extract_diff ($$) {
my ($p, $arg) = @_;
my ($self, $want, $smsg) = @$arg;
@@ -193,8 +198,8 @@ sub extract_diff ($$) {
my $path = ++$self->{tot};
$di->{n} = $path;
- open(my $tmp, '>:utf8', $self->{tmp}->dirname . "/$path") or
- die "open(tmp): $!";
+ my $f = _tmp($self)->dirname."/$path";
+ open(my $tmp, '>:utf8', $f) or die "open($f): $!";
print $tmp $di->{hdr_lines}, $patch or die "print(tmp): $!";
close $tmp or die "close(tmp): $!";
@@ -284,8 +289,7 @@ sub prepare_index ($) {
# pure Perl "git init"
sub do_git_init ($) {
my ($self) = @_;
- my $dir = $self->{tmp}->dirname;
- my $git_dir = "$dir/git";
+ my $git_dir = _tmp($self)->dirname.'/git';
foreach ('', qw(objects refs objects/info refs/heads)) {
mkdir("$git_dir/$_") or die "mkdir $_: $!";
@@ -478,7 +482,6 @@ sub apply_result ($$) {
sub do_git_apply ($) {
my ($self) = @_;
- my $dn = $self->{tmp}->dirname;
my $patches = $self->{patches};
# we need --ignore-whitespace because some patches are CRLF
@@ -501,7 +504,7 @@ sub do_git_apply ($) {
} while (@$patches && $len < $ARG_SIZE_MAX &&
!oids_same_ish($patches->[0]->{oid_b}, $prv_oid_b));
- my $opt = { 2 => 1, -C => $dn, quiet => 1 };
+ my $opt = { 2 => 1, -C => _tmp($self)->dirname, quiet => 1 };
my $qsp = PublicInbox::Qspawn->new(\@cmd, $self->{git_env}, $opt);
$self->{-cur_di} = $di;
$qsp->{qsp_err} = \($self->{-qsp_err} = '');
@@ -683,7 +686,6 @@ sub solve ($$$$$) {
$self->{todo} = [ { %$hints, oid_b => $oid_want } ];
$self->{patches} = []; # [ $di, $di, ... ]
$self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] }
- $self->{tmp} = File::Temp->newdir("solver.$oid_want-XXXX", TMPDIR => 1);
dbg($self, "solving $oid_want ...");
if (my $async = $env->{'pi-httpd.async'}) {
next prev parent reply other threads:[~2022-08-29 9:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 9:26 [PATCH 00/18] WWW: patch, tree, git glossary Eric Wong
2022-08-29 9:26 ` Eric Wong [this message]
2022-08-29 9:26 ` [PATCH 02/18] viewvcs: share File::Temp::Dir with solver Eric Wong
2022-08-29 9:26 ` [PATCH 03/18] viewvcs: delay stringification of solver debug log Eric Wong
2022-08-29 9:26 ` [PATCH 04/18] www: allow html_oneshot to take an array arg Eric Wong
2022-08-29 9:26 ` [PATCH 05/18] viewvcs: use array for highlighted blob display Eric Wong
2022-08-29 9:26 ` [PATCH 06/18] viewvcs: add patch download link for single-parent commits Eric Wong
2022-08-29 9:26 ` [PATCH 07/18] viewvcs: author date links to contemporary messages Eric Wong
2022-08-29 9:26 ` [PATCH 08/18] view: speed up /$INBOX/ landing page by 0.5-1.0% Eric Wong
2022-08-29 9:26 ` [PATCH 09/18] treewide: ditch inbox->recent method Eric Wong
2022-08-29 9:26 ` [PATCH 10/18] view: /$INBOX/: show "messages from $old to $new" Eric Wong
2022-08-29 9:26 ` [PATCH 11/18] view: cleanups and reuse for {obuf} preparation Eric Wong
2022-08-29 9:26 ` [PATCH 12/18] www: atom: fix "changed" href to nowhere Eric Wong
2022-08-29 9:26 ` [PATCH 13/18] www: provide text/help/#search anchor Eric Wong
2022-08-29 9:26 ` [PATCH 14/18] solver: early make hints detection more robust Eric Wong
2022-08-29 9:26 ` [PATCH 15/18] viewvcs: add tree view Eric Wong
2022-08-29 9:26 ` [PATCH 16/18] viewvcs: reduce hash assignments for commit info Eric Wong
2022-08-29 9:26 ` [PATCH 17/18] viewvcs: add glossary for commit Eric Wong
2022-08-29 9:57 ` [19/18 PATCH] viewvcs: fixup commit glossary stuff Eric Wong
2022-08-29 9:26 ` [PATCH 18/18] viewvcs: show "blob $OID" rather than "$OID blob" 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=20220829092647.1512215-2-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.
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).