X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/f1a70921e3bfc0496b5564582a5a1463b7a98c09..57e56828f5b03f8fb31631f36731f989d4335607:/IkiWiki/Plugin/svn.pm diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index 06b987f51..d10b4888d 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -19,6 +19,7 @@ sub import { hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); + hook(type => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub checkconfig () { @@ -44,6 +45,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => undef, + section => "rcs", }, svnrepo => { type => "string", @@ -348,9 +350,18 @@ sub rcs_diff ($) { return `svnlook diff $config{svnrepo} -r$rev --no-diff-deleted`; } -sub rcs_getctime ($) { +{ + +my ($lastfile, $lastmtime, $lastctime); + +sub findtimes ($) { my $file=shift; + if (defined $lastfile && $lastfile eq $file) { + return $lastmtime, $lastctime; + } + $lastfile=$file; + my $svn_log_infoline=qr/^r\d+\s+\|\s+[^\s]+\s+\|\s+(\d+-\d+-\d+\s+\d+:\d+:\d+\s+[-+]?\d+).*/; my $child = open(SVNLOG, "-|"); @@ -358,24 +369,39 @@ sub rcs_getctime ($) { exec("svn", "log", $file) || error("svn log $file failed to run"); } - my $date; + my ($cdate, $mdate); while () { if (/$svn_log_infoline/) { - $date=$1; + $cdate=$1; + $mdate=$1 unless defined $mdate; } } - close SVNLOG || warn "svn log $file exited $?"; + close SVNLOG || error "svn log $file exited $?"; - if (! defined $date) { - warn "failed to parse svn log for $file\n"; - return 0; + if (! defined $cdate) { + error "failed to parse svn log for $file\n"; } eval q{use Date::Parse}; error($@) if $@; - $date=str2time($date); - debug("found ctime ".localtime($date)." for $file"); - return $date; + + $lastctime=str2time($cdate); + $lastmtime=str2time($mdate); + return $lastmtime, $lastctime; +} + +} + +sub rcs_getctime ($) { + my $file=shift; + + return (findtimes($file))[1]; +} + +sub rcs_getmtime ($) { + my $file=shift; + + return (findtimes($file))[0]; } 1