]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/bzr_2.0_breaks_bzr_plugin.mdwn
bda07d15be2e58e0512899949474a47229c74481
[ikiwiki.git] / doc / bugs / bzr_2.0_breaks_bzr_plugin.mdwn
1 Version 2.0 of bzr seems to break the bzr plugin.
2
3 I traced this to the bzr_log method in the plugin, and patching that seems to fix it. The plugin just needs to parse the input little bit differently.
4 --liw
5
6     From fb897114124e627fd3acf5af8e784c9a77419a81 Mon Sep 17 00:00:00 2001
7     From: Lars Wirzenius <liw@liw.fi>
8     Date: Sun, 4 Apr 2010 21:05:07 +1200
9     Subject: [PATCH] Fix bzr plugin to work with bzr 2.0.
10
11     The output of "bzr log" seems to have changed a bit, so we change the
12     parsing accordingly. This has not been tested with earlier versions of
13     bzr.
14
15     Several problems seemed to occur, all in the bzr_log subroutine:
16
17     1. The @infos list would contain an empty hash, which would confuse the
18        rest of the program.
19     2. This was because bzr_log would push an empty anonymous hash to the
20        list whenever it thought a new record would start.
21     3. However, a new record marker (now?) also happens at th end of bzr log
22        output.
23     4. Now we collect the record to a hash that gets pushed to the list only
24        if it is not empty.
25     5. Also, sometimes bzr log outputs "revno: 1234 [merge]", so we catch only
26        the revision number.
27     6. Finally, there may be non-headers at the of the output, so we ignore
28        those.
29     ---
30      IkiWiki/Plugin/bzr.pm |   23 ++++++++++++++++-------
31      1 files changed, 16 insertions(+), 7 deletions(-)
32
33     diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm
34     index 1ffdc23..e813331 100644
35     --- a/IkiWiki/Plugin/bzr.pm
36     +++ b/IkiWiki/Plugin/bzr.pm
37     @@ -73,28 +73,37 @@ sub bzr_log ($) {
38         my @infos = ();
39         my $key = undef;
40      
41     +    my $hash = {};
42         while (<$out>) {
43                 my $line = $_;
44                 my ($value);
45                 if ($line =~ /^message:/) {
46                         $key = "message";
47     -                   $infos[$#infos]{$key} = "";
48     +                   $$hash{$key} = "";
49                 }
50                 elsif ($line =~ /^(modified|added|renamed|renamed and modified|removed):/) {
51                         $key = "files";
52     -                   unless (defined($infos[$#infos]{$key})) { $infos[$#infos]{$key} = ""; }
53     +                   unless (defined($$hash{$key})) { $$hash{$key} = ""; }
54                 }
55                 elsif (defined($key) and $line =~ /^  (.*)/) {
56     -                   $infos[$#infos]{$key} .= "$1\n";
57     +                   $$hash{$key} .= "$1\n";
58                 }
59                 elsif ($line eq "------------------------------------------------------------\n") {
60     +               if (keys %$hash) {
61     +                       push (@infos, $hash);
62     +               }
63     +                   $hash = {};
64                         $key = undef;
65     -                   push (@infos, {});
66                 }
67     -           else {
68     +           elsif ($line =~ /: /) {
69                         chomp $line;
70     -                           ($key, $value) = split /: +/, $line, 2;
71     -                   $infos[$#infos]{$key} = $value;
72     +                   if ($line =~ /^revno: (\d+)/) {
73     +                       $key = "revno";
74     +                       $value = $1;
75     +                   } else {
76     +                           ($key, $value) = split /: +/, $line, 2;
77     +                   }
78     +                   $$hash{$key} = $value;
79                 } 
80         }
81         close $out;
82     -- 
83     1.7.0