]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/cvs.pm
(no commit message)
[git.ikiwiki.info.git] / IkiWiki / Plugin / cvs.pm
index ccd697e1b48649576249b971bb239f743b910556..360d9724950c866c7cd4e5e6ca99053124d45b99 100644 (file)
@@ -1,7 +1,7 @@
-#!/usr/pkg/bin/perl
+#!/usr/bin/perl
 package IkiWiki::Plugin::cvs;
 
 package IkiWiki::Plugin::cvs;
 
-# Copyright (c) 2008 Amitai Schlair
+# Copyright (c) 2009 Amitai Schlair
 # All rights reserved.
 #
 # This code is derived from software contributed to ikiwiki
 # All rights reserved.
 #
 # This code is derived from software contributed to ikiwiki
@@ -49,10 +49,11 @@ 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_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 genwrapper () {
 }
 
 sub genwrapper () {
-       my $check_args=<<"EOF";
+       return <<EOF;
        {
                int j;
                for (j = 1; j < argc; j++)
        {
                int j;
                for (j = 1; j < argc; j++)
@@ -60,7 +61,6 @@ sub genwrapper () {
                                exit(0);
        }
 EOF
                                exit(0);
        }
 EOF
-       return $check_args;
 }
 
 sub checkconfig () {
 }
 
 sub checkconfig () {
@@ -86,6 +86,7 @@ sub getsetup () {
                plugin => {
                        safe => 0, # rcs plugin
                        rebuild => undef,
                plugin => {
                        safe => 0, # rcs plugin
                        rebuild => undef,
+                       section => "rcs",
                },
                cvsrepo => {
                        type => "string",
                },
                cvsrepo => {
                        type => "string",
@@ -104,7 +105,7 @@ sub getsetup () {
                cvs_wrapper => {
                        type => "string",
                        example => "/cvs/wikirepo/CVSROOT/post-commit",
                cvs_wrapper => {
                        type => "string",
                        example => "/cvs/wikirepo/CVSROOT/post-commit",
-                       description => "cvs post-commit hook to generate (triggered by CVSROOT/loginfo entry",
+                       description => "cvs post-commit hook to generate (triggered by CVSROOT/loginfo entry)",
                        safe => 0, # file
                        rebuild => 0,
                },
                        safe => 0, # file
                        rebuild => 0,
                },
@@ -264,11 +265,13 @@ sub rcs_add ($) {
                        if (defined($filemime) && $filemime eq 'text/plain') {
                                cvs_runcvs('add', $file) ||
                                        warn("cvs add $file failed\n");
                        if (defined($filemime) && $filemime eq 'text/plain') {
                                cvs_runcvs('add', $file) ||
                                        warn("cvs add $file failed\n");
-                       } else {
+                       }
+                       else {
                                cvs_runcvs('add', '-kb', $file) ||
                                        warn("cvs add binary $file failed\n");
                        }
                                cvs_runcvs('add', '-kb', $file) ||
                                        warn("cvs add binary $file failed\n");
                        }
-               } else {
+               }
+               else {
                        # directory
                        cvs_runcvs('add', $file) ||
                                warn("cvs add $file failed\n");
                        # directory
                        cvs_runcvs('add', $file) ||
                                warn("cvs add $file failed\n");
@@ -321,11 +324,12 @@ sub rcs_recentchanges($) {
        eval q{use File::ReadBackwards};
        error($@) if $@;
 
        eval q{use File::ReadBackwards};
        error($@) if $@;
 
-       my (undef, $tmpfile) = tempfile(OPEN=>0);
+       my ($tmphandle, $tmpfile) = tempfile();
        system("env TZ=UTC cvsps -q --cvs-direct -z 30 -x >$tmpfile");
        if ($? == -1) {
                error "couldn't run cvsps: $!\n";
        system("env TZ=UTC cvsps -q --cvs-direct -z 30 -x >$tmpfile");
        if ($? == -1) {
                error "couldn't run cvsps: $!\n";
-       } elsif (($? >> 8) != 0) {
+       }
+       elsif (($? >> 8) != 0) {
                error "cvsps exited " . ($? >> 8) . ": $!\n";
        }
 
                error "cvsps exited " . ($? >> 8) . ": $!\n";
        }
 
@@ -382,7 +386,8 @@ sub rcs_recentchanges($) {
                    $message[0]->{line}=~/$config{web_commit_regexp}/) {
                        $user=defined $2 ? "$2" : "$3";
                        $message[0]->{line}=$4;
                    $message[0]->{line}=~/$config{web_commit_regexp}/) {
                        $user=defined $2 ? "$2" : "$3";
                        $message[0]->{line}=$4;
-               } else {
+               }
+               else {
                        $committype="cvs";
                }
 
                        $committype="cvs";
                }
 
@@ -392,21 +397,24 @@ sub rcs_recentchanges($) {
                $line = <SPSVC>;
                if ($line =~ /^Author: (.*)$/) {
                        $user = $1 unless defined $user && length $user;
                $line = <SPSVC>;
                if ($line =~ /^Author: (.*)$/) {
                        $user = $1 unless defined $user && length $user;
-               } else {
+               }
+               else {
                        error "expected Author, got $line";
                }
 
                $line = <SPSVC>;
                if ($line =~ /^Date: (.*)$/) {
                        $when = str2time($1, 'UTC');
                        error "expected Author, got $line";
                }
 
                $line = <SPSVC>;
                if ($line =~ /^Date: (.*)$/) {
                        $when = str2time($1, 'UTC');
-               } else {
+               }
+               else {
                        error "expected Date, got $line";
                }
 
                $line = <SPSVC>;
                if ($line =~ /^PatchSet (.*)$/) {
                        $rev = $1;
                        error "expected Date, got $line";
                }
 
                $line = <SPSVC>;
                if ($line =~ /^PatchSet (.*)$/) {
                        $rev = $1;
-               } else {
+               }
+               else {
                        error "expected PatchSet, got $line";
                }
 
                        error "expected PatchSet, got $line";
                }
 
@@ -444,7 +452,8 @@ sub rcs_diff ($) {
 
        if (wantarray) {
                return @cvsps;
 
        if (wantarray) {
                return @cvsps;
-       } else {
+       }
+       else {
                return join("", @cvsps);
        }
 }
                return join("", @cvsps);
        }
 }
@@ -477,4 +486,8 @@ sub rcs_getctime ($) {
        return $date;
 }
 
        return $date;
 }
 
+sub rcs_getmtime ($) {
+       error "rcs_getmtime is not implemented for cvs\n"; # TODO
+}
+
 1
 1