]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/cvs.pm
Provide a UUID in edittemplate templates.
[ikiwiki.git] / IkiWiki / Plugin / cvs.pm
index 42812ddefe77ae8888c0040d99d0b0ef82ed774b..841aec914f7208df52036379319f4bdfda7ddc01 100644 (file)
@@ -33,6 +33,7 @@ use warnings;
 use strict;
 use IkiWiki;
 
 use strict;
 use IkiWiki;
 
+use URI::Escape q{uri_escape_utf8};
 use File::chdir;
 
 
 use File::chdir;
 
 
@@ -313,7 +314,10 @@ sub rcs_recentchanges ($) {
                        $oldrev =~ s/INITIAL/0/;
                        $newrev =~ s/\(DEAD\)//;
                        my $diffurl = defined $config{diffurl} ? $config{diffurl} : "";
                        $oldrev =~ s/INITIAL/0/;
                        $newrev =~ s/\(DEAD\)//;
                        my $diffurl = defined $config{diffurl} ? $config{diffurl} : "";
-                       $diffurl=~s/\[\[file\]\]/$page/g;
+                       my $epage = join('/',
+                               map { uri_escape_utf8($_) } split('/', $page)
+                       );
+                       $diffurl=~s/\[\[file\]\]/$epage/g;
                        $diffurl=~s/\[\[r1\]\]/$oldrev/g;
                        $diffurl=~s/\[\[r2\]\]/$newrev/g;
                        unshift @pages, {
                        $diffurl=~s/\[\[r1\]\]/$oldrev/g;
                        $diffurl=~s/\[\[r2\]\]/$newrev/g;
                        unshift @pages, {
@@ -500,7 +504,16 @@ sub cvs_runcvs(@) {
        my @cmd = @_;
        unshift @cmd, 'cvs', '-Q';
 
        my @cmd = @_;
        unshift @cmd, 'cvs', '-Q';
 
-       local $CWD = $config{srcdir};
+       # CVS can't operate outside a srcdir, so we're always setting $CWD.
+       # "local $CWD" restores the previous value when we go out of scope.
+       # Usually that's correct. But if we're removing the last file from
+       # a directory, the post-commit hook will exec in a working directory
+       # that's about to not exist (CVS will prune it).
+       #
+       # chdir() manually here, so we can selectively not chdir() back.
+
+       my $oldcwd = $CWD;
+       chdir($config{srcdir});
 
        eval q{
                use IPC::Open3;
 
        eval q{
                use IPC::Open3;
@@ -528,6 +541,8 @@ sub cvs_runcvs(@) {
        print STDOUT $cvsout;
        print STDERR $cvserr;
 
        print STDOUT $cvsout;
        print STDERR $cvserr;
 
+       chdir($oldcwd) if -d $oldcwd;
+
        return ($ret == 0) ? 1 : 0;
 }
 
        return ($ret == 0) ? 1 : 0;
 }