From 917f54a777d152ee5963acd81bf8a2800a0507b1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 1 Oct 2008 17:24:06 -0400 Subject: add pesco's darcs plugin --- IkiWiki/Plugin/darcs.pm | 509 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 509 insertions(+) create mode 100644 IkiWiki/Plugin/darcs.pm (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm new file mode 100644 index 000000000..0957ef0ef --- /dev/null +++ b/IkiWiki/Plugin/darcs.pm @@ -0,0 +1,509 @@ +# Support for the darcs rcs, . +# Copyright (C) 2006 Thomas Schwinge +# 2007 Benjamin A'Lee +# Tuomo Valkonen +# 2008 Simon Michael +# Petr Ročkai +# Sven M. Hallberg +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# History (see http://ikiwiki.info/todo/darcs/): +# +# * Thomas Schwinge wrote the original file, implementing only rcs_commit. +# * Benjamin A'Lee contributed an alternative implementation. +# * Tuomo Valkonen contributed rcs_getctime and stub rcs_recentchanges. +# * Simon Michael contributed multiple changes. +# * Petr Ročkai fixed rcs_recentchanges and added caching to rcs_getctime. +# * Sven M. Hallberg merged the above and added missing features. + + +# We're guaranteed to be the only instance of ikiwiki running at a given +# time. It is essential that only ikiwiki is working on a particular +# repository. That means one instance of ikiwiki and it also means that +# you must not 'darcs push' into this repository, as this might create +# race conditions, as I understand it. + + +package IkiWiki::Plugin::darcs; + +use warnings; +use strict; +use IkiWiki; + + +sub import { + hook(type => "checkconfig", id => "darcs", call => \&checkconfig); + hook(type => "getsetup", id => "darcs", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} + + +# Which darcs executable to use. +my $darcs = ($ENV{DARCS} or 'darcs'); + + +# Internal functions + +our %cache; + +sub loadcache () { + my $repodir=$config{srcdir}; + if (!defined %cache) { + my $f = "$repodir/.ikiwiki.ctimes"; + if (-s "$f") { + my $VAR1; + my $x = `cat "$f"`; + $x =~ /^(.*)$/sm; # untaint + eval "$1"; + %cache = %$VAR1; + } + } +} + +END { + my $repodir=$config{srcdir}; + if (defined %cache) { + debug("dumping ctime cache to $repodir/.ikiwiki.ctimes"); + open CACHE, ">$repodir/.ikiwiki.ctimes"; + print CACHE Dumper(\%cache); + close CACHE; + } +} + +sub silentsystem (@) { + open(SAVED_STDOUT, ">&STDOUT"); + open(STDOUT, ">/dev/null"); + my $ret = system @_; + open(STDOUT, ">&SAVED_STDOUT"); + return $ret; +} + +sub darcs_info ($$$) { + my $field = shift; + my $repodir = shift; + my $file = shift; # Relative to the repodir. + + my $child = open(DARCS_CHANGES, "-|"); + if (! $child) { + exec($darcs, 'changes', '--repodir', $repodir, '--xml-output', $file) or + error("failed to run 'darcs changes'"); + } + + # Brute force for now. :-/ + while () { + last if /^<\/created_as>$/; + } + ($_) = =~ /$field=\'([^\']+)/; + $field eq 'hash' and s/\.gz//; # Strip away the '.gz' from 'hash'es. + + close(DARCS_CHANGES) or error("'darcs changes' exited " . $?); + + return $_; +} + +sub darcs_rev($) { + my $file = shift; # Relative to the repodir. + my $repodir = $config{srcdir}; + + my $child = open(DARCS_MANIFEST, "-|"); + if (! $child) { + exec($darcs, 'query', 'manifest', '--repodir', $repodir) or + error("failed to run 'darcs query manifest'"); + } + my $found=0; + while () { + $found = 1, last if /^$file$/; + } + return "" if (! $found); + close(DARCS_MANIFEST) or error("'darcs query manifest' exited " . $?); + + my $hash = darcs_info('hash', $repodir, $file); + return defined $hash ? $hash : ""; +} + + +# Exported functions. + +sub checkconfig() { + if (defined $config{darcs_wrapper} && length $config{darcs_wrapper}) { + push @{$config{wrappers}}, { + wrapper => $config{darcs_wrapper}, + wrappermode => (defined $config{darcs_wrappermode} ? $config{darcs_wrappermode} : "06755"), + }; + } +} + +sub getsetup() { + return + plugin => { + safe => 0, # rcs plugin + rebuild => undef, + }, + darcs_wrapper => { + type => "string", + example => "/darcs/repo/_darcs/ikiwiki-wrapper", + description => "wrapper to generate (set as master repo apply hook)", + safe => 0, # file + rebuild => 0, + }, + darcs_wrappermode => { + type => "string", + example => '06755', + description => "mode for darcs_wrapper (can safely be made suid)", + safe => 0, + rebuild => 0, + }, + historyurl => { + type => "string", + example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filehistory;f=[[file]]", + description => "darcsweb url to show file history ([[file]] substituted)", + safe => 1, + rebuild => 1, + }, + diffurl => { + type => "string", + example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filediff;h=[[hash]];f=[[file]]", + description => "darcsweb url to show a diff ([[hash]] and [[file]] substituted)", + safe => 1, + rebuild => 1, + }, +} + +sub rcs_update () { + silentsystem($darcs, "pull", "--repodir", $config{srcdir}, "-qa") +} + +sub rcs_prepedit ($) { + # Prepares to edit a file under revision control. Returns a token that + # must be passed to rcs_commit() when the file is to be commited. For us, + # this token the hash value of the latest patch that modifies the file, + # i.e. something like its current revision. If the file is not yet added + # to the repository, we return TODO: the empty string. + + my $file = shift; # Relative to the repodir. + my $rev = darcs_rev($file); + return $rev; +} + +sub rcs_commit ($$$;$$) { + # Commit the page. Returns 'undef' on success and a version of the page + # with conflict markers on failure. + + my ($file, $message, $rcstoken, $user, $ipaddr) = @_; + + # Compute if the "revision" of $file changed. + my $changed = darcs_rev($file) ne $rcstoken; + + # Yes, the following is a bit convoluted. + if ($changed) { + # TODO. Invent a better, non-conflicting name. + rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or + error("failed to rename $file to $file.save: $!"); + + # Roll the repository back to $rcstoken. + + # TODO. Can we be sure that no changes are lost? I think that + # we can, if we make sure that the 'darcs push' below will always + # succeed. + + # We need to revert everything as 'darcs obliterate' might choke + # otherwise. + # TODO: 'yes | ...' needed? Doesn't seem so. + silentsystem($darcs, "revert", "--repodir", $config{srcdir}, "--all") and + error("'darcs revert' failed"); + # Remove all patches starting at $rcstoken. + my $child = open(DARCS_OBLITERATE, "|-"); + if (! $child) { + open(STDOUT, ">/dev/null"); + exec($darcs, "obliterate", "--repodir", $config{srcdir}, + "--match", "hash " . $rcstoken) and + error("'darcs obliterate' failed"); + } + while (print DARCS_OBLITERATE "y") { + ; + } + close(DARCS_OBLITERATE); + # Restore the $rcstoken one. + silentsystem($darcs, "pull", "--quiet", "--repodir", $config{srcdir}, + "--match", "hash " . $rcstoken, "--all") and + error("'darcs pull' failed"); + + # We're back at $rcstoken. Re-install the modified file. + rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or + error("failed to rename $file.save to $file: $!"); + } + + # Record the changes. + my $author; + if (defined $user) { + $author = "$user\@web"; + } elsif (defined $ipaddr) { + $author = "$ipaddr\@web"; + } else { + $author = "anon\@web"; + } + if (!defined $message || !length($message)) { + $message = "empty message"; + } + silentsystem($darcs, 'record', '--repodir', $config{srcdir}, '--all', + '-m', $message, '--author', $author, $file) and + error("'darcs record' failed"); + + # Update the repository by pulling from the default repository, which is + # master repository. + silentsystem($darcs, "pull", "--quiet", "--repodir", $config{srcdir}, + "--all") and error("'darcs pull' failed"); + + # If this updating yields any conflicts, we'll record them now to resolve + # them. If nothing is recorded, there are no conflicts. + $rcstoken = darcs_rev($file); + # TODO: Use only the first line here, i.e. only the patch name? + writefile("$file.log", $config{srcdir}, 'resolve conflicts: ' . $message); + silentsystem($darcs, 'record', '--repodir', $config{srcdir}, '--all', + '-m', 'resolve conflicts: ' . $message, '--author', $author, $file) and + error("'darcs record' failed"); + my $conflicts = darcs_rev($file) ne $rcstoken; + unlink("$config{srcdir}/$file.log") or + error("failed to remove '$file.log'"); + + # Push the changes to the main repository. + silentsystem($darcs, 'push', '--quiet', '--repodir', $config{srcdir}, '--all') + and error("'darcs push' failed"); + # TODO: darcs send? + + if ($conflicts) { + my $document = readfile("$config{srcdir}/$file"); + # Try to leave everything in a consistent state. + # TODO: 'yes | ...' needed? Doesn't seem so. + silentsystem($darcs, "revert", "--repodir", $config{srcdir}, "--all") and + warn("'darcs revert' failed"); + return $document; + } else { + return undef; + } +} + +sub rcs_commit_staged($$$) { + my ($message, $user, $ipaddr) = @_; + + my $author; + if (defined $user) { + $author = "$user\@web"; + } elsif (defined $ipaddr) { + $author = "$ipaddr\@web"; + } else { + $author = "anon\@web"; + } + if (!defined $message || !length($message)) { + $message = "empty message"; + } + + silentsystem($darcs, "record", "--repodir", $config{srcdir}, "-a", "-A", $author, + "-m", $message) and error("'darcs record' failed"); + + # Push the changes to the main repository. + silentsystem($darcs, 'push', '--quiet', '--repodir', $config{srcdir}, '--all') + and error("'darcs push' failed"); + # TODO: darcs send? + + return undef; +} + +sub rcs_add ($) { + my $file = shift; # Relative to the repodir. + + # Intermediate directories will be added automagically. + system($darcs, 'add', '--quiet', '--repodir', $config{srcdir}, + '--boring', $file) and error("'darcs add' failed"); +} + +sub rcs_remove ($) { + my $file = shift; # Relative to the repodir. + + system('rm', $config{srcdir}.'/'.$file) + and error("'rm' failed"); +} + +sub rcs_rename ($$) { + my $a = shift; # Relative to the repodir. + my $b = shift; # Relative to the repodir. + + system($darcs, 'mv', '--repodir', $config{srcdir}, $a, $b) + and error("'darcs mv' failed"); +} + +sub rcs_recentchanges ($) { + my $num=shift; + my @ret; + + eval q{use Date::Parse}; + eval q{use XML::Simple}; + + my $repodir=$config{srcdir}; + + debug("darcs recent changes: $num"); + + my $child = open(LOG, "-|"); + if (! $child) { + $ENV{"DARCS_DONT_ESCAPE_ANYTHING"}=1; + exec("darcs", "changes", "--xml", + "--summary", + "--repodir", "$repodir", + "--last", "$num") + || error("'darcs changes' failed to run"); + } + my $data; + $data .= $_ while(); + close LOG; + + my $log = XMLin($data, ForceArray => 1); + + debug("parsing recent changes..."); + foreach my $patch (@{$log->{patch}}) { + my $date=$patch->{local_date}; + my $hash=$patch->{hash}; + my $when=str2time($date); + my (@pages, @files, @pg); + push @pages, $_ for (@{$patch->{summary}->[0]->{modify_file}}); + push @pages, $_ for (@{$patch->{summary}->[0]->{add_file}}); + push @pages, $_ for (@{$patch->{summary}->[0]->{remove_file}}); + for (@pages) { + my $f = $_; + $f = $_->{content} if (ref $_); + $f =~ s,^\s+,,; $f =~ s,\s+$,,; # cut whitespace + + push @files, $f; + } + for (@{$patch->{summary}->[0]->{move}}) { + my $p = $_; + push @files, $p->{from}; + } + + for (@files) { + my $f = $_; + my $d = defined $config{'diffurl'} ? $config{'diffurl'} : ""; + $d =~ s/\[\[file\]\]/$f/go; + $d =~ s/\[\[hash\]\]/$hash/go; + + debug("file: $f"); + debug("diffurl: $d"); + push @pg, { + page => pagename($f), + diffurl => $d, + }; + } + next unless (scalar @pg > 0); + debug("recent change: " . $patch->{name}[0] . " (" + . scalar @pg . " changes)"); + + my @message; + push @message, { line => $_ } for (@{$patch->{name}}); + + my $committype; + if ($patch->{author} =~ /\@web$/) { + $committype = "web"; + } else { + $committype = "darcs"; + } + + push @ret, { + rev => $patch->{hash}, + user => $patch->{author}, + committype => $committype, + when => $when, + message => [@message], + pages => [@pg], + }; + } + + return @ret; +} + +sub rcs_diff ($) { + my $rev=shift; + my @lines; + foreach my $line (silentsystem("darcs", "diff", "--match", "hash ".$rev)) { + if (@lines || $line=~/^diff/) { + push @lines, $line."\n"; + } + } + if (wantarray) { + return @lines; + } + else { + return join("", @lines); + } +} + +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}; + + &loadcache; + + my $filer=substr($file, length($repodir)); + $filer =~ s:^[/]+::; + + if (defined $cache{$filer}) { + #debug("taking cached ctime ".localtime($cache{$filer})." for $filer"); + return $cache{$filer}; + } + + my $child = open(LOG, "-|"); + if (! $child) { + exec("darcs", "changes", "--xml", "--reverse", + "--repodir", "$repodir", "$filer") + || error("'darcs changes $filer' failed to run"); + } + + my $data; + $data .= $_ while(); + 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"; + $cache{$filer} = 0; + return 0; + } + + my $date=str2time($datestr); + + #debug("found ctime ".localtime($date)." for $filer"); + + $cache{$filer} = $date; + return $date; +} + +1 -- cgit v1.2.3 From 7eb512205fba0efad301521bbd641848b4890b1d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 15 Oct 2008 19:38:21 -0400 Subject: updated from pesco's darcs repo, current to Oct 11 version --- IkiWiki/Plugin/darcs.pm | 730 ++++++++++++++++++++++------------------------ doc/ikiwiki-makerepo.mdwn | 11 +- ikiwiki-makerepo | 40 ++- 3 files changed, 392 insertions(+), 389 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 0957ef0ef..27ea6b6dd 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -45,465 +45,427 @@ use IkiWiki; sub import { - hook(type => "checkconfig", id => "darcs", call => \&checkconfig); - hook(type => "getsetup", id => "darcs", call => \&getsetup); - hook(type => "rcs", id => "rcs_update", call => \&rcs_update); - hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); - hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); - hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); - hook(type => "rcs", id => "rcs_add", call => \&rcs_add); - hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); - hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); - hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); - hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); - hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); + hook(type => "checkconfig", id => "darcs", call => \&checkconfig); + hook(type => "getsetup", id => "darcs", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); } -# Which darcs executable to use. -my $darcs = ($ENV{DARCS} or 'darcs'); - - # Internal functions -our %cache; - -sub loadcache () { - my $repodir=$config{srcdir}; - if (!defined %cache) { - my $f = "$repodir/.ikiwiki.ctimes"; - if (-s "$f") { - my $VAR1; - my $x = `cat "$f"`; - $x =~ /^(.*)$/sm; # untaint - eval "$1"; - %cache = %$VAR1; - } - } -} - -END { - my $repodir=$config{srcdir}; - if (defined %cache) { - debug("dumping ctime cache to $repodir/.ikiwiki.ctimes"); - open CACHE, ">$repodir/.ikiwiki.ctimes"; - print CACHE Dumper(\%cache); - close CACHE; - } -} - sub silentsystem (@) { - open(SAVED_STDOUT, ">&STDOUT"); - open(STDOUT, ">/dev/null"); - my $ret = system @_; - open(STDOUT, ">&SAVED_STDOUT"); - return $ret; + open(SAVED_STDOUT, ">&STDOUT"); + open(STDOUT, ">/dev/null"); + my $ret = system @_; + open(STDOUT, ">&SAVED_STDOUT"); + return $ret; } sub darcs_info ($$$) { - my $field = shift; - my $repodir = shift; - my $file = shift; # Relative to the repodir. - - my $child = open(DARCS_CHANGES, "-|"); - if (! $child) { - exec($darcs, 'changes', '--repodir', $repodir, '--xml-output', $file) or - error("failed to run 'darcs changes'"); - } - - # Brute force for now. :-/ - while () { - last if /^<\/created_as>$/; - } - ($_) = =~ /$field=\'([^\']+)/; - $field eq 'hash' and s/\.gz//; # Strip away the '.gz' from 'hash'es. - - close(DARCS_CHANGES) or error("'darcs changes' exited " . $?); - - return $_; + my $field = shift; + my $repodir = shift; + my $file = shift; # Relative to the repodir. + + my $child = open(DARCS_CHANGES, "-|"); + if (! $child) { + exec('darcs', 'changes', '--repodir', $repodir, '--xml-output', $file) or + error("failed to run 'darcs changes'"); + } + + # Brute force for now. :-/ + while () { + last if /^<\/created_as>$/; + } + ($_) = =~ /$field=\'([^\']+)/; + $field eq 'hash' and s/\.gz//; # Strip away the '.gz' from 'hash'es. + + close(DARCS_CHANGES) or error("'darcs changes' exited " . $?); + + return $_; } sub darcs_rev($) { - my $file = shift; # Relative to the repodir. - my $repodir = $config{srcdir}; - - my $child = open(DARCS_MANIFEST, "-|"); - if (! $child) { - exec($darcs, 'query', 'manifest', '--repodir', $repodir) or - error("failed to run 'darcs query manifest'"); - } - my $found=0; - while () { - $found = 1, last if /^$file$/; - } - return "" if (! $found); - close(DARCS_MANIFEST) or error("'darcs query manifest' exited " . $?); - - my $hash = darcs_info('hash', $repodir, $file); - return defined $hash ? $hash : ""; + my $file = shift; # Relative to the repodir. + my $repodir = $config{srcdir}; + + my $child = open(DARCS_MANIFEST, "-|"); + if (! $child) { + exec('darcs', 'query', 'manifest', '--repodir', $repodir) or + error("failed to run 'darcs query manifest'"); + } + my $found=0; + while () { + $found = 1, last if /^$file$/; + } + return "" if (! $found); + close(DARCS_MANIFEST) or error("'darcs query manifest' exited " . $?); + + my $hash = darcs_info('hash', $repodir, $file); + return defined $hash ? $hash : ""; } # Exported functions. sub checkconfig() { - if (defined $config{darcs_wrapper} && length $config{darcs_wrapper}) { - push @{$config{wrappers}}, { - wrapper => $config{darcs_wrapper}, - wrappermode => (defined $config{darcs_wrappermode} ? $config{darcs_wrappermode} : "06755"), - }; - } + if (defined $config{darcs_wrapper} && length $config{darcs_wrapper}) { + push @{$config{wrappers}}, { + wrapper => $config{darcs_wrapper}, + wrappermode => (defined $config{darcs_wrappermode} ? $config{darcs_wrappermode} : "06755"), + }; + } } sub getsetup() { - return + return plugin => { - safe => 0, # rcs plugin - rebuild => undef, + safe => 0, # rcs plugin + rebuild => undef, }, darcs_wrapper => { - type => "string", - example => "/darcs/repo/_darcs/ikiwiki-wrapper", - description => "wrapper to generate (set as master repo apply hook)", - safe => 0, # file - rebuild => 0, + type => "string", + example => "/darcs/repo/_darcs/ikiwiki-wrapper", + description => "wrapper to generate (set as master repo apply hook)", + safe => 0, # file + rebuild => 0, }, darcs_wrappermode => { - type => "string", - example => '06755', - description => "mode for darcs_wrapper (can safely be made suid)", - safe => 0, - rebuild => 0, + type => "string", + example => '06755', + description => "mode for darcs_wrapper (can safely be made suid)", + safe => 0, + rebuild => 0, }, historyurl => { - type => "string", - example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filehistory;f=[[file]]", - description => "darcsweb url to show file history ([[file]] substituted)", - safe => 1, - rebuild => 1, + type => "string", + example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filehistory;f=[[file]]", + description => "darcsweb url to show file history ([[file]] substituted)", + safe => 1, + rebuild => 1, }, diffurl => { - type => "string", - example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filediff;h=[[hash]];f=[[file]]", - description => "darcsweb url to show a diff ([[hash]] and [[file]] substituted)", - safe => 1, - rebuild => 1, + type => "string", + example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filediff;h=[[hash]];f=[[file]]", + description => "darcsweb url to show a diff ([[hash]] and [[file]] substituted)", + safe => 1, + rebuild => 1, }, } sub rcs_update () { - silentsystem($darcs, "pull", "--repodir", $config{srcdir}, "-qa") + silentsystem('darcs', "pull", "--repodir", $config{srcdir}, "-qa") } sub rcs_prepedit ($) { - # Prepares to edit a file under revision control. Returns a token that - # must be passed to rcs_commit() when the file is to be commited. For us, - # this token the hash value of the latest patch that modifies the file, - # i.e. something like its current revision. If the file is not yet added - # to the repository, we return TODO: the empty string. - - my $file = shift; # Relative to the repodir. - my $rev = darcs_rev($file); - return $rev; + # Prepares to edit a file under revision control. Returns a token that + # must be passed to rcs_commit() when the file is to be commited. For us, + # this token the hash value of the latest patch that modifies the file, + # i.e. something like its current revision. If the file is not yet added + # to the repository, we return TODO: the empty string. + + my $file = shift; # Relative to the repodir. + my $rev = darcs_rev($file); + return $rev; } sub rcs_commit ($$$;$$) { - # Commit the page. Returns 'undef' on success and a version of the page - # with conflict markers on failure. - - my ($file, $message, $rcstoken, $user, $ipaddr) = @_; - - # Compute if the "revision" of $file changed. - my $changed = darcs_rev($file) ne $rcstoken; - - # Yes, the following is a bit convoluted. - if ($changed) { - # TODO. Invent a better, non-conflicting name. - rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or - error("failed to rename $file to $file.save: $!"); - - # Roll the repository back to $rcstoken. - - # TODO. Can we be sure that no changes are lost? I think that - # we can, if we make sure that the 'darcs push' below will always - # succeed. - - # We need to revert everything as 'darcs obliterate' might choke - # otherwise. - # TODO: 'yes | ...' needed? Doesn't seem so. - silentsystem($darcs, "revert", "--repodir", $config{srcdir}, "--all") and - error("'darcs revert' failed"); - # Remove all patches starting at $rcstoken. - my $child = open(DARCS_OBLITERATE, "|-"); - if (! $child) { - open(STDOUT, ">/dev/null"); - exec($darcs, "obliterate", "--repodir", $config{srcdir}, - "--match", "hash " . $rcstoken) and - error("'darcs obliterate' failed"); - } - while (print DARCS_OBLITERATE "y") { - ; - } - close(DARCS_OBLITERATE); - # Restore the $rcstoken one. - silentsystem($darcs, "pull", "--quiet", "--repodir", $config{srcdir}, - "--match", "hash " . $rcstoken, "--all") and - error("'darcs pull' failed"); - - # We're back at $rcstoken. Re-install the modified file. - rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or - error("failed to rename $file.save to $file: $!"); - } - - # Record the changes. - my $author; - if (defined $user) { - $author = "$user\@web"; - } elsif (defined $ipaddr) { - $author = "$ipaddr\@web"; - } else { - $author = "anon\@web"; - } - if (!defined $message || !length($message)) { - $message = "empty message"; - } - silentsystem($darcs, 'record', '--repodir', $config{srcdir}, '--all', - '-m', $message, '--author', $author, $file) and - error("'darcs record' failed"); - - # Update the repository by pulling from the default repository, which is - # master repository. - silentsystem($darcs, "pull", "--quiet", "--repodir", $config{srcdir}, - "--all") and error("'darcs pull' failed"); - - # If this updating yields any conflicts, we'll record them now to resolve - # them. If nothing is recorded, there are no conflicts. - $rcstoken = darcs_rev($file); - # TODO: Use only the first line here, i.e. only the patch name? - writefile("$file.log", $config{srcdir}, 'resolve conflicts: ' . $message); - silentsystem($darcs, 'record', '--repodir', $config{srcdir}, '--all', - '-m', 'resolve conflicts: ' . $message, '--author', $author, $file) and - error("'darcs record' failed"); - my $conflicts = darcs_rev($file) ne $rcstoken; - unlink("$config{srcdir}/$file.log") or - error("failed to remove '$file.log'"); - - # Push the changes to the main repository. - silentsystem($darcs, 'push', '--quiet', '--repodir', $config{srcdir}, '--all') - and error("'darcs push' failed"); - # TODO: darcs send? - - if ($conflicts) { - my $document = readfile("$config{srcdir}/$file"); - # Try to leave everything in a consistent state. - # TODO: 'yes | ...' needed? Doesn't seem so. - silentsystem($darcs, "revert", "--repodir", $config{srcdir}, "--all") and - warn("'darcs revert' failed"); - return $document; - } else { - return undef; - } + # Commit the page. Returns 'undef' on success and a version of the page + # with conflict markers on failure. + + my ($file, $message, $rcstoken, $user, $ipaddr) = @_; + + # Compute if the "revision" of $file changed. + my $changed = darcs_rev($file) ne $rcstoken; + + # Yes, the following is a bit convoluted. + if ($changed) { + # TODO. Invent a better, non-conflicting name. + rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or + error("failed to rename $file to $file.save: $!"); + + # Roll the repository back to $rcstoken. + + # TODO. Can we be sure that no changes are lost? I think that + # we can, if we make sure that the 'darcs push' below will always + # succeed. + + # We need to revert everything as 'darcs obliterate' might choke + # otherwise. + # TODO: 'yes | ...' needed? Doesn't seem so. + silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") and + error("'darcs revert' failed"); + # Remove all patches starting at $rcstoken. + my $child = open(DARCS_OBLITERATE, "|-"); + if (! $child) { + open(STDOUT, ">/dev/null"); + exec('darcs', "obliterate", "--repodir", $config{srcdir}, + "--match", "hash " . $rcstoken) and + error("'darcs obliterate' failed"); + } + while (print DARCS_OBLITERATE "y") { + ; + } + close(DARCS_OBLITERATE); + # Restore the $rcstoken one. + silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir}, + "--match", "hash " . $rcstoken, "--all") and + error("'darcs pull' failed"); + + # We're back at $rcstoken. Re-install the modified file. + rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or + error("failed to rename $file.save to $file: $!"); + } + + # Record the changes. + my $author; + if (defined $user) { + $author = "$user\@web"; + } elsif (defined $ipaddr) { + $author = "$ipaddr\@web"; + } else { + $author = "anon\@web"; + } + if (!defined $message || !length($message)) { + $message = "empty message"; + } + silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all', + '-m', $message, '--author', $author, $file) and + error("'darcs record' failed"); + + # Update the repository by pulling from the default repository, which is + # master repository. + silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir}, + "--all") and error("'darcs pull' failed"); + + # If this updating yields any conflicts, we'll record them now to resolve + # them. If nothing is recorded, there are no conflicts. + $rcstoken = darcs_rev($file); + # TODO: Use only the first line here, i.e. only the patch name? + writefile("$file.log", $config{srcdir}, 'resolve conflicts: ' . $message); + silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all', + '-m', 'resolve conflicts: ' . $message, '--author', $author, $file) and + error("'darcs record' failed"); + my $conflicts = darcs_rev($file) ne $rcstoken; + unlink("$config{srcdir}/$file.log") or + error("failed to remove '$file.log'"); + + # Push the changes to the main repository. + silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') + and error("'darcs push' failed"); + # TODO: darcs send? + + if ($conflicts) { + my $document = readfile("$config{srcdir}/$file"); + # Try to leave everything in a consistent state. + # TODO: 'yes | ...' needed? Doesn't seem so. + silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") and + warn("'darcs revert' failed"); + return $document; + } else { + return undef; + } } sub rcs_commit_staged($$$) { - my ($message, $user, $ipaddr) = @_; - - my $author; - if (defined $user) { - $author = "$user\@web"; - } elsif (defined $ipaddr) { - $author = "$ipaddr\@web"; - } else { - $author = "anon\@web"; - } - if (!defined $message || !length($message)) { - $message = "empty message"; - } - - silentsystem($darcs, "record", "--repodir", $config{srcdir}, "-a", "-A", $author, - "-m", $message) and error("'darcs record' failed"); - - # Push the changes to the main repository. - silentsystem($darcs, 'push', '--quiet', '--repodir', $config{srcdir}, '--all') - and error("'darcs push' failed"); - # TODO: darcs send? - - return undef; + my ($message, $user, $ipaddr) = @_; + + my $author; + if (defined $user) { + $author = "$user\@web"; + } elsif (defined $ipaddr) { + $author = "$ipaddr\@web"; + } else { + $author = "anon\@web"; + } + if (!defined $message || !length($message)) { + $message = "empty message"; + } + + silentsystem('darcs', "record", "--repodir", $config{srcdir}, "-a", "-A", $author, + "-m", $message) and error("'darcs record' failed"); + + # Push the changes to the main repository. + silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') + and error("'darcs push' failed"); + # TODO: darcs send? + + return undef; } sub rcs_add ($) { - my $file = shift; # Relative to the repodir. + my $file = shift; # Relative to the repodir. - # Intermediate directories will be added automagically. - system($darcs, 'add', '--quiet', '--repodir', $config{srcdir}, - '--boring', $file) and error("'darcs add' failed"); + # Intermediate directories will be added automagically. + system('darcs', 'add', '--quiet', '--repodir', $config{srcdir}, + '--boring', $file) and error("'darcs add' failed"); } sub rcs_remove ($) { - my $file = shift; # Relative to the repodir. + my $file = shift; # Relative to the repodir. - system('rm', $config{srcdir}.'/'.$file) - and error("'rm' failed"); + unlink($config{srcdir}.'/'.$file); } sub rcs_rename ($$) { - my $a = shift; # Relative to the repodir. - my $b = shift; # Relative to the repodir. + my $a = shift; # Relative to the repodir. + my $b = shift; # Relative to the repodir. - system($darcs, 'mv', '--repodir', $config{srcdir}, $a, $b) - and error("'darcs mv' failed"); + system('darcs', 'mv', '--repodir', $config{srcdir}, $a, $b) + and error("'darcs mv' failed"); } sub rcs_recentchanges ($) { - my $num=shift; - my @ret; - - eval q{use Date::Parse}; - eval q{use XML::Simple}; - - my $repodir=$config{srcdir}; - - debug("darcs recent changes: $num"); - - my $child = open(LOG, "-|"); - if (! $child) { - $ENV{"DARCS_DONT_ESCAPE_ANYTHING"}=1; - exec("darcs", "changes", "--xml", - "--summary", - "--repodir", "$repodir", - "--last", "$num") - || error("'darcs changes' failed to run"); - } - my $data; - $data .= $_ while(); - close LOG; - - my $log = XMLin($data, ForceArray => 1); - - debug("parsing recent changes..."); - foreach my $patch (@{$log->{patch}}) { - my $date=$patch->{local_date}; - my $hash=$patch->{hash}; - my $when=str2time($date); - my (@pages, @files, @pg); - push @pages, $_ for (@{$patch->{summary}->[0]->{modify_file}}); - push @pages, $_ for (@{$patch->{summary}->[0]->{add_file}}); - push @pages, $_ for (@{$patch->{summary}->[0]->{remove_file}}); - for (@pages) { - my $f = $_; - $f = $_->{content} if (ref $_); - $f =~ s,^\s+,,; $f =~ s,\s+$,,; # cut whitespace - - push @files, $f; - } - for (@{$patch->{summary}->[0]->{move}}) { - my $p = $_; - push @files, $p->{from}; - } - - for (@files) { - my $f = $_; - my $d = defined $config{'diffurl'} ? $config{'diffurl'} : ""; - $d =~ s/\[\[file\]\]/$f/go; - $d =~ s/\[\[hash\]\]/$hash/go; - - debug("file: $f"); - debug("diffurl: $d"); - push @pg, { - page => pagename($f), - diffurl => $d, - }; - } - next unless (scalar @pg > 0); - debug("recent change: " . $patch->{name}[0] . " (" - . scalar @pg . " changes)"); - - my @message; - push @message, { line => $_ } for (@{$patch->{name}}); - - my $committype; - if ($patch->{author} =~ /\@web$/) { - $committype = "web"; - } else { - $committype = "darcs"; - } - - push @ret, { - rev => $patch->{hash}, - user => $patch->{author}, - committype => $committype, - when => $when, - message => [@message], - pages => [@pg], - }; - } - - return @ret; + my $num=shift; + my @ret; + + eval q{use Date::Parse}; + eval q{use XML::Simple}; + + my $repodir=$config{srcdir}; + + debug("darcs recent changes: $num"); + + my $child = open(LOG, "-|"); + if (! $child) { + $ENV{"DARCS_DONT_ESCAPE_ANYTHING"}=1; + exec("darcs", "changes", "--xml", + "--summary", + "--repodir", "$repodir", + "--last", "$num") + || error("'darcs changes' failed to run"); + } + my $data; + $data .= $_ while(); + close LOG; + + my $log = XMLin($data, ForceArray => 1); + + debug("parsing recent changes..."); + foreach my $patch (@{$log->{patch}}) { + my $date=$patch->{local_date}; + my $hash=$patch->{hash}; + my $when=str2time($date); + my (@pages, @files, @pg); + push @pages, $_ for (@{$patch->{summary}->[0]->{modify_file}}); + push @pages, $_ for (@{$patch->{summary}->[0]->{add_file}}); + push @pages, $_ for (@{$patch->{summary}->[0]->{remove_file}}); + for (@pages) { + my $f = $_; + $f = $_->{content} if (ref $_); + $f =~ s,^\s+,,; $f =~ s,\s+$,,; # cut whitespace + + push @files, $f; + } + for (@{$patch->{summary}->[0]->{move}}) { + my $p = $_; + push @files, $p->{from}; + } + + for (@files) { + my $f = $_; + my $d = defined $config{'diffurl'} ? $config{'diffurl'} : ""; + $d =~ s/\[\[file\]\]/$f/go; + $d =~ s/\[\[hash\]\]/$hash/go; + + debug("file: $f"); + debug("diffurl: $d"); + push @pg, { + page => pagename($f), + diffurl => $d, + }; + } + next unless (scalar @pg > 0); + debug("recent change: " . $patch->{name}[0] . " (" + . scalar @pg . " changes)"); + + my @message; + push @message, { line => $_ } for (@{$patch->{name}}); + + my $committype; + if ($patch->{author} =~ /\@web$/) { + $committype = "web"; + } else { + $committype = "darcs"; + } + + push @ret, { + rev => $patch->{hash}, + user => $patch->{author}, + committype => $committype, + when => $when, + message => [@message], + pages => [@pg], + }; + } + + return @ret; } sub rcs_diff ($) { - my $rev=shift; - my @lines; - foreach my $line (silentsystem("darcs", "diff", "--match", "hash ".$rev)) { - if (@lines || $line=~/^diff/) { - push @lines, $line."\n"; - } - } - if (wantarray) { - return @lines; - } - else { - return join("", @lines); - } + my $rev=shift; + my @lines; + foreach my $line (silentsystem("darcs", "diff", "--match", "hash ".$rev)) { + if (@lines || $line=~/^diff/) { + push @lines, $line."\n"; + } + } + if (wantarray) { + return @lines; + } + else { + return join("", @lines); + } } sub rcs_getctime ($) { - my $file=shift; - - eval q{use Date::Parse}; - eval q{use XML::Simple}; - local $/=undef; + my $file=shift; - # Sigh... doing things the hard way again - my $repodir=$config{srcdir}; + eval q{use Date::Parse}; + eval q{use XML::Simple}; + local $/=undef; - &loadcache; + # Sigh... doing things the hard way again + my $repodir=$config{srcdir}; - my $filer=substr($file, length($repodir)); - $filer =~ s:^[/]+::; + my $filer=substr($file, length($repodir)); + $filer =~ s:^[/]+::; - if (defined $cache{$filer}) { - #debug("taking cached ctime ".localtime($cache{$filer})." for $filer"); - return $cache{$filer}; - } + my $child = open(LOG, "-|"); + if (! $child) { + exec("darcs", "changes", "--xml", "--reverse", + "--repodir", "$repodir", "$filer") + || error("'darcs changes $filer' failed to run"); + } - my $child = open(LOG, "-|"); - if (! $child) { - exec("darcs", "changes", "--xml", "--reverse", - "--repodir", "$repodir", "$filer") - || error("'darcs changes $filer' failed to run"); - } + my $data; + $data .= $_ while(); + close LOG; - my $data; - $data .= $_ while(); - close LOG; + my $log = XMLin($data, ForceArray => 1); - my $log = XMLin($data, ForceArray => 1); + my $datestr=$log->{patch}[0]->{local_date}; - my $datestr=$log->{patch}[0]->{local_date}; + if (! defined $datestr) { + warn "failed to get ctime for $filer"; + return 0; + } - if (! defined $datestr) { - warn "failed to get ctime for $filer"; - $cache{$filer} = 0; - return 0; - } + my $date=str2time($datestr); - my $date=str2time($datestr); + #debug("found ctime ".localtime($date)." for $filer"); - #debug("found ctime ".localtime($date)." for $filer"); - - $cache{$filer} = $date; - return $date; + return $date; } 1 + +# vim: ts=4 sw=4 noet diff --git a/doc/ikiwiki-makerepo.mdwn b/doc/ikiwiki-makerepo.mdwn index dcebbb96a..d5034b2c7 100644 --- a/doc/ikiwiki-makerepo.mdwn +++ b/doc/ikiwiki-makerepo.mdwn @@ -4,9 +4,9 @@ ikiwiki-makerepo - check an ikiwiki srcdir into revision control # SYNOPSIS -ikiwiki-makerepo svn|git|monotone srcdir repository +ikiwiki-makerepo svn|git|monotone|darcs srcdir repository -ikiwiki-makerepo mercurial srcdir +ikiwiki-makerepo mercurial|darcs srcdir # DESCRIPTION @@ -17,6 +17,13 @@ mercurial repository. Note that for mercurial, the srcdir is converted into a mercurial repository. There is no need to have a separate repository with mercurial. +For darcs, the second (one-argument) form turns the given srcdir into a +darcs master repository with the (new) srcdir inside. Adjust your ikiwiki.setup +according to the command output! Also, the master repo's apply hook will be +preconfigured to call a (hypothetical) ikiwiki wrapper. The command +reports the relevant file. Adjust it as needed or remove it if you don't use +the cgi script. + Note that for monotone, you are assumed to already have run "mtn genkey" to generate key. diff --git a/ikiwiki-makerepo b/ikiwiki-makerepo index c3d835c30..78eea8f53 100755 --- a/ikiwiki-makerepo +++ b/ikiwiki-makerepo @@ -6,8 +6,8 @@ srcdir="$2" repository="$3" usage () { - echo "usage: ikiwiki-makerepo svn|git|monotone srcdir repository" >&2 - echo " ikiwiki-makerepo bzr|mercurial srcdir" >&2 + echo "usage: ikiwiki-makerepo svn|git|monotone|darcs srcdir repository" >&2 + echo " ikiwiki-makerepo bzr|mercurial|darcs srcdir" >&2 exit 1 } @@ -20,7 +20,7 @@ if [ ! -d "$srcdir" ]; then exit 1 fi -if [ "$rcs" != mercurial ] && [ "$rcs" != bzr ]; then +if [ "$rcs" != mercurial ] && [ "$rcs" != bzr ] && [ "$rcs" != darcs ]; then if [ -z "$repository" ]; then echo "you need to specify both a srcdir and a repository for $rcs" >&2 usage @@ -121,6 +121,40 @@ monotone) echo ' return "passphrasehere"' echo "end" ;; +darcs) + if [ -e "$srcdir/_darcs" ]; then + echo "$srcdir already seems to be a darcs repository" >&2 + exit 1 + fi + + # if only one arg is given, we turn the given srcdir into the darcs + # master repo with a hidden srcdir inside its _darcs directory. + if [ -z "$repository" ]; then + echo "Turning $srcdir into master repo." + repository="$srcdir" + srcdir="$srcdir/_darcs/srcdir" + echo "The new srcdir is $srcdir - adjust ikiwiki.setup accordingly!" + fi + + mkdir -p "$repository" + cd "$repository" + darcs initialize + + mkdir -p "$srcdir" + cd "$srcdir" + darcs initialize + echo .ikiwiki >> _darcs/prefs/boring + darcs record -a -l -q -m "initial import" + darcs pull -a -q "$repository" + darcs push -a -q "$repository" + echo "Directory $srcdir is now a branch of darcs repo $repository" + + # set up master repo's apply hook and tell user to adjust it if desired + darcsdefaults="$repository/_darcs/prefs/defaults" + echo "Preconfiguring apply hook in $darcsdefaults - adjust as desired!" + echo "apply posthook $repository/_darcs/ikiwrapper" >> "$darcsdefaults" + echo "apply run-posthook" >> "$darcsdefaults" +;; *) echo "Unsupported revision control system $rcs" >&2 usage -- cgit v1.2.3 From 78a69e5bd632eb86ef8135e9c1d05d2c48b43362 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 16 Oct 2008 17:20:17 -0400 Subject: only darcs add files not yet in version control --- IkiWiki/Plugin/darcs.pm | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 27ea6b6dd..1facc1789 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -88,14 +88,14 @@ sub darcs_info ($$$) { ($_) = =~ /$field=\'([^\']+)/; $field eq 'hash' and s/\.gz//; # Strip away the '.gz' from 'hash'es. - close(DARCS_CHANGES) or error("'darcs changes' exited " . $?); + close(DARCS_CHANGES); return $_; } -sub darcs_rev($) { - my $file = shift; # Relative to the repodir. - my $repodir = $config{srcdir}; +sub file_in_vc($$) { + my $repodir = shift; + my $file = shift; my $child = open(DARCS_MANIFEST, "-|"); if (! $child) { @@ -104,11 +104,18 @@ sub darcs_rev($) { } my $found=0; while () { - $found = 1, last if /^$file$/; + $found = 1, last if /^(\.\/)?$file$/; } - return "" if (! $found); close(DARCS_MANIFEST) or error("'darcs query manifest' exited " . $?); + return $found; +} + +sub darcs_rev($) { + my $file = shift; # Relative to the repodir. + my $repodir = $config{srcdir}; + + return "" if (! file_in_vc($repodir, $file)); my $hash = darcs_info('hash', $repodir, $file); return defined $hash ? $hash : ""; } @@ -304,9 +311,11 @@ sub rcs_commit_staged($$$) { sub rcs_add ($) { my $file = shift; # Relative to the repodir. - # Intermediate directories will be added automagically. - system('darcs', 'add', '--quiet', '--repodir', $config{srcdir}, - '--boring', $file) and error("'darcs add' failed"); + if(! file_in_vc($config{srcdir}, $file)) { + # Intermediate directories will be added automagically. + system('darcs', 'add', '--quiet', '--repodir', $config{srcdir}, + '--boring', $file) and error("'darcs add' failed"); + } } sub rcs_remove ($) { -- cgit v1.2.3 From 72b9482835faabcef13a22c9c9af3314da5a71f3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 1 Apr 2009 19:18:43 -0400 Subject: recentchanges: change to using do=goto links. --- IkiWiki/Plugin/recentchanges.pm | 2 +- debian/changelog | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 329dd6f32..fa851e466 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -123,7 +123,7 @@ sub store ($$$) { } elsif (length $config{cgiurl}) { $change->{authorurl} = IkiWiki::cgiurl( - do => "recentchanges_link", + do => "goto", page => (length $config{userdir} ? "$config{userdir}/" : "").$change->{author}, ); } diff --git a/debian/changelog b/debian/changelog index a3ff97d30..25ed0dce9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,7 @@ ikiwiki (3.09) UNRELEASED; urgency=low * comments: Fix anchor ids to be legal xhtml. Closes: #521339 * Fix documentation of anonok_pagespec. Closes: #521793 * Add missing suggests on libtext-textile-perl. Closes: #522039 + * recentchanges: change to using do=goto links. -- Joey Hess Thu, 19 Mar 2009 15:32:49 -0400 -- cgit v1.2.3 From bbd61b346b9375b4fc6370593e15e7db075b122e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 17:45:13 -0400 Subject: formatting, layout, indentation, coding style --- IkiWiki/Plugin/darcs.pm | 222 +++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 114 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 1facc1789..978457b2c 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -1,3 +1,4 @@ +#!/usr/bin/perl # Support for the darcs rcs, . # Copyright (C) 2006 Thomas Schwinge # 2007 Benjamin A'Lee @@ -36,14 +37,12 @@ # you must not 'darcs push' into this repository, as this might create # race conditions, as I understand it. - package IkiWiki::Plugin::darcs; use warnings; use strict; use IkiWiki; - sub import { hook(type => "checkconfig", id => "darcs", call => \&checkconfig); hook(type => "getsetup", id => "darcs", call => \&getsetup); @@ -59,9 +58,6 @@ sub import { hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); } - -# Internal functions - sub silentsystem (@) { open(SAVED_STDOUT, ">&STDOUT"); open(STDOUT, ">/dev/null"); @@ -94,8 +90,8 @@ sub darcs_info ($$$) { } sub file_in_vc($$) { - my $repodir = shift; - my $file = shift; + my $repodir = shift; + my $file = shift; my $child = open(DARCS_MANIFEST, "-|"); if (! $child) { @@ -115,14 +111,11 @@ sub darcs_rev($) { my $file = shift; # Relative to the repodir. my $repodir = $config{srcdir}; - return "" if (! file_in_vc($repodir, $file)); + return "" if (! file_in_vc($repodir, $file)); my $hash = darcs_info('hash', $repodir, $file); return defined $hash ? $hash : ""; } - -# Exported functions. - sub checkconfig() { if (defined $config{darcs_wrapper} && length $config{darcs_wrapper}) { push @{$config{wrappers}}, { @@ -134,38 +127,38 @@ sub checkconfig() { sub getsetup() { return - plugin => { - safe => 0, # rcs plugin - rebuild => undef, - }, - darcs_wrapper => { - type => "string", - example => "/darcs/repo/_darcs/ikiwiki-wrapper", - description => "wrapper to generate (set as master repo apply hook)", - safe => 0, # file - rebuild => 0, - }, - darcs_wrappermode => { - type => "string", - example => '06755', - description => "mode for darcs_wrapper (can safely be made suid)", - safe => 0, - rebuild => 0, - }, - historyurl => { - type => "string", - example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filehistory;f=[[file]]", - description => "darcsweb url to show file history ([[file]] substituted)", - safe => 1, - rebuild => 1, - }, - diffurl => { - type => "string", - example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filediff;h=[[hash]];f=[[file]]", - description => "darcsweb url to show a diff ([[hash]] and [[file]] substituted)", - safe => 1, - rebuild => 1, - }, + plugin => { + safe => 0, # rcs plugin + rebuild => undef, + }, + darcs_wrapper => { + type => "string", + example => "/darcs/repo/_darcs/ikiwiki-wrapper", + description => "wrapper to generate (set as master repo apply hook)", + safe => 0, # file + rebuild => 0, + }, + darcs_wrappermode => { + type => "string", + example => '06755', + description => "mode for darcs_wrapper (can safely be made suid)", + safe => 0, + rebuild => 0, + }, + historyurl => { + type => "string", + example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filehistory;f=[[file]]", + description => "darcsweb url to show file history ([[file]] substituted)", + safe => 1, + rebuild => 1, + }, + diffurl => { + type => "string", + example => "http://darcs.example.com/darcsweb.cgi?r=wiki;a=filediff;h=[[hash]];f=[[file]]", + description => "darcsweb url to show a diff ([[hash]] and [[file]] substituted)", + safe => 1, + rebuild => 1, + }, } sub rcs_update () { @@ -176,8 +169,7 @@ sub rcs_prepedit ($) { # Prepares to edit a file under revision control. Returns a token that # must be passed to rcs_commit() when the file is to be commited. For us, # this token the hash value of the latest patch that modifies the file, - # i.e. something like its current revision. If the file is not yet added - # to the repository, we return TODO: the empty string. + # i.e. something like its current revision. my $file = shift; # Relative to the repodir. my $rev = darcs_rev($file); @@ -195,63 +187,63 @@ sub rcs_commit ($$$;$$) { # Yes, the following is a bit convoluted. if ($changed) { - # TODO. Invent a better, non-conflicting name. - rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or - error("failed to rename $file to $file.save: $!"); - - # Roll the repository back to $rcstoken. - - # TODO. Can we be sure that no changes are lost? I think that - # we can, if we make sure that the 'darcs push' below will always - # succeed. - - # We need to revert everything as 'darcs obliterate' might choke - # otherwise. - # TODO: 'yes | ...' needed? Doesn't seem so. - silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") and - error("'darcs revert' failed"); - # Remove all patches starting at $rcstoken. - my $child = open(DARCS_OBLITERATE, "|-"); - if (! $child) { - open(STDOUT, ">/dev/null"); - exec('darcs', "obliterate", "--repodir", $config{srcdir}, - "--match", "hash " . $rcstoken) and - error("'darcs obliterate' failed"); - } - while (print DARCS_OBLITERATE "y") { - ; - } - close(DARCS_OBLITERATE); - # Restore the $rcstoken one. - silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir}, - "--match", "hash " . $rcstoken, "--all") and - error("'darcs pull' failed"); - - # We're back at $rcstoken. Re-install the modified file. - rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or - error("failed to rename $file.save to $file: $!"); + # TODO. Invent a better, non-conflicting name. + rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or + error("failed to rename $file to $file.save: $!"); + + # Roll the repository back to $rcstoken. + + # TODO. Can we be sure that no changes are lost? I think that + # we can, if we make sure that the 'darcs push' below will always + # succeed. + + # We need to revert everything as 'darcs obliterate' might choke + # otherwise. + # TODO: 'yes | ...' needed? Doesn't seem so. + silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") == 0 || + error("'darcs revert' failed"); + # Remove all patches starting at $rcstoken. + my $child = open(DARCS_OBLITERATE, "|-"); + if (! $child) { + open(STDOUT, ">/dev/null"); + exec('darcs', "obliterate", "--repodir", $config{srcdir}, + "--match", "hash " . $rcstoken) and + error("'darcs obliterate' failed"); + } + 1 while print DARCS_OBLITERATE "y"; + close(DARCS_OBLITERATE); + # Restore the $rcstoken one. + silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir}, + "--match", "hash " . $rcstoken, "--all") == 0 || + error("'darcs pull' failed"); + + # We're back at $rcstoken. Re-install the modified file. + rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or + error("failed to rename $file.save to $file: $!"); } # Record the changes. my $author; if (defined $user) { $author = "$user\@web"; - } elsif (defined $ipaddr) { + } + elsif (defined $ipaddr) { $author = "$ipaddr\@web"; - } else { + } + else { $author = "anon\@web"; } if (!defined $message || !length($message)) { $message = "empty message"; } silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all', - '-m', $message, '--author', $author, $file) and + '-m', $message, '--author', $author, $file) == 0 || error("'darcs record' failed"); # Update the repository by pulling from the default repository, which is # master repository. silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir}, - "--all") and error("'darcs pull' failed"); + "--all") !=0 || error("'darcs pull' failed"); # If this updating yields any conflicts, we'll record them now to resolve # them. If nothing is recorded, there are no conflicts. @@ -259,25 +251,26 @@ sub rcs_commit ($$$;$$) { # TODO: Use only the first line here, i.e. only the patch name? writefile("$file.log", $config{srcdir}, 'resolve conflicts: ' . $message); silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all', - '-m', 'resolve conflicts: ' . $message, '--author', $author, $file) and + '-m', 'resolve conflicts: ' . $message, '--author', $author, $file) == 0 || error("'darcs record' failed"); my $conflicts = darcs_rev($file) ne $rcstoken; unlink("$config{srcdir}/$file.log") or - error("failed to remove '$file.log'"); + error("failed to remove '$file.log'"); # Push the changes to the main repository. - silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') - and error("'darcs push' failed"); + silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') == 0 || + error("'darcs push' failed"); # TODO: darcs send? if ($conflicts) { my $document = readfile("$config{srcdir}/$file"); # Try to leave everything in a consistent state. # TODO: 'yes | ...' needed? Doesn't seem so. - silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") and + silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") == 0 || warn("'darcs revert' failed"); return $document; - } else { + } + else { return undef; } } @@ -288,9 +281,11 @@ sub rcs_commit_staged($$$) { my $author; if (defined $user) { $author = "$user\@web"; - } elsif (defined $ipaddr) { + } + elsif (defined $ipaddr) { $author = "$ipaddr\@web"; - } else { + } + else { $author = "anon\@web"; } if (!defined $message || !length($message)) { @@ -298,11 +293,11 @@ sub rcs_commit_staged($$$) { } silentsystem('darcs', "record", "--repodir", $config{srcdir}, "-a", "-A", $author, - "-m", $message) and error("'darcs record' failed"); + "-m", $message) == 0 || error("'darcs record' failed"); # Push the changes to the main repository. - silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') - and error("'darcs push' failed"); + silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') == 0 || + error("'darcs push' failed"); # TODO: darcs send? return undef; @@ -314,7 +309,7 @@ sub rcs_add ($) { if(! file_in_vc($config{srcdir}, $file)) { # Intermediate directories will be added automagically. system('darcs', 'add', '--quiet', '--repodir', $config{srcdir}, - '--boring', $file) and error("'darcs add' failed"); + '--boring', $file) == 0 || error("'darcs add' failed"); } } @@ -328,8 +323,8 @@ sub rcs_rename ($$) { my $a = shift; # Relative to the repodir. my $b = shift; # Relative to the repodir. - system('darcs', 'mv', '--repodir', $config{srcdir}, $a, $b) - and error("'darcs mv' failed"); + system('darcs', 'mv', '--repodir', $config{srcdir}, $a, $b) == 0 || + error("'darcs mv' failed"); } sub rcs_recentchanges ($) { @@ -367,20 +362,17 @@ sub rcs_recentchanges ($) { push @pages, $_ for (@{$patch->{summary}->[0]->{modify_file}}); push @pages, $_ for (@{$patch->{summary}->[0]->{add_file}}); push @pages, $_ for (@{$patch->{summary}->[0]->{remove_file}}); - for (@pages) { - my $f = $_; - $f = $_->{content} if (ref $_); + foreach my $f (@pages) { + $f = $f->{content} if ref $f; $f =~ s,^\s+,,; $f =~ s,\s+$,,; # cut whitespace push @files, $f; } - for (@{$patch->{summary}->[0]->{move}}) { - my $p = $_; + foreach my $p (@{$patch->{summary}->[0]->{move}}) { push @files, $p->{from}; } - for (@files) { - my $f = $_; + foreach my $f (@files) { my $d = defined $config{'diffurl'} ? $config{'diffurl'} : ""; $d =~ s/\[\[file\]\]/$f/go; $d =~ s/\[\[hash\]\]/$hash/go; @@ -397,12 +389,13 @@ sub rcs_recentchanges ($) { . scalar @pg . " changes)"); my @message; - push @message, { line => $_ } for (@{$patch->{name}}); + push @message, { line => $_ } foreach (@{$patch->{name}}); my $committype; if ($patch->{author} =~ /\@web$/) { $committype = "web"; - } else { + } + else { $committype = "darcs"; } @@ -456,25 +449,26 @@ sub rcs_getctime ($) { } my $data; - $data .= $_ while(); + { + local $/=undef; + $data = ; + } close LOG; my $log = XMLin($data, ForceArray => 1); - my $datestr=$log->{patch}[0]->{local_date}; + 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 $filer"); + my $date = str2time($datestr); + + debug("ctime for '$file': ". localtime($date)); return $date; } 1 - -# vim: ts=4 sw=4 noet -- cgit v1.2.3 From f7fa6966195a3a4cc392aea56b307c939d28ffc7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 17:49:04 -0400 Subject: move comments to copyright and changelog --- IkiWiki/Plugin/darcs.pm | 38 -------------------------------------- debian/changelog | 13 +++++++++++++ debian/copyright | 10 ++++++++++ 3 files changed, 23 insertions(+), 38 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 978457b2c..dfd193b9c 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -1,42 +1,4 @@ #!/usr/bin/perl -# Support for the darcs rcs, . -# Copyright (C) 2006 Thomas Schwinge -# 2007 Benjamin A'Lee -# Tuomo Valkonen -# 2008 Simon Michael -# Petr Ročkai -# Sven M. Hallberg -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# History (see http://ikiwiki.info/todo/darcs/): -# -# * Thomas Schwinge wrote the original file, implementing only rcs_commit. -# * Benjamin A'Lee contributed an alternative implementation. -# * Tuomo Valkonen contributed rcs_getctime and stub rcs_recentchanges. -# * Simon Michael contributed multiple changes. -# * Petr Ročkai fixed rcs_recentchanges and added caching to rcs_getctime. -# * Sven M. Hallberg merged the above and added missing features. - - -# We're guaranteed to be the only instance of ikiwiki running at a given -# time. It is essential that only ikiwiki is working on a particular -# repository. That means one instance of ikiwiki and it also means that -# you must not 'darcs push' into this repository, as this might create -# race conditions, as I understand it. - package IkiWiki::Plugin::darcs; use warnings; diff --git a/debian/changelog b/debian/changelog index fab20985d..2b1f938b3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +ikiwiki (3.10) UNRELEASED; urgency=low + + * darcs: Finally added support for this VCS, thanks to many + contributors: + - Thomas Schwinge wrote the original file, implementing only rcs_commit. + - Benjamin A'Lee contributed an alternative implementation. + - Tuomo Valkonen contributed rcs_getctime and stub rcs_recentchanges. + - Simon Michael contributed multiple changes. + - Petr Ročkai fixed rcs_recentchanges. + - Sven M. Hallberg merged the above and added missing features. + + -- Joey Hess Sat, 04 Apr 2009 17:47:36 -0400 + ikiwiki (3.09) unstable; urgency=low * inline: Add title_natural sort order, using Sort::Naturally diff --git a/debian/copyright b/debian/copyright index 67f0ac540..5fc55f5c5 100644 --- a/debian/copyright +++ b/debian/copyright @@ -32,6 +32,16 @@ Files: tla.pm Copyright: © 2006 Clint Adams License: GPL-2+ +Files: darcs.pm +Copyright: + © 2006 Thomas Schwinge + 2007 Benjamin A'Lee + Tuomo Valkonen + 2008 Simon Michael + Petr Ročkai + Sven M. Hallberg +License: GPL-2+ + Files: teximg.pm Copyright: © 2007 Patrick Winnertz License: GPL-2+ -- cgit v1.2.3 From a9c0d7e288d06a43e4e3d03e3ff8496e99e80962 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 18:17:38 -0400 Subject: support darcs in setup automator use a consistent name for the ikiwiki wrapper file --- IkiWiki/Setup/Automator.pm | 3 +++ doc/rcs/darcs.mdwn | 2 +- ikiwiki-makerepo | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 7d9eca3af..f1ed57b4b 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -58,6 +58,9 @@ sub import (@) { elsif ($config{rcs} eq 'monotone') { $config{mtn_wrapper}=$config{srcdir}."_MTN/ikiwiki-netsync-hook"; } + elsif ($config{rcs} eq 'darcs') { + $config{darcs_wrapper}=$config{repository}."_darcs/ikiwiki-wrapper"; + } elsif ($config{rcs} eq 'bzr') { # TODO } diff --git a/doc/rcs/darcs.mdwn b/doc/rcs/darcs.mdwn index 7f66d0808..fbb9bcede 100644 --- a/doc/rcs/darcs.mdwn +++ b/doc/rcs/darcs.mdwn @@ -9,7 +9,7 @@ automatically commits edited pages, and uses the Darcs history to generate the Example for a `_darcs/prefs/defaults` file in `$SRCDIR`: - apply posthook /path/to/repository/_darcs/ikiwrapper + apply posthook /path/to/repository/_darcs/ikiwiki-wrapper apply run-posthook See also [[todo/darcs|todo/darcs]] diff --git a/ikiwiki-makerepo b/ikiwiki-makerepo index 787611ac1..8d590f0c2 100755 --- a/ikiwiki-makerepo +++ b/ikiwiki-makerepo @@ -143,7 +143,7 @@ darcs) # set up master repo's apply hook and tell user to adjust it if desired darcsdefaults="$repository/_darcs/prefs/defaults" echo "Preconfiguring apply hook in $darcsdefaults - adjust as desired!" - echo "apply posthook $repository/_darcs/ikiwrapper" >> "$darcsdefaults" + echo "apply posthook $repository/_darcs/ikiwiki-wrapper" >> "$darcsdefaults" echo "apply run-posthook" >> "$darcsdefaults" ;; *) -- cgit v1.2.3 From 3fb4653d8a0824fb182da0346a7a80b282564cd5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 18:25:52 -0400 Subject: Add missing newline to Confirm Password prompt. --- IkiWiki/Setup/Automator.pm | 1 + debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 7d9eca3af..c194d34be 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -117,6 +117,7 @@ sub import (@) { for (;;) { print "Choose a password: "; chomp($password=); + print "\n"; print "Confirm password: "; chomp($password2=); diff --git a/debian/changelog b/debian/changelog index fab20985d..781024146 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.10) UNRELEASED; urgency=low + + * Add missing newline to Confirm Password prompt. + + -- Joey Hess Sat, 04 Apr 2009 18:25:33 -0400 + ikiwiki (3.09) unstable; urgency=low * inline: Add title_natural sort order, using Sort::Naturally -- cgit v1.2.3 From 01b063d2e2f79704fe1d850f226a01a01400da01 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 18:30:29 -0400 Subject: fix bug I introduced --- IkiWiki/Plugin/darcs.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index dfd193b9c..5927f23da 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -205,7 +205,7 @@ sub rcs_commit ($$$;$$) { # Update the repository by pulling from the default repository, which is # master repository. silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir}, - "--all") !=0 || error("'darcs pull' failed"); + "--all") == 0 || error("'darcs pull' failed"); # If this updating yields any conflicts, we'll record them now to resolve # them. If nothing is recorded, there are no conflicts. -- cgit v1.2.3 From 91e583bce1ce8adee4d70bb4a64b46a900c29b45 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 18:32:41 -0400 Subject: fix name of wrapper --- IkiWiki/Setup/Automator.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index f1ed57b4b..8a451d386 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -59,7 +59,7 @@ sub import (@) { $config{mtn_wrapper}=$config{srcdir}."_MTN/ikiwiki-netsync-hook"; } elsif ($config{rcs} eq 'darcs') { - $config{darcs_wrapper}=$config{repository}."_darcs/ikiwiki-wrapper"; + $config{darcs_wrapper}=$config{repository}."/_darcs/ikiwiki-wrapper"; } elsif ($config{rcs} eq 'bzr') { # TODO -- cgit v1.2.3 From 6a7eb63ca534bdad7ab13f840cdee33ea391d9bf Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 18:36:39 -0400 Subject: fix display of web commits in recentchanges The darcs backend appends @web to the names of web committers, so remove it when extracting. --- IkiWiki/Plugin/darcs.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 5927f23da..1ed9f0044 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -354,16 +354,19 @@ sub rcs_recentchanges ($) { push @message, { line => $_ } foreach (@{$patch->{name}}); my $committype; - if ($patch->{author} =~ /\@web$/) { + my $author; + if ($patch->{author} =~ /(.*)\@web$/) { + $author = $1; $committype = "web"; } else { + $author=$patch->{author}; $committype = "darcs"; } push @ret, { rev => $patch->{hash}, - user => $patch->{author}, + user => $author, committype => $committype, when => $when, message => [@message], -- cgit v1.2.3 From f8fa69326a8963b179f2c0d6dd52d2f737634541 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 18:48:33 -0400 Subject: remove debugging --- IkiWiki/Plugin/darcs.pm | 7 ------- 1 file changed, 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 1ed9f0044..de9ef4f03 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -298,8 +298,6 @@ sub rcs_recentchanges ($) { my $repodir=$config{srcdir}; - debug("darcs recent changes: $num"); - my $child = open(LOG, "-|"); if (! $child) { $ENV{"DARCS_DONT_ESCAPE_ANYTHING"}=1; @@ -315,7 +313,6 @@ sub rcs_recentchanges ($) { my $log = XMLin($data, ForceArray => 1); - debug("parsing recent changes..."); foreach my $patch (@{$log->{patch}}) { my $date=$patch->{local_date}; my $hash=$patch->{hash}; @@ -339,16 +336,12 @@ sub rcs_recentchanges ($) { $d =~ s/\[\[file\]\]/$f/go; $d =~ s/\[\[hash\]\]/$hash/go; - debug("file: $f"); - debug("diffurl: $d"); push @pg, { page => pagename($f), diffurl => $d, }; } next unless (scalar @pg > 0); - debug("recent change: " . $patch->{name}[0] . " (" - . scalar @pg . " changes)"); my @message; push @message, { line => $_ } foreach (@{$patch->{name}}); -- cgit v1.2.3 From 4cf70291bcc4fbeeb2a6233a121b5d9f9c00344d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 4 Apr 2009 19:04:02 -0400 Subject: remove unnecessary variable --- IkiWiki/Plugin/darcs.pm | 7 ++----- po/ikiwiki.pot | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index de9ef4f03..9b62e70e4 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -393,16 +393,13 @@ sub rcs_getctime ($) { eval q{use XML::Simple}; local $/=undef; - # Sigh... doing things the hard way again - my $repodir=$config{srcdir}; - - my $filer=substr($file, length($repodir)); + my $filer=substr($file, length($config{srcdir})); $filer =~ s:^[/]+::; my $child = open(LOG, "-|"); if (! $child) { exec("darcs", "changes", "--xml", "--reverse", - "--repodir", "$repodir", "$filer") + "--repodir", $config{srcdir}, $filer) || error("'darcs changes $filer' failed to run"); } diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index b05558858..d05a4a693 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-04-04 18:19-0400\n" +"POT-Creation-Date: 2009-04-04 18:50-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -- cgit v1.2.3