X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/8c55424b11edbe1fd3e6ff1e20ec85c1f3c6e593..60111384a9c178b03cd778c298e28953ca80177b:/IkiWiki/Plugin/cvs.pm diff --git a/IkiWiki/Plugin/cvs.pm b/IkiWiki/Plugin/cvs.pm index 2c2445f39..d44ded505 100644 --- a/IkiWiki/Plugin/cvs.pm +++ b/IkiWiki/Plugin/cvs.pm @@ -5,7 +5,10 @@ use warnings; use strict; use IkiWiki; +use File::chdir; + sub import { + hook(type => "genwrapper", id => "cvs", call => \&genwrapper); hook(type => "checkconfig", id => "cvs", call => \&checkconfig); hook(type => "getsetup", id => "cvs", call => \&getsetup); hook(type => "rcs", id => "rcs_update", call => \&rcs_update); @@ -20,6 +23,17 @@ sub import { hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); } +sub genwrapper () { + return <&STDOUT"); open(STDOUT, ">", "/dev/null"); @@ -251,7 +265,7 @@ sub rcs_rename ($$) { return unless cvs_is_controlling; - chdir $config{srcdir} || error("Cannot chdir to $config{srcdir}: $!"); + local $CWD = $config{srcdir}; if (system("mv", "$src", "$dest") != 0) { warn("filesystem rename failed\n"); @@ -270,7 +284,7 @@ sub rcs_recentchanges($) { eval q{use Date::Parse}; error($@) if $@; - chdir $config{srcdir} || error("Cannot chdir to $config{srcdir}: $!"); + local $CWD = $config{srcdir}; # There's no cvsps option to get the last N changesets. # Write full output to a temp file and read backwards. @@ -284,7 +298,8 @@ sub rcs_recentchanges($) { system("env TZ=UTC cvsps -q --cvs-direct -z 30 -x >$tmpfile"); if ($? == -1) { error "couldn't run cvsps: $!\n"; - } elsif (($? >> 8) != 0) { + } + elsif (($? >> 8) != 0) { error "cvsps exited " . ($? >> 8) . ": $!\n"; } @@ -394,7 +409,7 @@ sub rcs_recentchanges($) { sub rcs_diff ($) { my $rev=IkiWiki::possibly_foolish_untaint(int(shift)); - chdir $config{srcdir} || error("Cannot chdir to $config{srcdir}: $!"); + local $CWD = $config{srcdir}; # diff output is unavoidably preceded by the cvsps PatchSet entry my @cvsps = `env TZ=UTC cvsps -q --cvs-direct -z 30 -g -s $rev`;