aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Rcs/bazaar.pm69
-rwxr-xr-xt/bazaar.t6
2 files changed, 30 insertions, 45 deletions
diff --git a/IkiWiki/Rcs/bazaar.pm b/IkiWiki/Rcs/bazaar.pm
index 21821586b..80aba6a45 100644
--- a/IkiWiki/Rcs/bazaar.pm
+++ b/IkiWiki/Rcs/bazaar.pm
@@ -10,44 +10,28 @@ package IkiWiki;
sub bazaar_log($) {
my $out = shift;
- my @infos;
+ my @infos = ();
+ my $key = undef;
while (<$out>) {
my $line = $_;
- my ($key, $value);
-
- if (/^description:/) {
- $key = "description";
- $value = "";
-
- # slurp everything as the description text
- # until the next changeset
- while (<$out>) {
- if (/^changeset: /) {
- $line = $_;
- last;
- }
-
- $value .= $_;
- }
-
- local $/ = "";
- chomp $value;
+ my ($value);
+ if ($line =~ /^message:/) {
+ $key = "message";
+ $infos[$#infos]{$key} = "";
+ } elsif ($line =~ /^(modified|added|renamed|renamed and modified|removed):/) {
+ $key = "files";
+ unless (defined($infos[$#infos]{$key})) { $infos[$#infos]{$key} = ""; }
+ } elsif (defined($key) and $line =~ /^ (.*)/) {
+ $infos[$#infos]{$key} .= $1;
+ } elsif ($line eq "------------------------------------------------------------\n") {
+ $key = undef;
+ push (@infos, {});
+ } else {
+ chomp $line;
+ ($key, $value) = split /: +/, $line, 2;
$infos[$#infos]{$key} = $value;
- }
-
- chomp $line;
- ($key, $value) = split /: +/, $line, 2;
-
- if ($key eq "changeset") {
- push @infos, {};
-
- # remove the revision index, which is strictly
- # local to the repository
- $value =~ s/^\d+://;
- }
-
- $infos[$#infos]{$key} = $value;
+ }
}
close $out;
@@ -118,14 +102,14 @@ sub rcs_recentchanges ($) { #{{{
my @pages = ();
my @message = ();
- foreach my $msgline (split(/\n/, $info->{description})) {
+ foreach my $msgline (split(/\n/, $info->{message})) {
push @message, { line => $msgline };
}
- foreach my $file (split / /,$info->{files}) {
+ foreach my $file (split(/\n/, $info->{files})) {
my $diffurl = $config{'diffurl'};
$diffurl =~ s/\[\[file\]\]/$file/go;
- $diffurl =~ s/\[\[r2\]\]/$info->{changeset}/go;
+ $diffurl =~ s/\[\[r2\]\]/$info->{revno}/go;
push @pages, {
page => pagename($file),
@@ -133,15 +117,16 @@ sub rcs_recentchanges ($) { #{{{
};
}
- my $user = $info->{"user"};
+ my $user = $info->{"committer"};
+ if (defined($info->{"author"})) { $user = $info->{"author"}; }
$user =~ s/\s*<.*>\s*$//;
$user =~ s/^\s*//;
push @ret, {
- rev => $info->{"changeset"},
+ rev => $info->{"revno"},
user => $user,
committype => "bazaar",
- when => time - str2time($info->{"date"}),
+ when => time - str2time($info->{"timestamp"}),
message => [@message],
pages => [@pages],
};
@@ -159,7 +144,7 @@ sub rcs_getctime ($) { #{{{
# XXX filename passes through the shell here, should try to avoid
# that just in case
- my @cmdline = ("bzr", "log", "-v", "--limit", '1', "$config{srcdir}/$file");
+ my @cmdline = ("bzr", "log", "--limit", '1', "$config{srcdir}/$file");
open (my $out, "@cmdline |");
my @log = bazaar_log($out);
@@ -171,7 +156,7 @@ sub rcs_getctime ($) { #{{{
eval q{use Date::Parse};
error($@) if $@;
- my $ctime = str2time($log[0]->{"date"});
+ my $ctime = str2time($log[0]->{"timestamp"});
return $ctime;
} #}}}
diff --git a/t/bazaar.t b/t/bazaar.t
index 67a15875f..75534682b 100755
--- a/t/bazaar.t
+++ b/t/bazaar.t
@@ -44,8 +44,8 @@ my $message = "Added the second page";
my $test2 = readfile("t/test2.mdwn");
writefile('test2.mdwn', $config{srcdir}, $test2);
-system "bzr add -R $config{srcdir} $config{srcdir}/test2.mdwn";
-system "bzr commit -R $config{srcdir} -u \"$user\" -m \"$message\" -d \"0 0\"";
+system "bzr add $config{srcdir}/test2.mdwn";
+system "bzr commit --author \"$user\" -m \"$message\" $config{srcdir}";
@changes = IkiWiki::rcs_recentchanges(3);
@@ -57,6 +57,6 @@ is($changes[0]{pages}[0]{"page"}, "test2.mdwn");
is($changes[1]{pages}[0]{"page"}, "test1.mdwn");
my $ctime = IkiWiki::rcs_getctime("test2.mdwn");
-is($ctime, 0);
+ok($ctime >= time() - 20);
system "rm -rf $dir";