(no commit message)
[ikiwiki.git] / doc / bugs / bzr_plugin_does_not_define_rcs__95__diff.mdwn
1 The bzr plugin does not seem to define the rcs_diff subroutine.
2 I got the follow error after enabling recentchangesdiff:
3
4 "Undefined subroutine &IkiWiki::Plugin::bzr::rcs_diff called at /usr/share/perl5/IkiWiki.pm line 1590."
5
6 Grepping to verify absence of rcs_diff:
7
8     $ grep rcs_diff /usr/share/perl5/IkiWiki/Plugin/{git,bzr}.pm
9     /usr/share/perl5/IkiWiki/Plugin/git.pm:     hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
10     /usr/share/perl5/IkiWiki/Plugin/git.pm:sub rcs_diff ($) {
11     /usr/share/perl5/IkiWiki/Plugin/bzr.pm:     hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
12
13 > I've added the minimal stub needed to avoid the crash, but for
14 > recentchangesdiff to work, someone needs to implement `rcs_diff` for bzr.
15 > This should be trivial if you know and use bzr. The function
16 > is passed as a parameter the revno of interest and just needs
17 > to ask bzr for the diff between that and the previous version. --[[Joey]] 
18
19 >> I'll see if I can make a patch. The bzr command to get the revision would
20 >> look like this: bzr diff -r revno:$PREV:/path/to/src..revno:$REVNO:/path/to/src
21 >> (where $PREV would be $REVNO minus one). --liw
22
23 >> Sorry, that was not entirely correct, for some reason. I'll add a patch below that
24 >> seems to work. I am unfortunately not ready to set up a git repository that you
25 >> can pull from. --liw
26
27     diff --git a/IkiWiki/Plugin/.bzr.pm.swp b/IkiWiki/Plugin/.bzr.pm.swp
28     new file mode 100644
29     index 0000000..712120c
30     Binary files /dev/null and b/IkiWiki/Plugin/.bzr.pm.swp differ
31     diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm
32     index 783623d..f1d5854 100644
33     --- a/IkiWiki/Plugin/bzr.pm
34     +++ b/IkiWiki/Plugin/bzr.pm
35     @@ -256,7 +256,25 @@ sub rcs_recentchanges ($) {
36      }
37    
38      sub rcs_diff ($) {
39     -   # TODO
40     +        my $taintedrev=shift;
41     +   my ($rev) = $taintedrev =~ /^(\d+(\.\d+)*)$/; # untaint
42     +           print STDERR "taintedrev: $taintedrev\nrev: $rev\n";
43     +
44     +   my $prevspec = "before:" . $rev;
45     +   my $revspec = "revno:" . $rev;
46     +        my @cmdline = ("bzr", "diff", "--old", $config{srcdir},
47     +                  "--new", $config{srcdir},
48     +                  "-r", $prevspec . ".." . $revspec);
49     +   print STDERR "cmdline: @cmdline\n";
50     +        open (my $out, "@cmdline |");
51     +
52     +   my @lines = <$out>;
53     +        if (wantarray) {
54     +                return @lines;
55     +        }
56     +        else {
57     +                return join("", @lines);
58     +        }
59      }
60    
61      sub rcs_getctime ($) {