]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/mercurial.pm
mercurial: Implement rcs_diff. (Daniel Andersson)
[git.ikiwiki.info.git] / IkiWiki / Plugin / mercurial.pm
index e64e00512155e3bd6aa94839b85a6102fcc73b98..102b4692b805024ec02dc78a7db09896436e3d2b 100644 (file)
@@ -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);
+       }
 }
 
 {