Merge remote branch 'davrieb/autotag' into autotag
[ikiwiki.git] / IkiWiki / Plugin / bzr.pm
index 6e45c39e44ccefaa37851ea6a0b604362167c437..f79ca7c8f52e53831414d7f327d44664a4bf67b2 100644 (file)
@@ -20,6 +20,7 @@ sub import {
        hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
        hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
        hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
+       hook(type => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime);
 }
 
 sub checkconfig () {
@@ -73,26 +74,24 @@ sub bzr_log ($) {
        my @infos = ();
        my $key = undef;
 
-       my $hash = {};
+       my %info;
        while (<$out>) {
                my $line = $_;
                my ($value);
                if ($line =~ /^message:/) {
                        $key = "message";
-                       $$hash{$key} = "";
+                       $info{$key} = "";
                }
                elsif ($line =~ /^(modified|added|renamed|renamed and modified|removed):/) {
                        $key = "files";
-                       unless (defined($$hash{$key})) { $$hash{$key} = ""; }
+                       $info{$key} = "" unless defined $info{$key};
                }
                elsif (defined($key) and $line =~ /^  (.*)/) {
-                       $$hash{$key} .= "$1\n";
+                       $info{$key} .= "$1\n";
                }
                elsif ($line eq "------------------------------------------------------------\n") {
-                       if (keys %$hash) {
-                               push (@infos, $hash);
-                       }
-                       $hash = {};
+                       push @infos, {%info} if keys %info;
+                       %info = ();
                        $key = undef;
                }
                elsif ($line =~ /: /) {
@@ -104,10 +103,11 @@ sub bzr_log ($) {
                        else {
                                ($key, $value) = split /: +/, $line, 2;
                        }
-                       $$hash{$key} = $value;
+                       $info{$key} = $value;
                }
        }
        close $out;
+       push @infos, {%info} if keys %info;
 
        return @infos;
 }
@@ -307,4 +307,8 @@ sub rcs_getctime ($) {
        return $ctime;
 }
 
+sub rcs_getmtime ($) {
+       error "rcs_getmtime is not implemented for bzr\n"; # TODO
+}
+
 1