X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ecdfd1b8644bc926db008054ab6192e18351afed..b25f7700bde4981d1fb69d89c1451abc0c7bb87a:/IkiWiki/Plugin/darcs.pm diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 0dfc8708d..646f65df1 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -3,6 +3,7 @@ package IkiWiki::Plugin::darcs; use warnings; use strict; +use URI::Escape q{uri_escape_utf8}; use IkiWiki; sub import { @@ -336,7 +337,8 @@ sub rcs_recentchanges ($) { foreach my $f (@files) { my $d = defined $config{'diffurl'} ? $config{'diffurl'} : ""; - $d =~ s/\[\[file\]\]/$f/go; + my $ef = uri_escape_utf8($f); + $d =~ s/\[\[file\]\]/$ef/go; $d =~ s/\[\[hash\]\]/$hash/go; push @pg, { @@ -373,11 +375,14 @@ sub rcs_recentchanges ($) { return @ret; } -sub rcs_diff ($) { +sub rcs_diff ($;$) { my $rev=shift; + my $maxlines=shift; my @lines; - foreach my $line (silentsystem("darcs", "diff", "--match", "hash ".$rev)) { + my $repodir=$config{srcdir}; + foreach my $line (`darcs diff --repodir $repodir --match 'hash $rev'`) { if (@lines || $line=~/^diff/) { + last if defined $maxlines && @lines == $maxlines; push @lines, $line."\n"; } } @@ -396,14 +401,11 @@ sub rcs_getctime ($) { eval q{use XML::Simple}; local $/=undef; - my $filer=substr($file, length($config{srcdir})); - $filer =~ s:^[/]+::; - my $child = open(LOG, "-|"); if (! $child) { exec("darcs", "changes", "--xml", "--reverse", - "--repodir", $config{srcdir}, $filer) - || error("'darcs changes $filer' failed to run"); + "--repodir", $config{srcdir}, $file) + || error("'darcs changes $file' failed to run"); } my $data; @@ -418,7 +420,7 @@ sub rcs_getctime ($) { my $datestr = $log->{patch}[0]->{local_date}; if (! defined $datestr) { - warn "failed to get ctime for $filer"; + warn "failed to get ctime for $file"; return 0; }