X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/b4db945b34d0475894467792acc69038d5b25306..4fe1538b4df838f73382ed64648aa7c12c7ef50a:/IkiWiki/Plugin/mercurial.pm diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index e64e00512..b7fe01485 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -180,7 +180,6 @@ sub rcs_commit_helper (@) { $ENV{HGENCODING} = 'utf-8'; my $user="Anonymous"; - my $nickname; if (defined $params{session}) { if (defined $params{session}->param("name")) { $user = $params{session}->param("name"); @@ -189,6 +188,7 @@ sub rcs_commit_helper (@) { $user = $params{session}->remote_addr(); } + my $nickname=$user; if (defined $params{session}->param("nickname")) { $nickname=encode_utf8($params{session}->param("nickname")); $nickname=~s/\s+/_/g; @@ -307,7 +307,23 @@ sub rcs_recentchanges ($) { } sub rcs_diff ($;$) { - # TODO + my $rev=shift; + my $maxlines=shift; + my @lines; + my $addlines=sub { + my $line=shift; + return if defined $maxlines && @lines == $maxlines; + push @lines, $line."\n" + if (@lines || $line=~/^diff --git/); + return 1; + }; + safe_hg(undef, $addlines, "hg", "diff", "-c", $rev, "-g"); + if (wantarray) { + return @lines; + } + else { + return join("", @lines); + } } { @@ -345,15 +361,8 @@ sub findtimes ($$) { print $tmpl_fh 'file = "{file}\\n"' . "\n"; foreach my $line (run_or_die('hg', 'log', '--style', $tmpl_filename)) { - # {date} gives output on the form - # 1310694511.0-7200 - # where the first number is UTC Unix timestamp with one - # decimal (decimal always 0, at least on my system) - # followed by local timezone offset from UTC in - # seconds. - if (! defined $date && $line =~ /^\d+\.\d[+-]\d*$/) { - $line =~ s/^(\d+).*/$1/; - $date=$line; + if (! defined $date && $line =~ /^(\d+)/) { + $date=$1; } elsif (! length $line) { $date=undef;