]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/monotone.pm
Merge branch 'ready/tag-test' into transient-tag
[ikiwiki.git] / IkiWiki / Plugin / monotone.pm
index 95fbcee7648c56c0825d714d15ad7bea37e93621..38313a542aff9bd231b036ae3d47367f55289578 100644 (file)
@@ -42,7 +42,7 @@ sub checkconfig () {
 
        my $version=undef;
        while (<MTN>) {
-               if (/^monotone (\d+\.\d+) /) {
+               if (/^monotone (\d+\.\d+)(?:(?:\.\d+){0,2}|dev)? /) {
                        $version=$1;
                }
        }
@@ -252,9 +252,20 @@ sub get_changed_files ($$) {
 
        my @ret;
        my %seen = ();
-       
+
+       # we need to strip off the relative path to the source dir
+       # because monotone outputs all file paths absolute according
+       # to the workspace root
+       my $rel_src_dir = $config{'srcdir'};
+       $rel_src_dir =~ s/^\Q$config{'mtnrootdir'}\E\/?//;
+       $rel_src_dir .= "/" if length $rel_src_dir;
+
        while ($changes =~ m/\s*(add_file|patch|delete|rename)\s"(.*?)(?<!\\)"\n/sg) {
                my $file = $2;
+               # ignore all file changes outside the source dir
+               next unless $file =~ m/^\Q$rel_src_dir\E/;
+               $file =~ s/^\Q$rel_src_dir\E//;
+        
                # don't add the same file multiple times
                if (! $seen{$file}) {
                        push @ret, $file;
@@ -610,8 +621,9 @@ sub rcs_recentchanges ($) {
        return @ret;
 }
 
-sub rcs_diff ($) {
+sub rcs_diff ($;$) {
        my $rev=shift;
+       my $maxlines=shift;
        my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
        
        chdir $config{srcdir}
@@ -622,7 +634,11 @@ sub rcs_diff ($) {
                exec("mtn", "diff", "--root=$config{mtnrootdir}", "-r", "p:".$sha1, "-r", $sha1) || error("mtn diff $sha1 failed to run");
        }
 
-       my (@lines) = <MTNDIFF>;
+       my @lines;
+       while (my $line=<MTNDIFF>) {
+               last if defined $maxlines && @lines == $maxlines;
+               push @lines, $line;
+       }
 
        close MTNDIFF || debug("mtn diff $sha1 exited $?");