From: Eric Wong <normalperson@yhbt.net>
To: Marcus Griep <marcus@griep.us>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/3] git-svn: Make it scream by minimizing temp files
Date: Mon, 11 Aug 2008 20:14:42 -0700 [thread overview]
Message-ID: <20080812031442.GB14051@untitled> (raw)
In-Reply-To: <1218470035-13864-3-git-send-email-marcus@griep.us>
Marcus Griep <marcus@griep.us> wrote:
> ---
> git-svn.perl | 53 +++++++++++++++++++++++++++++++++++------------------
> 1 files changed, 35 insertions(+), 18 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index fe78461..0937918 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -1285,6 +1285,8 @@ use Carp qw/croak/;
> use File::Path qw/mkpath/;
> use File::Copy qw/copy/;
> use IPC::Open3;
> +use File::Temp ();
> +use File::Spec;
>
> my ($_gc_nr, $_gc_period);
>
> @@ -1323,10 +1325,11 @@ BEGIN {
> }
> }
>
> -my (%LOCKFILES, %INDEX_FILES);
> +my (%LOCKFILES, %INDEX_FILES, %TEMP_FILES);
> END {
> unlink keys %LOCKFILES if %LOCKFILES;
> unlink keys %INDEX_FILES if %INDEX_FILES;
> + unlink values %TEMP_FILES if %TEMP_FILES;
> }
> sub resolve_local_globs {
> @@ -2935,6 +2938,21 @@ sub remove_username {
> $_[0] =~ s{^([^:]*://)[^@]+@}{$1};
> }
>
> +sub _temp_file {
> + my ($self, $fd) = @_;
> + if (defined $TEMP_FILES{$fd}) {
> + truncate $TEMP_FILES{$fd}, 0 or croak $!;
> + sysseek $TEMP_FILES{$fd}, 0, 0 or croak $!;
> + } else {
> + $TEMP_FILES{$fd} = File::Temp->new(
> + TEMPLATE => 'GitSvn_XXXXXX',
> + DIR => File::Spec->tmpdir
> + ) or croak $!;
> + $TEMP_FILES{$fd}->autoflush(1);
> + }
> + $TEMP_FILES{$fd};
> +}
> +
The above is dead code now that we're using the versions in Git::,
right?
> @@ -3246,9 +3262,10 @@ sub apply_textdelta {
> - [ SVN::TxDelta::apply($base, $fh, undef, $fb->{path}, $fb->{pool}) ];
> + my $return = [ SVN::TxDelta::apply($base, $dup, undef, $fb->{path}, $fb->{pool}) ];
> + $return;
Why create a temporary variable? (and break the sacred 80-column limit).
> @@ -3277,22 +3294,23 @@ sub close_file {
> - or croak("write $tmp_filename: $!\n");
> + or croak("write ", $tmp_fh->filename, ": $!\n");
I missed this before, but $tmp_fh->filename doesn't interpolate correctly.
("write ${\$tmp_fh->filename}: $!\n")
or
("write ", $tmp_fh->filename, ": $!\n") works.
I believe the latter form is more idiomatic so we should probably use
that...
--
Eric Wong
next prev parent reply other threads:[~2008-08-12 3:16 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 22:41 [PATCH] git-svn: Make it scream by minimizing temp files Marcus Griep
2008-08-08 22:59 ` Junio C Hamano
2008-08-09 1:12 ` Marcus Griep
2008-08-09 6:25 ` Eric Wong
2008-08-09 15:45 ` Marcus Griep
2008-08-10 1:46 ` Eric Wong
2008-08-10 3:53 ` Junio C Hamano
2008-08-10 7:47 ` Eric Wong
2008-08-10 8:26 ` Junio C Hamano
2008-08-10 8:09 ` Eric Wong
2008-08-11 15:53 ` [PATCH 0/3] git-svn and temporary file improvements Marcus Griep
2008-08-11 15:53 ` [PATCH 1/3] Git.pm: Add faculties to allow temp files to be cached Marcus Griep
2008-08-11 15:53 ` [PATCH 2/3] git-svn: Make it scream by minimizing temp files Marcus Griep
2008-08-11 15:53 ` [PATCH 3/3] git-svn: Reduce temp file usage when dealing with non-links Marcus Griep
2008-08-12 3:37 ` Eric Wong
2008-08-12 15:53 ` Marcus Griep
2008-08-12 16:01 ` Marcus Griep
2008-08-12 16:45 ` [PATCH v2 " Marcus Griep
2008-08-13 3:29 ` [PATCH " Eric Wong
2008-08-13 3:42 ` Marcus Griep
2008-08-13 3:52 ` Eric Wong
2008-08-12 3:14 ` Eric Wong [this message]
2008-08-12 15:50 ` [PATCH 2/3] git-svn: Make it scream by minimizing temp files Marcus Griep
2008-08-12 16:00 ` [PATCH 2/3] git-svn: Make it incrementally faster " Marcus Griep
2008-08-13 3:29 ` Eric Wong
2008-08-12 3:08 ` [PATCH 1/3] Git.pm: Add faculties to allow temp files to be cached Eric Wong
2008-08-12 15:41 ` Marcus Griep
2008-08-12 16:00 ` Marcus Griep
2008-08-13 3:28 ` Eric Wong
2008-08-13 20:05 ` Lea Wiemann
2008-08-13 20:13 ` Marcus Griep
2008-08-13 20:31 ` Marcus Griep
2008-08-13 20:38 ` Junio C Hamano
2008-08-13 22:28 ` Lea Wiemann
2008-08-13 22:30 ` [PATCH] Git.pm: require Perl 5.6.1 Lea Wiemann
2008-08-14 6:58 ` [PATCH 1/3] Git.pm: Add faculties to allow temp files to be cached Eric Wong
2008-08-15 15:10 ` [PATCH] Git.pm: Make File::Spec and File::Temp requirement lazy Marcus Griep
2008-08-15 19:31 ` Bryan Donlan
2008-08-15 19:46 ` Marcus Griep
2008-08-15 19:53 ` [PATCH v2] " Marcus Griep
2008-08-13 20:52 ` [PATCH 1/3] Git.pm: Add faculties to allow temp files to be cached Miklos Vajna
2008-08-14 6:29 ` Junio C Hamano
2008-08-14 14:35 ` Marcus Griep
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080812031442.GB14051@untitled \
--to=normalperson@yhbt.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=marcus@griep.us \
/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