X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/0b57bfe5b9ac2d1981f27ba1911aaff4b01f9061..17c2bfa9499e7d8306adc5a59ad8532dc42ff53f:/doc/patchqueue/darcs.mdwn?ds=sidebyside diff --git a/doc/patchqueue/darcs.mdwn b/doc/patchqueue/darcs.mdwn index c7ac34b18..13bd82513 100644 --- a/doc/patchqueue/darcs.mdwn +++ b/doc/patchqueue/darcs.mdwn @@ -206,8 +206,8 @@ This is my ([bma](bma@bmalee.eu)) darcs.pm - it's messy (my Perl isn't up to muc `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"]] -[[toggleable text=""" +[[toggle text="show" id="bma"]] +[[toggleable id="bma" text=""" #!/usr/bin/perl @@ -328,4 +328,137 @@ This is my ([bma](bma@bmalee.eu)) darcs.pm - it's messy (my Perl isn't up to muc -"""]] \ No newline at end of file +"""]] + +--- + +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 +