]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Rcs/svn.pm
web commit by JoshTriplett: Add shortcut for imdb.
[ikiwiki.git] / IkiWiki / Rcs / svn.pm
index fbf6b2c9ecc7be2556afe95cfa0ab11216731734..af4641d3af00b713ea428dde0b1371c70e2a5b47 100644 (file)
@@ -60,13 +60,22 @@ sub rcs_prepedit ($) { #{{{
        }
 } #}}}
 
-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.
        my $file=shift;
        my $message=shift;
        my $rcstoken=shift;
+       my $user=shift;
+       my $ipaddr=shift;
+
+       if (defined $user) {
+               $message="web commit by $user".(length $message ? ": $message" : "");
+       }
+       elsif (defined $ipaddr) {
+               $message="web commit from $ipaddr".(length $message ? ": $message" : "");
+       }
 
        if (-d "$config{srcdir}/.svn") {
                # Check to see if the page has been changed by someone
@@ -76,9 +85,8 @@ sub rcs_commit ($$$) { #{{{
                if (defined $rev && defined $oldrev && $rev != $oldrev) {
                        # Merge their changes into the file that we've
                        # changed.
-                       chdir($config{srcdir}); # svn merge wants to be here
                        if (system("svn", "merge", "--quiet", "-r$oldrev:$rev",
-                                  "$config{srcdir}/$file") != 0) {
+                                  "$config{srcdir}/$file", "$config{srcdir}/$file") != 0) {
                                warn("svn merge -r$oldrev:$rev failed\n");
                        }
                }
@@ -86,7 +94,7 @@ sub rcs_commit ($$$) { #{{{
                if (system("svn", "commit", "--quiet", 
                           "--encoding", "UTF-8", "-m",
                           possibly_foolish_untaint($message),
-                          "$config{srcdir}") != 0) {
+                          $config{srcdir}) != 0) {
                        my $conflict=readfile("$config{srcdir}/$file");
                        if (system("svn", "revert", "--quiet", "$config{srcdir}/$file") != 0) {
                                warn("svn revert failed\n");
@@ -122,7 +130,6 @@ sub rcs_recentchanges ($) { #{{{
 
        eval q{
                use Date::Parse;
-               use Time::Duration;
                use XML::SAX;
                use XML::Simple;
        };
@@ -195,7 +202,7 @@ sub rcs_recentchanges ($) { #{{{
 
 sub rcs_notify () { #{{{
        if (! exists $ENV{REV}) {
-               error("REV is not set, not running from svn post-commit hook, cannot send notifications");
+               error(gettext("REV is not set, not running from svn post-commit hook, cannot send notifications"));
        }
        my $rev=int(possibly_foolish_untaint($ENV{REV}));