(.*?)<\/comment>/gm) {
- push @message, {line => $1};
- }
-
- my @pages;
- foreach my $match ($change =~ m/<.*?_(file|directory)>(.*?)(<(added|removed)_lines.*\/>)*<\/.*?_(file|directory)>/g) {
- # My perl-fu is weak. I'm probably going about this all wrong, anyway.
- push @pages, {page => pagename($match)} if ( -f $config{srcdir}."/".$match || -d $config{srcdir}."/".$match) and not $match =~ m/^$/;
- }
- push @ret, { rev => $rev,
- user => $user,
- committype => $committype,
- when => $when,
- message => [@message],
- pages => [@pages],
- }
- }
- return @ret;
- } #}}}
-
- sub rcs_notify () { #{{{
- # TODO
- } #}}}
-
- sub rcs_getctime ($) { #{{{
- error gettext("getctime not implemented");
- } #}}}
-
- 1
-
-
-
-"""]]
-
----
-
-Well, here's my version too. It only does getctime -- using a real XML parser, instead of regexp ugliness -- and maybe recentchanges, but that may be bitrotted, or maybe I never finished it, as I only need the getctime. As for actual commits, I have previously voiced my opinion, that this should be done by the plugin generating a patch bundle, and forwarding it to darcs in some way (`darcs apply` or even email to another host, possibly moderated), instead of the hacky direct modification of a working copy. It could also be faster to getctime in a batch. Just reading in all the changes the first time they're needed, might not be a big improvement in many cases, but if we got a batch request from ikiwiki, we could keep reaing the changes until all the files in this batch request have been met. --[[tuomov]]
-
-[[toggle text="show" id="tuomov"]]
-[[toggleable id="tuomov" text="""
-
-#!/usr/bin/perl
-# Stubs for no revision control.
-
-use warnings;
-use strict;
-use IkiWiki;
-
-package IkiWiki;
-
-sub rcs_update () {
-}
-
-sub rcs_prepedit ($) {
- return ""
-}
-
-sub rcs_commit ($$$) {
- return undef # success
-}
-
-sub rcs_add ($) {
-}
-
-sub rcs_recentchanges ($) {
- my $num=shift;
- my @ret;
-
- eval q{use Date::Parse};
- eval q{use XML::Simple};
-
- my $repodir=$config{srcdir};
-
- if (-d "$config{srcdir}/_darcs") {
- my $child = open(LOG, "-|");
- if (! $child) {
- exec("darcs", "changes", "--xml",
- "--repodir", "$repodir",
- "--last", "$num")
- || error("darcs changes failed to run");
- }
- my $data=;
- close LOG;
-
- my $log = XMLin($data, ForceArray => 1);
-
- foreach my $patch ($log->{patch}) {
- my $date=$patch->{local_date};
- my $hash=$patch->{hash};
- my $when=concise(ago(time - str2time($date)));
- my @pages;
-
- my $child = open(SUMMARY, "-|");
- if (! $child) {
- exec("darcs", "annotate", "-s", "--xml",
- "--match", "hash: $hash",
- "--repodir", "$repodir")
- || error("darcs annotate failed to run");
- }
- my $data=;
- close SUMMARY;
-
- my $summary = XMLin("$data", ForceArray => 1);
-
- # TODO: find @pages
-
- push @ret, {
- #rev => $rev,
- user => $patch->{author},
- #committype => $committype,
- when => $when,
- #message => [@message],
- pages => [@pages],
- }; # if @pages;
- return @ret if @ret >= $num;
- }
- }
-
- return @ret;
-}
-
-sub rcs_notify () {
-}
-
-sub rcs_getctime ($) {
- my $file=shift;
-
- eval q{use Date::Parse};
- eval q{use XML::Simple};
- local $/=undef;
-
- # Sigh... doing things the hard way again
- my $repodir=$config{srcdir};
-
- my $filer=substr($file, length($repodir));
- $filer =~ s:^[/]+::;
-
- my $child = open(LOG, "-|");
- if (! $child) {
- exec("darcs", "changes", "--xml", "--reverse",
- "--repodir", "$repodir", "$filer")
- || error("darcs changes $filer failed to run");
- }
-
- my $data=;
- close LOG;
-
- my $log = XMLin($data, ForceArray => 1);
-
- my $datestr=$log->{patch}[0]->{local_date};
-
- if (! defined $datestr) {
- warn "failed to get ctime for $filer";
- return 0;
- }
-
- my $date=str2time($datestr);
-
- debug("found ctime ".localtime($date)." for $file");
-
- return $date;
-}
-
-1
-
-"""]]
-
----
-
-I merged the two versions above and made some fixes; it is recording my web edits in darcs and showing a recent changes page.
-It is in a [darcs repository](http://joyful.com/darcsweb/darcsweb.cgi?r=ikiwiki-darcs), please send patches. --[[Simon_Michael]]
-
-
-[[tag patch]]
+ (now a darcs repo)
+
+I've taken all the good stuff from the above (now deleted --[[Joey]]) and added the missing hooks. The code hasn't seen a lot of testing, so some bugs are likely yet to surface. Also, I'm not experienced with perl and don't know where I should have used the function `possibly_foolish_untaint`.
+
+> Review of this one:
+>
+> * Should use tab indentation. (fixed)
+> * `rcs_getctime` should not need to use a ctime cache (such a cache should
+> also not be named `.ikiwiki.ctimes`). `rcs_getctime` is run exactly
+> once per page, ever, and the data is cached in ikiwiki's index. (fixed)
+> * I doubt that ENV{DARCS} will be available, since the wrapper clobbers> the entire
+> environment. I'd say remove that. (fixed)
+> * I don't understand what `darcs_info` is doing, but it seems to be
+> parsing xml with a regexp?
+> * Looks like `rcs_commit` needs a few improvements, as marked TODO
+> * `rcs_remove` just calls unlink? Does darcs record notice the file was removed
+> and automatically commit the removal?
+> * Is the the darcs info in [[rcs/details]] still up-to-date re this version? (fixed)
+> --[[Joey]]
+
+> Update:
+>
+> I think I've addressed all of the above except for the XML parsing in `darcs_info`.
+> The function determines the md5 hash of the last patch the given file appears in.
+> That's indeed being done with regexps but my Perl isn't good enough for a quick recode
+> right now.
+>
+> As for the darcs info in [[rcs/details]], it does not accurately describe the way
+> this version works. It's similar, but the details differ slightly.
+> You could copy my description above to replace it.
+>
+>> done --[[Joey]]
+>
+> There is still some ironing to do, for instance the current version doesn't allow for
+> modifying attachments by re-uploading them via CGI ("darcs add failed"). Am I assuming
+> correctly that "adding" a file that's already in the repo should just be a no-op?
+> --pesco
+
+>> It should result in the new file contents being committed by
+>> `rcs_commit_staged`. For some revision control systems, which
+>> automatically commit modifications, it would be a no-op. --[[Joey]]
+
+>>> Done. --pesco
+
+----
+
+I've finally merged this into ikiwiki master. The plugin looks quite
+complete, with only the new `rcs_receive` hook missing, and I
+hope it works as good as it looks. :) If anyone wants to work on improving
+it, there are some TODOs as mentioned above that could still be improved.
+--[[Joey]]
+
+[[!tag patch done]]