X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/e0e65bc026c39fcfaf46bdfedec89985ff1e8587..0416a79dfe63d1484fc08c29847f639e1970216c:/doc/patchqueue/darcs.mdwn diff --git a/doc/patchqueue/darcs.mdwn b/doc/patchqueue/darcs.mdwn index 4f4337c38..41d209fbd 100644 --- a/doc/patchqueue/darcs.mdwn +++ b/doc/patchqueue/darcs.mdwn @@ -1,6 +1,6 @@ Here's Thomas Schwinge unfinished darcs support for ikiwiki. -(Finishing this has been succested as a [[soc]] project.) +(Finishing this has been suggested as a [[soc]] project.) > I haven't been working on this for months and also won't in the near > future. Feel free to use what I have done so @@ -9,6 +9,8 @@ Here's Thomas Schwinge unfinished darcs support for ikiwiki. -- [Thomas Schwinge](mailto:tschwinge@gnu.org) +[[toggle text="show"]] +[[toggleable text=""" # Support for the darcs rcs, . # Copyright (C) 2006 Thomas Schwinge # @@ -198,3 +200,132 @@ Here's Thomas Schwinge unfinished darcs support for ikiwiki. } 1 +"""]] + +This is my ([bma](bma@bmalee.eu)) darcs.pm - it's messy (my Perl isn't up to much) but seems to work. It uses just one repo, like the mercurial plugin (unlike the above version, which AIUI uses two). + +`rcs_commit()` uses backticks instead of `system()`, to prevent darcs' output being sent to the browser and mucking with the HTTP headers (`darcs record` has no --quiet option). And `rcs_recentchanges()` uses regexes rather than parsing darcs' XML output. + +[[toggle text="show" id="bma"]] +[[toggleable id="bma" text=""" + + #!/usr/bin/perl + + use warnings; + use strict; + use IkiWiki; + use Date::Parse; + use open qw{:utf8 :std}; + + package IkiWiki; + + sub rcs_update () { #{{{ + # Do nothing - there's nowhere to update *from*. + } #}}} + + sub rcs_prepedit ($) { #{{{ + } #}}} + + sub rcs_commit ($$$;$$) { #{{{ + my ($file, $message, $rcstoken, $user, $ipaddr) = @_; + + # $user should probably be a name and an email address, by darcs + # convention. + if (defined $user) { + $user = possibly_foolish_untaint($user); + } + elsif (defined $ipaddr) { + $user = "Anonymous from $ipaddr"; + } + else { + $user = "Anonymous"; + } + + $message = possibly_foolish_untaint($message); + + # BUG: this outputs one line of text, and there's not a -q or --quiet + # option. Redirecting output to /dev/null works, but I still get the + # HTTP status and location headers displayed in the browser - is that + # darcs' fault or ikiwiki's? + # Doing it in backticks *works*, but I'm sure it could be done better. + my @cmdline = ("darcs", "record", "--repodir", "$config{srcdir}", + "-a", "-m", "$message", "--author", "$user", $file); + `darcs record --repodir "$config{srcdir}" -a -m "$message" --author "$user" $file`; # Return value? Output? Who needs 'em? + #if (system(@cmdline) != 0) { + # warn "'@cmdline' failed: $!"; + #} + + return undef; # success + + sub rcs_add ($) { # {{{ + my ($file) = @_; + + my @cmdline = ("darcs", "add", "--repodir", "$config{srcdir}", "-a", "-q", "$file"); + if (system(@cmdline) != 0) { + warn "'@cmdline' failed: $!"; + } + } #}}} + + sub rcs_recentchanges ($) { #{{{ + # TODO: This is horrible code. It doesn't work perfectly, and uses regexes + # rather than parsing Darcs' XML output. + my $num=shift; + my @ret; + + return unless -d "$config{srcdir}/_darcs"; + + my $changelog = `darcs changes --xml --summary --repodir "$config{srcdir}"`; + $changelog = join("", split(/\s*\n\s*/, $changelog)); + my @changes = split(/<\/patch>.*?(.*?)<\/name>/g; + my @message = {line => $1}; + foreach my $match ($change =~ m/(.*?)<\/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 + + + +"""]] \ No newline at end of file