]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/rcs__95__diff_implementation_for_Mercurial_backend__44___based_on_Git_backend.mdwn
How signinview handles the goto leak
[ikiwiki.git] / doc / todo / rcs__95__diff_implementation_for_Mercurial_backend__44___based_on_Git_backend.mdwn
1 (**Note:** this patch is built on top of [[Attempt to extend Mercurial backend support]] and [[rcs__95__get__123__c__44__m__125__time_implementation_for_Mercurial_backend__44___based_on_Git_backend]]. The former is needed for the `safe_hg()` definition. The latter only shows up in the very last line matching of this patch.)
2
3 CC of `rcs_diff` implementation in `git.pm` with few changes. Mercurial provides the `hg diff -g` switch, which outputs the diff in Git-format, making the implementation easy. I think it's a good idea to base `mercurial.pm` as much as possible om `git.pm` to simplify and be able to benefit from the maintenance of `git.pm`, which probably is more used.
4
5 [Patch at my hg repo](http://510x.se/hg/program/ikiwiki/diff/cc73d670bf99/Plugin/mercurial.pm) ([raw format](http://510x.se/hg/program/ikiwiki/raw-file/cc73d670bf99/Plugin/mercurial.pm)).
6
7 --[[Daniel Andersson]]
8
9 > Guess that makes sense, [[done]] --[[Joey]] 
10
11 ---
12
13         diff -r 1b6c46b62a28 -r cc73d670bf99 Plugin/mercurial.pm
14         --- a/Plugin/mercurial.pm       Tue Jul 19 13:35:17 2011 +0200
15         +++ b/Plugin/mercurial.pm       Tue Jul 19 13:35:37 2011 +0200
16         @@ -307,7 +307,23 @@
17          }
18          
19          sub rcs_diff ($;$) {
20         -       # TODO
21         +       my $rev=shift;
22         +       my $maxlines=shift;
23         +       my @lines;
24         +       my $addlines=sub {
25         +               my $line=shift;
26         +               return if defined $maxlines && @lines == $maxlines;
27         +               push @lines, $line."\n"
28         +                       if (@lines || $line=~/^diff --git/);
29         +               return 1;
30         +       };
31         +       safe_hg(undef, $addlines, "hg", "diff", "-c", $rev, "-g");
32         +       if (wantarray) {
33         +               return @lines;
34         +       }
35         +       else {
36         +               return join("", @lines);
37         +       }
38          }
39          
40          {