aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2010-04-16 18:43:51 -0400
committerJoey Hess <joey@gnu.kitenet.net>2010-04-16 18:46:20 -0400
commitb13bb0c83c8f23bca97734882997fd3dc29f0553 (patch)
tree0cf2f0d761a86af620338531fb6353dd10b69cab /IkiWiki/Plugin
parentdee2940c0bc97080088c99f399cd0ff0df3bec23 (diff)
downloadikiwiki-b13bb0c83c8f23bca97734882997fd3dc29f0553.tar
ikiwiki-b13bb0c83c8f23bca97734882997fd3dc29f0553.tar.gz
implement rcs_getmtime for svn
This is a slow implementation; it runs svn log once per file still, rather than running svn log once on the whole srcdir. I did it this way because in my experience, svn log, run on a directory, does not always list every change to files inside that directory. I don't know why, and I use svn as little as possible these days.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/svn.pm42
1 files changed, 31 insertions, 11 deletions
diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm
index 85c205f09..6e1d4a40f 100644
--- a/IkiWiki/Plugin/svn.pm
+++ b/IkiWiki/Plugin/svn.pm
@@ -350,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 ($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, "-|");
@@ -360,28 +369,39 @@ sub rcs_getctime ($) {
exec("svn", "log", $file) || error("svn log $file failed to run");
}
- my $date;
+ my ($cdate, $mdate);
while (<SVNLOG>) {
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 ($) {
- error "rcs_getmtime is not implemented for svn\n"; # TODO
+ my $file=shift;
+
+ return (findtimes($file))[0];
}
1