diff options
author | Joey Hess <joey@kitenet.net> | 2010-12-29 19:58:49 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-12-29 19:58:49 -0400 |
commit | 4fb26f4e60f2df282fc972e4b8506ccd306de789 (patch) | |
tree | ba95769fbc59a296364076fd2e649f3ebc0438af /IkiWiki/Plugin/monotone.pm | |
parent | 7d48813166c637e5bb2e11ef690fc7521716bd31 (diff) | |
download | ikiwiki-4fb26f4e60f2df282fc972e4b8506ccd306de789.tar ikiwiki-4fb26f4e60f2df282fc972e4b8506ccd306de789.tar.gz |
Add a second parameter to the rcs_diff hook, and avoid bloating memory reading in enormous commits.
Diffstat (limited to 'IkiWiki/Plugin/monotone.pm')
-rw-r--r-- | IkiWiki/Plugin/monotone.pm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index 02690b10e..38313a542 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -621,8 +621,9 @@ sub rcs_recentchanges ($) { return @ret; } -sub rcs_diff ($) { +sub rcs_diff ($;$) { my $rev=shift; + my $maxlines=shift; my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint chdir $config{srcdir} @@ -633,7 +634,11 @@ sub rcs_diff ($) { exec("mtn", "diff", "--root=$config{mtnrootdir}", "-r", "p:".$sha1, "-r", $sha1) || error("mtn diff $sha1 failed to run"); } - my (@lines) = <MTNDIFF>; + my @lines; + while (my $line=<MTNDIFF>) { + last if defined $maxlines && @lines == $maxlines; + push @lines, $line; + } close MTNDIFF || debug("mtn diff $sha1 exited $?"); |