API: rcs_commit and rcs_commit_staged are passed a new parameter
[ikiwiki.git] / IkiWiki / Plugin / cvs.pm
index dad28881d985f6c7a8fb8d103598663e27932110..a9fe162a1b7957e4f10e16163bea303b36936b7c 100644 (file)
@@ -1,6 +1,34 @@
-#!/usr/pkg/bin/perl
+#!/usr/bin/perl
 package IkiWiki::Plugin::cvs;
 
+# Copyright (c) 2009 Amitai Schlair
+# All rights reserved.
+#
+# This code is derived from software contributed to ikiwiki
+# by Amitai Schlair.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY IKIWIKI AND CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
+# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
 use warnings;
 use strict;
 use IkiWiki;
@@ -21,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_getmtime", call => \&rcs_getmtime);
 }
 
 sub genwrapper () {
-       my $check_args=<<"EOF";
+       return <<EOF;
        {
                int j;
                for (j = 1; j < argc; j++)
@@ -32,7 +61,6 @@ sub genwrapper () {
                                exit(0);
        }
 EOF
-       return $check_args;
 }
 
 sub checkconfig () {
@@ -58,6 +86,7 @@ sub getsetup () {
                plugin => {
                        safe => 0, # rcs plugin
                        rebuild => undef,
+                       section => "rcs",
                },
                cvsrepo => {
                        type => "string",
@@ -154,7 +183,7 @@ sub rcs_prepedit ($) {
        return defined $rev ? $rev : "";
 }
 
-sub rcs_commit ($$$;$$) {
+sub rcs_commit ($$$;$$$) {
        # Tries to commit the page; returns undef on _success_ and
        # a version of the page with the rcs's conflict markers on failure.
        # The file is relative to the srcdir.
@@ -163,6 +192,7 @@ sub rcs_commit ($$$;$$) {
        my $rcstoken=shift;
        my $user=shift;
        my $ipaddr=shift;
+       my $emailuser=shift;
 
        return unless cvs_is_controlling;
 
@@ -195,10 +225,10 @@ sub rcs_commit ($$$;$$) {
        return undef # success
 }
 
-sub rcs_commit_staged ($$$) {
+sub rcs_commit_staged ($$$;$) {
        # Commits all staged changes. Changes can be staged using rcs_add,
        # rcs_remove, and rcs_rename.
-       my ($message, $user, $ipaddr)=@_;
+       my ($message, $user, $ipaddr, $emailuser)=@_;
 
        if (defined $user) {
                $message="web commit by $user".(length $message ? ": $message" : "");
@@ -276,7 +306,7 @@ sub rcs_rename ($$) {
        rcs_remove($src);
 }
 
-sub rcs_recentchanges($) {
+sub rcs_recentchanges ($) {
        my $num = shift;
        my @ret;
 
@@ -295,11 +325,12 @@ sub rcs_recentchanges($) {
        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";
-       } elsif (($? >> 8) != 0) {
+       }
+       elsif (($? >> 8) != 0) {
                error "cvsps exited " . ($? >> 8) . ": $!\n";
        }
 
@@ -456,4 +487,8 @@ sub rcs_getctime ($) {
        return $date;
 }
 
+sub rcs_getmtime ($) {
+       error "rcs_getmtime is not implemented for cvs\n"; # TODO
+}
+
 1