- my ($mtime, $file, $rendered, @links)=split(' ', $_);
- my $page=pagename($file);
- $pagesources{$page}=$file;
- $oldpagemtime{$page}=$mtime;
- $oldlinks{$page}=[@links];
- $links{$page}=[@links];
- $renderedfiles{$page}=$rendered;
- }
- close IN;
-} #}}}
-
-sub saveindex () { #{{{
- if (! -d "$config{srcdir}/.ikiwiki") {
- mkdir("$config{srcdir}/.ikiwiki");
- }
- open (OUT, ">$config{srcdir}/.ikiwiki/index") || error("cannot write to index: $!");
- foreach my $page (keys %oldpagemtime) {
- print OUT "$oldpagemtime{$page} $pagesources{$page} $renderedfiles{$page} ".
- join(" ", @{$links{$page}})."\n"
- if $oldpagemtime{$page};
- }
- close OUT;
-} #}}}
-
-sub rcs_update () { #{{{
- if (-d "$config{srcdir}/.svn") {
- if (system("svn", "update", "--quiet", $config{srcdir}) != 0) {
- warn("svn update failed\n");
- }
- }
-} #}}}
-
-sub rcs_prepedit ($) { #{{{
- # Prepares to edit a file under revision control. Returns a token
- # that must be passed into rcs_commit when the file is ready
- # for committing.
- # The file is relative to the srcdir.
- my $file=shift;
-
- if (-d "$config{srcdir}/.svn") {
- # For subversion, return the revision of the file when
- # editing begins.
- my $rev=svn_info("Revision", "$config{srcdir}/$file");
- return defined $rev ? $rev : "";
- }
-} #}}}
-
-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;
-
- if (-d "$config{srcdir}/.svn") {
- # Check to see if the page has been changed by someone
- # else since rcs_prepedit was called.
- my ($oldrev)=$rcstoken=~/^([0-9]+)$/; # untaint
- my $rev=svn_info("Revision", "$config{srcdir}/$file");
- if ($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) {
- warn("svn merge -r$oldrev:$rev failed\n");
- }
- }
-
- if (system("svn", "commit", "--quiet", "-m",
- possibly_foolish_untaint($message),
- "$config{srcdir}/$file") != 0) {
- my $conflict=readfile("$config{srcdir}/$file");
- if (system("svn", "revert", "--quiet", "$config{srcdir}/$file") != 0) {
- warn("svn revert failed\n");
- }
- return $conflict;
- }
- }
- return undef # success
-} #}}}
-
-sub rcs_add ($) { #{{{
- # filename is relative to the root of the srcdir
- my $file=shift;
-
- if (-d "$config{srcdir}/.svn") {
- my $parent=dirname($file);
- while (! -d "$config{srcdir}/$parent/.svn") {
- $file=$parent;
- $parent=dirname($file);
- }
-
- if (system("svn", "add", "--quiet", "$config{srcdir}/$file") != 0) {
- warn("svn add failed\n");