From 20ba12802b3897bf48d8a7704a57e9cede2466bd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Feb 2010 04:22:15 -0500 Subject: add section information --- IkiWiki/Plugin/norcs.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'IkiWiki/Plugin/norcs.pm') diff --git a/IkiWiki/Plugin/norcs.pm b/IkiWiki/Plugin/norcs.pm index bfe84c0e1..e6a05a3c5 100644 --- a/IkiWiki/Plugin/norcs.pm +++ b/IkiWiki/Plugin/norcs.pm @@ -25,6 +25,7 @@ sub getsetup () { plugin => { safe => 0, # rcs plugin rebuild => 0, + section => "rcs", }, } -- cgit v1.2.3 From b14f84c4acccbc8450a9102b3b647013989b27bb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 16 Apr 2010 17:02:29 -0400 Subject: --gettime revamp * Rename --getctime to --gettime. (The old name still works for backwards compatability.) * --gettime now also looks up last modification time. * Add rcs_getmtime to plugin API; currently only implemented for git. --- IkiWiki.pm | 8 +++++-- IkiWiki/Plugin/bzr.pm | 5 +++++ IkiWiki/Plugin/cvs.pm | 5 +++++ IkiWiki/Plugin/darcs.pm | 5 +++++ IkiWiki/Plugin/git.pm | 5 +++++ IkiWiki/Plugin/mercurial.pm | 5 +++++ IkiWiki/Plugin/monotone.pm | 5 +++++ IkiWiki/Plugin/norcs.pm | 7 +++++- IkiWiki/Plugin/svn.pm | 5 +++++ IkiWiki/Plugin/tla.pm | 5 +++++ IkiWiki/Render.pm | 18 +++++++++++++--- debian/changelog | 5 +++++ .../How_does_ikiwiki_remember_times__63__.mdwn | 25 ++++++---------------- ...old_repository_to_new_ikiwiki_system__63__.mdwn | 4 ---- doc/plugins/write.mdwn | 7 ++++++ doc/rcs.mdwn | 8 +++++-- doc/tips/Importing_posts_from_Wordpress.mdwn | 2 +- doc/tips/inside_dot_ikiwiki/discussion.mdwn | 7 +++--- doc/todo/auto_getctime_on_fresh_build.mdwn | 8 +++++-- doc/usage.mdwn | 10 ++++----- ikiwiki.in | 3 ++- mtime-to-git | 14 ------------ 22 files changed, 109 insertions(+), 57 deletions(-) delete mode 100755 mtime-to-git (limited to 'IkiWiki/Plugin/norcs.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 1730e476a..7655dada5 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -440,10 +440,10 @@ sub getsetup () { safe => 0, rebuild => 0, }, - getctime => { + gettime => { type => "internal", default => 0, - description => "running in getctime mode", + description => "running in gettime mode", safe => 0, rebuild => 0, }, @@ -1790,6 +1790,10 @@ sub rcs_getctime ($) { $hooks{rcs}{rcs_getctime}{call}->(@_); } +sub rcs_getmtime ($) { + $hooks{rcs}{rcs_getmtime}{call}->(@_); +} + sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm index 0efc26b49..f79ca7c8f 100644 --- a/IkiWiki/Plugin/bzr.pm +++ b/IkiWiki/Plugin/bzr.pm @@ -20,6 +20,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub checkconfig () { @@ -306,4 +307,8 @@ sub rcs_getctime ($) { return $ctime; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for bzr\n"; # TODO +} + 1 diff --git a/IkiWiki/Plugin/cvs.pm b/IkiWiki/Plugin/cvs.pm index 26a3e9dd2..360d97249 100644 --- a/IkiWiki/Plugin/cvs.pm +++ b/IkiWiki/Plugin/cvs.pm @@ -49,6 +49,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub genwrapper () { @@ -485,4 +486,8 @@ sub rcs_getctime ($) { return $date; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for cvs\n"; # TODO +} + 1 diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index bc8394b90..c1d6661d3 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -18,6 +18,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub silentsystem (@) { @@ -427,4 +428,8 @@ sub rcs_getctime ($) { return $date; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for darcs\n"; # TODO +} + 1 diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index b02f4a5ed..86d80186f 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -25,6 +25,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive); } @@ -634,6 +635,10 @@ sub rcs_getctime ($) { return $ctime; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for git\n"; # TODO +} + sub rcs_receive () { # The wiki may not be the only thing in the git repo. # Determine if it is in a subdirectory by examining the srcdir, diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index ea00a3364..34e009c7a 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -20,6 +20,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub checkconfig () { @@ -254,4 +255,8 @@ sub rcs_getctime ($) { return $ctime; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for mercurial\n"; # TODO +} + 1 diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index c33cf7e3a..67d4abbaa 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -23,6 +23,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub checkconfig () { @@ -693,4 +694,8 @@ sub rcs_getctime ($) { return $date; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for monotone\n"; # TODO +} + 1 diff --git a/IkiWiki/Plugin/norcs.pm b/IkiWiki/Plugin/norcs.pm index e6a05a3c5..053652a5f 100644 --- a/IkiWiki/Plugin/norcs.pm +++ b/IkiWiki/Plugin/norcs.pm @@ -18,6 +18,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub getsetup () { @@ -63,7 +64,11 @@ sub rcs_diff ($) { } sub rcs_getctime ($) { - error gettext("getctime not implemented"); + return 0; +} + +sub rcs_getmtime ($) { + return 0; } 1 diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index 7d27ec842..85c205f09 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -19,6 +19,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub checkconfig () { @@ -379,4 +380,8 @@ sub rcs_getctime ($) { return $date; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for svn\n"; # TODO +} + 1 diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index 764da9b98..f5ad0cc96 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -18,6 +18,7 @@ sub import { 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 => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); } sub checkconfig () { @@ -284,4 +285,8 @@ sub rcs_getctime ($) { return $date; } +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for tla\n"; # TODO +} + 1 diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index e98888d76..e1cb68462 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -365,14 +365,26 @@ sub find_new_files ($) { } else { push @new, $file; - if ($config{getctime} && -e "$config{srcdir}/$file") { + if ($config{gettime} && -e "$config{srcdir}/$file") { eval { - my $time=rcs_getctime("$config{srcdir}/$file"); - $pagectime{$page}=$time; + my $ctime=rcs_getctime("$config{srcdir}/$file"); + if ($ctime > 0) { + $pagectime{$page}=$ctime; + } }; if ($@) { print STDERR $@; } + my $mtime; + eval { + my $mtime=rcs_getmtime("$config{srcdir}/$file"); + }; + if ($@) { + print STDERR $@; + } + elsif ($mtime > 0) { + utime($mtime, $mtime, "$config{srcdir}/$file"); + } } } $pagecase{lc $page}=$page; diff --git a/debian/changelog b/debian/changelog index 737d73655..615d5916f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -44,6 +44,11 @@ ikiwiki (3.20100415) UNRELEASED; urgency=low * conditional: Fix bug that forced "all" mode off by default. * calendarmonth.tmpl: The month calendar is now put in a sidebar. * calendar: Improved display of arrows. + * Rename --getctime to --gettime. (The old name still works for + backwards compatability.) + * --gettime now also looks up last modification time. + * Add rcs_getmtime to plugin API; currently only implemented + for git. -- Joey Hess Sun, 04 Apr 2010 12:17:11 -0400 diff --git a/doc/forum/How_does_ikiwiki_remember_times__63__.mdwn b/doc/forum/How_does_ikiwiki_remember_times__63__.mdwn index 6ce576db1..6b7739fd0 100644 --- a/doc/forum/How_does_ikiwiki_remember_times__63__.mdwn +++ b/doc/forum/How_does_ikiwiki_remember_times__63__.mdwn @@ -20,15 +20,17 @@ Do I have it right? > Some VCS, like git, set the file mtimes to the current time > when making a new checkout, so they will be lost if you do that. > The creation times can be retrived using the `--getctime` option. -> I suppose it might be nice if there were a `--getmtime` that pulled -> true modification times out of the VCS, but I haven't found it a big -> deal in practice for the last modification times to be updated to the -> current time when rebuilding a wiki like this. --[[Joey]] +> --[[Joey]] > > > Thanks for the clarification. I ran some tests of my own to make sure I understand it right, and I'm satisfied > > that the order of posts in my blog can be retrieved from the VCS using the `--getctime` option, at least if I > > choose to order my posts by creation time rather than modification time. But I now know that I can't rely on > > page modification times in ikiwiki as these can be lost permanently. +> +> > > Update: It's now renamed to `--gettime`, and pulls both the creation +> > > and modification times. Also, per [[todo/auto_getctime_on_fresh_build]], +> > > this is now done automatically the first time ikiwiki builds a +> > > srcdir. So, no need to worry about this any more! --[[Joey]] > > > > I would suggest that there should at least be a `--getmtime` option like you describe, and perhaps that > > `--getctime` and `--getmtime` be _on by default_. In my opinion the creation times and modification times of @@ -91,19 +93,6 @@ Do I have it right? > A quick workaround for me to get modification times right is the following > little zsh script, which unfortunately only works for git: - #!/usr/bin/env zsh - - set +x - - for FILE in **/*(.); do - TIMES="`git log --pretty=format:%ai $FILE`" - MTIME="`echo $TIMES | head -n1`" - - if [ ! -z $MTIME ]; then - echo touch -m -d "$MTIME" $FILE - touch -m -d "$MTIME" $FILE - fi - - done +>> Elided; no longer needed since --gettime does that, and much faster! --[[Joey]] > --[[David_Riebenbauer]] diff --git a/doc/forum/Migrating_old_repository_to_new_ikiwiki_system__63__.mdwn b/doc/forum/Migrating_old_repository_to_new_ikiwiki_system__63__.mdwn index fe67e6aba..d7a33b526 100644 --- a/doc/forum/Migrating_old_repository_to_new_ikiwiki_system__63__.mdwn +++ b/doc/forum/Migrating_old_repository_to_new_ikiwiki_system__63__.mdwn @@ -20,10 +20,6 @@ How do I set up an ikiwiki system using a pre-existing repository (instead of cr > recreate the ikiwiki srcdir > 3. `git clone` from the bare git repository a second time, > to create a checkout you can manually edit (optional) -> 4. run `ikiwiki --getctime --setup your.setup` -> The getctime will ensure page creation times are accurate -> by putting the info out of the git history, -> and only needs to be done once. > > If you preserved your repository, but not the setup file, > the easiest way to make one is probably to run diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 707622956..cf7044b2c 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1085,6 +1085,13 @@ it up in the history. It's ok if this is not implemented, and throws an error. +#### `rcs_getmtime($)` + +This is used to get the page modification time for a file from the RCS, by +looking it up in the history. + +It's ok if this is not implemented, and throws an error. + #### `rcs_receive()` This is called when ikiwiki is running as a pre-receive hook (or diff --git a/doc/rcs.mdwn b/doc/rcs.mdwn index 4e7a8d2a6..b5bfc2414 100644 --- a/doc/rcs.mdwn +++ b/doc/rcs.mdwn @@ -14,8 +14,10 @@ use, some advanced or special features are not supported in all of them. Lack of support in [[ikiwiki-makerepo]] or auto.setup can make it harder to set up a wiki using that revision control system. The `rcs_commit_staged` hook is needed to use [[attachments|plugins/attachment]] or -[[plugins/comments]]. And so on. The table below summarises this for each -revision control system and links to more information about each. +[[plugins/comments]]. `rcs_getctime` may be implemented in a fast way +(ie, one log lookup for all files), or very slowly (one lookup per file). +And so on. The table below summarises this for each revision control +system and links to more information about each. [[!table data=""" feature |[[git]]|[[svn]]|[[bzr]] |[[monotone]]|[[mercurial]]|[[darcs]]|[[tla]] |[[cvs]] @@ -25,6 +27,8 @@ auto.setup |yes |yes |incomplete|yes |incomplete |yes `rcs_rename` |yes |yes |yes |yes |no |yes |no |yes `rcs_remove` |yes |yes |yes |yes |no |yes |no |yes `rcs_diff` |yes |yes |yes |yes |no |yes |yes |yes +`rcs_getctime` |fast |slow |slow |slow |slow |slow |slow |slow +`rcs_getmtime` |fast |no |no |no |no |no |no |no anonymous push |yes |no |no |no |no |no |no |no conflict handling |yes |yes |yes |buggy |yes |yes |yes |yes """]] diff --git a/doc/tips/Importing_posts_from_Wordpress.mdwn b/doc/tips/Importing_posts_from_Wordpress.mdwn index 59330caa4..8774c9723 100644 --- a/doc/tips/Importing_posts_from_Wordpress.mdwn +++ b/doc/tips/Importing_posts_from_Wordpress.mdwn @@ -1,6 +1,6 @@ Use case: You want to move away from Wordpress to Ikiwiki as your blogging/website platform, but you want to retain your old posts. -[This](http://git.chris-lamb.co.uk/?p=ikiwiki-wordpress-import.git) is a simple tool that generates [git-fast-import](http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html)-compatible data from a WordPress export XML file. It retains creation time of each post, so you can use Ikiwiki's --getctime to get the preserve creation times on checkout. +[This](http://git.chris-lamb.co.uk/?p=ikiwiki-wordpress-import.git) is a simple tool that generates [git-fast-import](http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html)-compatible data from a WordPress export XML file. It retains creation time of each post, so you can use Ikiwiki's --gettime to get the preserve creation times on checkout. WordPress categories are mapped onto Ikiwiki tags. The ability to import comments is planned. diff --git a/doc/tips/inside_dot_ikiwiki/discussion.mdwn b/doc/tips/inside_dot_ikiwiki/discussion.mdwn index 34d5b9252..69df369ec 100644 --- a/doc/tips/inside_dot_ikiwiki/discussion.mdwn +++ b/doc/tips/inside_dot_ikiwiki/discussion.mdwn @@ -6,14 +6,15 @@ My database appears corrupted: No idea how this happened. I've blown it away and recreated it but, for future reference, is there any less violent way to recover from this situation? I miss having the correct created and last edited times. --[[sabr]] > update: fixed ctimes and mtimes using [these instructions](http://u32.net/Mediawiki_Conversion/Git_Import/#Correct%20Creation%20and%20Last%20Edited%20time) --[[sabr]] -> That's overly complex. Just run `ikiwiki -setup your.setup -getctime`. +> That's overly complex. Just run `ikiwiki -setup your.setup -gettime`. > BTW, I'd be interested in examining such a corrupt storable file to try > to see what happened to it. --[[Joey]] ->> --getctime appears to only set the last edited date. It's not supposed to set the creation date, is it? The only place that info is stored is in the git repo. +>> --gettime appears to only set the last edited date. It's not supposed to set the creation date, is it? The only place that info is stored is in the git repo. >>> Pulling the page creation date out of the git history is exactly what ->>> --getctime does. --[[Joey]] +>>> --gettime does. (It used to be called --getctime, and only do that; now +>>> it also pulls out the last modified date). --[[Joey]] >> Alas, I seem to have lost the bad index file to periodic /tmp wiping; I'll send it to you if it happens again. --[[sabr]] diff --git a/doc/todo/auto_getctime_on_fresh_build.mdwn b/doc/todo/auto_getctime_on_fresh_build.mdwn index ea95fb8c9..760c56fa1 100644 --- a/doc/todo/auto_getctime_on_fresh_build.mdwn +++ b/doc/todo/auto_getctime_on_fresh_build.mdwn @@ -1,9 +1,13 @@ [[!tag wishlist]] -It might be a good idea to enable --getctime when `.ikiwiki` does not +It might be a good idea to enable --gettime when `.ikiwiki` does not exist. This way a new checkout of a `srcdir` would automatically get -ctimes right. (Running --getctime whenever a rebuild is done would be too +ctimes right. (Running --gettime whenever a rebuild is done would be too slow.) --[[Joey]] Could this be too annoying in some cases, eg, checking out a large wiki that needs to get set up right away? --[[Joey]] + +> Not for git with the new, optimised --getctime. For other VCS.. well, +> pity they're not as fast as git ;), but it is a one-time expense... +> [[done]] --[[Joey]] diff --git a/doc/usage.mdwn b/doc/usage.mdwn index db1e36a10..553fef01e 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -320,13 +320,11 @@ also be configured using a setup file. intercepted. If you enable this option then you must run at least the CGI portion of ikiwiki over SSL. -* --getctime +* --gettime - Pull creation time for each new page out of the revision control - system. This rarely used option provides a way to get the real creation - times of items in weblogs, such as when building a wiki from a new - VCS checkout. It is unoptimised and quite slow. It is best used - with --rebuild, to force ikiwiki to get the ctime for all pages. + Extract creation and modification times for each new page from the + the revision control's log. This is done automatically when building a + wiki for the first time, so you normally do not need to use this option. * --set var=value diff --git a/ikiwiki.in b/ikiwiki.in index 38e4d3201..801ff9a0b 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -44,7 +44,8 @@ sub getconfig () { "wrappergroup=s" => \$config{wrappergroup}, "usedirs!" => \$config{usedirs}, "prefix-directives!" => \$config{prefix_directives}, - "getctime" => \$config{getctime}, + "getctime" => \$config{gettime}, + "gettime" => \$config{gettime}, "numbacklinks=i" => \$config{numbacklinks}, "rcs=s" => \$config{rcs}, "no-rcs" => sub { $config{rcs}="" }, diff --git a/mtime-to-git b/mtime-to-git deleted file mode 100755 index 9875af5d7..000000000 --- a/mtime-to-git +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# Sets mtimes of all files in the tree their last change date -# based on git's log. Useful to avoid too new dates after a -# fresh checkout, which lead to ikiwiki unnecessarily rebuilding -# basewiki files on upgrade. -if [ -d .git ]; then - for file in $(git ls-files); do - date="$(git log -1 --date=rfc "$file" | grep ^Date: | sed -e 's/Date://')" - if [ -n "$date" ]; then - echo "$date $file" - touch -d"$date" $file - fi - done -fi -- cgit v1.2.3 From b4a43406f61b7ff9ab77d242edf4d59369ac8596 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 23 Jun 2010 16:05:49 -0400 Subject: API: rcs_commit and rcs_commit_staged are passed a new parameter that may contain the username component of the email address of the user making the commit. --- IkiWiki/Plugin/bzr.pm | 8 ++++---- IkiWiki/Plugin/cvs.pm | 7 ++++--- IkiWiki/Plugin/darcs.pm | 8 ++++---- IkiWiki/Plugin/git.pm | 8 ++++---- IkiWiki/Plugin/mercurial.pm | 8 ++++---- IkiWiki/Plugin/monotone.pm | 7 ++++--- IkiWiki/Plugin/norcs.pm | 8 ++++---- IkiWiki/Plugin/svn.pm | 7 ++++--- IkiWiki/Plugin/tla.pm | 7 ++++--- debian/changelog | 5 ++++- doc/plugins/write.mdwn | 10 ++++++---- 11 files changed, 46 insertions(+), 37 deletions(-) (limited to 'IkiWiki/Plugin/norcs.pm') diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm index 9bee0c4b2..44ab9a86a 100644 --- a/IkiWiki/Plugin/bzr.pm +++ b/IkiWiki/Plugin/bzr.pm @@ -137,8 +137,8 @@ sub bzr_author ($$) { } } -sub rcs_commit ($$$;$$) { - my ($file, $message, $rcstoken, $user, $ipaddr) = @_; +sub rcs_commit ($$$;$$$) { + my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; $user = bzr_author($user, $ipaddr); @@ -156,10 +156,10 @@ sub rcs_commit ($$$;$$) { return undef; # success } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged ($$$;$) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my ($message, $user, $ipaddr, $emailuser)=@_; $user = bzr_author($user, $ipaddr); diff --git a/IkiWiki/Plugin/cvs.pm b/IkiWiki/Plugin/cvs.pm index 18491d517..a9fe162a1 100644 --- a/IkiWiki/Plugin/cvs.pm +++ b/IkiWiki/Plugin/cvs.pm @@ -183,7 +183,7 @@ sub rcs_prepedit ($) { return defined $rev ? $rev : ""; } -sub rcs_commit ($$$;$$) { +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. @@ -192,6 +192,7 @@ sub rcs_commit ($$$;$$) { my $rcstoken=shift; my $user=shift; my $ipaddr=shift; + my $emailuser=shift; return unless cvs_is_controlling; @@ -224,10 +225,10 @@ sub rcs_commit ($$$;$$) { return undef # success } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged ($$$;$) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my ($message, $user, $ipaddr, $emailuser)=@_; if (defined $user) { $message="web commit by $user".(length $message ? ": $message" : ""); diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index f17fadcb1..345456c01 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -140,11 +140,11 @@ sub rcs_prepedit ($) { return $rev; } -sub rcs_commit ($$$;$$) { +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) = @_; + my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; # Compute if the "revision" of $file changed. my $changed = darcs_rev($file) ne $rcstoken; @@ -239,8 +239,8 @@ sub rcs_commit ($$$;$$) { } } -sub rcs_commit_staged ($$$) { - my ($message, $user, $ipaddr) = @_; +sub rcs_commit_staged ($$$;$) { + my ($message, $user, $ipaddr, $emailuser) = @_; my $author; if (defined $user) { diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index a43b85920..b56f229d7 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -464,12 +464,12 @@ sub rcs_prepedit ($) { return git_sha1($file); } -sub rcs_commit ($$$;$$) { +sub rcs_commit ($$$;$$$) { # Try to commit the page; returns undef on _success_ and # a version of the page with the rcs's conflict markers on # failure. - my ($file, $message, $rcstoken, $user, $ipaddr) = @_; + my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; # Check to see if the page has been changed by someone else since # rcs_prepedit was called. @@ -485,10 +485,10 @@ sub rcs_commit ($$$;$$) { return rcs_commit_staged($message, $user, $ipaddr); } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged ($$$;$) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my ($message, $user, $ipaddr, $emailuser)=@_; # Set the commit author and email to the web committer. my %env=%ENV; diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index a80bb2da5..1793ab4bb 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -126,8 +126,8 @@ sub rcs_prepedit ($) { return ""; } -sub rcs_commit ($$$;$$) { - my ($file, $message, $rcstoken, $user, $ipaddr) = @_; +sub rcs_commit ($$$;$$$) { + my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; if (defined $user) { $user = IkiWiki::possibly_foolish_untaint($user); @@ -153,10 +153,10 @@ sub rcs_commit ($$$;$$) { return undef; # success } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged ($$$;$) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my ($message, $user, $ipaddr, $emailuser)=@_; error("rcs_commit_staged not implemented for mercurial"); # TODO } diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index 67d4abbaa..55d8039e0 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -293,7 +293,7 @@ sub rcs_prepedit ($) { return get_rev(); } -sub rcs_commit ($$$;$$) { +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. @@ -302,6 +302,7 @@ sub rcs_commit ($$$;$$) { my $rcstoken=shift; my $user=shift; my $ipaddr=shift; + my $emailuser=shift; my $author; if (defined $user) { @@ -438,10 +439,10 @@ sub rcs_commit ($$$;$$) { return undef # success } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged ($$$;$) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my ($message, $user, $ipaddr, $emailuser)=@_; # Note - this will also commit any spurious changes that happen to be # lying around in the working copy. There shouldn't be any, but... diff --git a/IkiWiki/Plugin/norcs.pm b/IkiWiki/Plugin/norcs.pm index 053652a5f..5131a1502 100644 --- a/IkiWiki/Plugin/norcs.pm +++ b/IkiWiki/Plugin/norcs.pm @@ -38,13 +38,13 @@ sub rcs_prepedit ($) { return "" } -sub rcs_commit ($$$;$$) { - my ($file, $message, $rcstoken, $user, $ipaddr) = @_; +sub rcs_commit ($$$;$$$) { + my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; return undef # success } -sub rcs_commit_staged ($$$) { - my ($message, $user, $ipaddr)=@_; +sub rcs_commit_staged ($$$;$) { + my ($message, $user, $ipaddr, $emailuser)=@_; return undef # success } diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index d10b4888d..ffacb8cf9 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -144,7 +144,7 @@ sub rcs_prepedit ($) { } } -sub rcs_commit ($$$;$$) { +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. @@ -153,6 +153,7 @@ sub rcs_commit ($$$;$$) { my $rcstoken=shift; my $user=shift; my $ipaddr=shift; + my $emailuser=shift; if (defined $user) { $message="web commit by $user".(length $message ? ": $message" : ""); @@ -189,10 +190,10 @@ sub rcs_commit ($$$;$$) { return undef # success } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged ($$$;$) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my ($message, $user, $ipaddr, $emailuser)=@_; if (defined $user) { $message="web commit by $user".(length $message ? ": $message" : ""); diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index f5ad0cc96..80c015e3c 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -98,12 +98,13 @@ sub rcs_prepedit ($) { } } -sub rcs_commit ($$$;$$) { +sub rcs_commit ($$$;$$$) { my $file=shift; my $message=shift; my $rcstoken=shift; my $user=shift; my $ipaddr=shift; + my $emailuser=shift; if (defined $user) { $message="web commit by $user".(length $message ? ": $message" : ""); @@ -139,10 +140,10 @@ sub rcs_commit ($$$;$$) { return undef # success } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged ($$$;$) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my ($message, $user, $ipaddr, $emailuser)=@_; error("rcs_commit_staged not implemented for tla"); # TODO } diff --git a/debian/changelog b/debian/changelog index 01d0abb47..2dfebd0b2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,9 @@ ikiwiki (3.20100624) UNRELEASED; urgency=low - * Add new optional field usershort to rcs_recentchanges. + * API: Add new optional field usershort to rcs_recentchanges. + * API: rcs_commit and rcs_commit_staged are passed a new parameter + that may contain the username component of the email address of + the user making the commit. -- Joey Hess Wed, 23 Jun 2010 15:30:04 -0400 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 5f0e95a9f..ab2934bf1 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1051,15 +1051,17 @@ token, that will be passed into `rcs_commit` when committing. For example, it might return the current revision ID of the file, and use that information later when merging changes. -#### `rcs_commit($$$;$$)` +#### `rcs_commit($$$;$$$)` -Passed a file, message, token (from `rcs_prepedit`), user, and ip address. +Passed a file, message, token (from `rcs_prepedit`), user, ip address, +and optionally the username component of the committer's email address. Should try to commit the file. Returns `undef` on *success* and a version of the page with the rcs's conflict markers on failure. -#### `rcs_commit_staged($$$)` +#### `rcs_commit_staged($$$;$)` -Passed a message, user, and ip address. Should commit all staged changes. +Passed a message, user, ip address, and optionally the username component of +the committer's email address. Should commit all staged changes. Returns undef on success, and an error message on failure. Changes can be staged by calls to `rcs_add`, `rcs_remove`, and -- cgit v1.2.3 From ecdfd1b8644bc926db008054ab6192e18351afed Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 23 Jun 2010 17:35:21 -0400 Subject: rcs_commit and rcs_commit_staged api changes Using named parameters for these is overdue. Passing the session in a parameter instead of passing username and IP separately will later allow storing other session info, like username or part of the email. Note that these functions are not part of the exported API, and the prototype change will catch (most) skew, so I am not changing API versions. Any third-party plugins that call them will need updated though. --- IkiWiki.pm | 4 +- IkiWiki/Plugin/attachment.pm | 10 ++-- IkiWiki/Plugin/autoindex.pm | 4 +- IkiWiki/Plugin/bzr.pm | 43 +++++++++-------- IkiWiki/Plugin/comments.pm | 14 +++--- IkiWiki/Plugin/cvs.pm | 59 ++++++++++++----------- IkiWiki/Plugin/darcs.pm | 75 +++++++++++++++--------------- IkiWiki/Plugin/editpage.pm | 10 ++-- IkiWiki/Plugin/git.pm | 52 +++++++++++++-------- IkiWiki/Plugin/mercurial.pm | 32 ++++++------- IkiWiki/Plugin/monotone.pm | 85 +++++++++++++++------------------- IkiWiki/Plugin/norcs.pm | 6 +-- IkiWiki/Plugin/poll.pm | 10 ++-- IkiWiki/Plugin/remove.pm | 7 +-- IkiWiki/Plugin/rename.pm | 5 +- IkiWiki/Plugin/svn.pm | 59 ++++++++++++----------- IkiWiki/Plugin/tag.pm | 2 +- IkiWiki/Plugin/tla.pm | 34 ++++++++------ debian/changelog | 5 +- doc/plugins/write.mdwn | 16 ++++--- ikiwiki-calendar.in | 2 +- ikiwiki.spec | 2 +- po/ikiwiki.pot | 108 +++++++++++++++++++++---------------------- t/bazaar.t | 25 ++++++++-- t/cvs.t | 6 ++- t/git.t | 12 +++-- t/mercurial.t | 11 ++++- t/svn.t | 6 ++- 28 files changed, 380 insertions(+), 324 deletions(-) (limited to 'IkiWiki/Plugin/norcs.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 203da3ba2..35b38df46 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1840,11 +1840,11 @@ sub rcs_prepedit ($) { $hooks{rcs}{rcs_prepedit}{call}->(@_); } -sub rcs_commit ($$$;$$) { +sub rcs_commit (@) { $hooks{rcs}{rcs_commit}{call}->(@_); } -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged (@) { $hooks{rcs}{rcs_commit_staged}{call}->(@_); } diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index 216e00b3d..ee105a170 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -183,10 +183,12 @@ sub formbuilder (@) { if ($config{rcs}) { IkiWiki::rcs_add($filename); IkiWiki::disable_commit_hook(); - IkiWiki::rcs_commit($filename, gettext("attachment upload"), - IkiWiki::rcs_prepedit($filename), - $session->param("name"), - $session->remote_addr()); + IkiWiki::rcs_commit( + file => $filename, + message => gettext("attachment upload"), + token => IkiWiki::rcs_prepedit($filename), + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } diff --git a/IkiWiki/Plugin/autoindex.pm b/IkiWiki/Plugin/autoindex.pm index c3eb53300..11595e217 100644 --- a/IkiWiki/Plugin/autoindex.pm +++ b/IkiWiki/Plugin/autoindex.pm @@ -117,8 +117,8 @@ sub refresh () { } if ($config{rcs}) { IkiWiki::rcs_commit_staged( - gettext("automatic index generation"), - undef, undef); + message => gettext("automatic index generation"), + ); IkiWiki::enable_commit_hook(); } } diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm index 44ab9a86a..562d5d389 100644 --- a/IkiWiki/Plugin/bzr.pm +++ b/IkiWiki/Plugin/bzr.pm @@ -123,8 +123,13 @@ sub rcs_prepedit ($) { return ""; } -sub bzr_author ($$) { - my ($user, $ipaddr) = @_; +sub bzr_author ($) { + my $session=shift; + + return unless defined $session; + + my $user=$session->param("name"); + my $ipaddr=$session->remote_addr(); if (defined $user) { return IkiWiki::possibly_foolish_untaint($user); @@ -137,18 +142,19 @@ sub bzr_author ($$) { } } -sub rcs_commit ($$$;$$$) { - my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; +sub rcs_commit (@) { + my %params=@_; - $user = bzr_author($user, $ipaddr); + my $user=bzr_author($params{session}); - $message = IkiWiki::possibly_foolish_untaint($message); - if (! length $message) { - $message = "no message given"; + $params{message} = IkiWiki::possibly_foolish_untaint($params{message}); + if (! length $params{message}) { + $params{message} = "no message given"; } - my @cmdline = ("bzr", "commit", "--quiet", "-m", $message, "--author", $user, - $config{srcdir}."/".$file); + my @cmdline = ("bzr", "commit", "--quiet", "-m", $params{message}, + (defined $user ? ("--author", $user) : ()), + $config{srcdir}."/".$params{file}); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } @@ -156,19 +162,18 @@ sub rcs_commit ($$$;$$$) { return undef; # success } -sub rcs_commit_staged ($$$;$) { - # Commits all staged changes. Changes can be staged using rcs_add, - # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr, $emailuser)=@_; +sub rcs_commit_staged (@) { + my %params=@_; - $user = bzr_author($user, $ipaddr); + my $user=bzr_author($params{session}); - $message = IkiWiki::possibly_foolish_untaint($message); - if (! length $message) { - $message = "no message given"; + $params{message} = IkiWiki::possibly_foolish_untaint($params{message}); + if (! length $params{message}) { + $params{message} = "no message given"; } - my @cmdline = ("bzr", "commit", "--quiet", "-m", $message, "--author", $user, + my @cmdline = ("bzr", "commit", "--quiet", "-m", $params{message}, + (defined $user ? ("--author", $user) : ()), $config{srcdir}); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 4770209c9..41c6948e8 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -513,9 +513,10 @@ sub editcomment ($$) { IkiWiki::rcs_add($file); IkiWiki::disable_commit_hook(); - $conflict = IkiWiki::rcs_commit_staged($message, - $session->param('name'), - $session->remote_addr()); + $conflict = IkiWiki::rcs_commit_staged( + message => $message, + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } @@ -603,9 +604,10 @@ sub commentmoderation ($$) { if ($config{rcs} and $config{comments_commit}) { my $message = gettext("Comment moderation"); IkiWiki::disable_commit_hook(); - $conflict=IkiWiki::rcs_commit_staged($message, - $session->param('name'), - $session->remote_addr()); + $conflict=IkiWiki::rcs_commit_staged( + message => $message, + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } diff --git a/IkiWiki/Plugin/cvs.pm b/IkiWiki/Plugin/cvs.pm index a9fe162a1..c6687d780 100644 --- a/IkiWiki/Plugin/cvs.pm +++ b/IkiWiki/Plugin/cvs.pm @@ -183,41 +183,47 @@ sub rcs_prepedit ($) { return defined $rev ? $rev : ""; } -sub rcs_commit ($$$;$$$) { +sub commitmessage (@) { + my %params=@_; + + if (defined $params{session}) { + if (defined $params{session}->param("name")) { + return "web commit by ". + $params{session}->param("name"). + (length $params{message} ? ": $params{message}" : ""); + } + elsif (defined $params{session}->remote_addr()) { + return "web commit from ". + $params{session}->remote_addr(). + (length $params{message} ? ": $params{message}" : ""); + } + } + return $params{message}; +} + +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; - my $user=shift; - my $ipaddr=shift; - my $emailuser=shift; + my %params=@_; return unless cvs_is_controlling; - if (defined $user) { - $message="web commit by $user".(length $message ? ": $message" : ""); - } - elsif (defined $ipaddr) { - $message="web commit from $ipaddr".(length $message ? ": $message" : ""); - } - # 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=cvs_info("Repository revision", "$config{srcdir}/$file"); + my ($oldrev)=$params{token}=~/^([0-9]+)$/; # untaint + my $rev=cvs_info("Repository revision", "$config{srcdir}/$params{file}"); if (defined $rev && defined $oldrev && $rev != $oldrev) { # Merge their changes into the file that we've # changed. - cvs_runcvs('update', $file) || + cvs_runcvs('update', $params{file}) || warn("cvs merge from $oldrev to $rev failed\n"); } if (! cvs_runcvs('commit', '-m', - IkiWiki::possibly_foolish_untaint $message)) { - my $conflict=readfile("$config{srcdir}/$file"); - cvs_runcvs('update', '-C', $file) || + IkiWiki::possibly_foolish_untaint(commitmessage(%params)))) { + my $conflict=readfile("$config{srcdir}/$params{file}"); + cvs_runcvs('update', '-C', $params{file}) || warn("cvs revert failed\n"); return $conflict; } @@ -225,20 +231,13 @@ sub rcs_commit ($$$;$$$) { return undef # success } -sub rcs_commit_staged ($$$;$) { +sub rcs_commit_staged (@) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr, $emailuser)=@_; - - if (defined $user) { - $message="web commit by $user".(length $message ? ": $message" : ""); - } - elsif (defined $ipaddr) { - $message="web commit from $ipaddr".(length $message ? ": $message" : ""); - } + my %params=@_; if (! cvs_runcvs('commit', '-m', - IkiWiki::possibly_foolish_untaint $message)) { + IkiWiki::possibly_foolish_untaint(commitmessage(%params)))) { warn "cvs staged commit failed\n"; return 1; # failure } diff --git a/IkiWiki/Plugin/darcs.pm b/IkiWiki/Plugin/darcs.pm index 345456c01..0dfc8708d 100644 --- a/IkiWiki/Plugin/darcs.pm +++ b/IkiWiki/Plugin/darcs.pm @@ -140,14 +140,31 @@ sub rcs_prepedit ($) { return $rev; } -sub rcs_commit ($$$;$$$) { +sub commitauthor (@) { + my %params=@_; + + my $author="anon\@web"; + if (defined $params{session}) { + if (defined $params{session}->param("name")) { + return $params{session}->param("name").'@web'; + } + elsif (defined $params{session}->remote_addr()) { + return $params{session}->remote_addr().'@web'; + } + } + return 'anon@web'; +} + +sub rcs_commit (@) { # Commit the page. Returns 'undef' on success and a version of the page # with conflict markers on failure. + my %params=@_; - my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; + my ($file, $message, $token) = + ($params{file}, $params{message}, $params{token}); # Compute if the "revision" of $file changed. - my $changed = darcs_rev($file) ne $rcstoken; + my $changed = darcs_rev($file) ne $token; # Yes, the following is a bit convoluted. if ($changed) { @@ -155,7 +172,7 @@ sub rcs_commit ($$$;$$$) { rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or error("failed to rename $file to $file.save: $!"); - # Roll the repository back to $rcstoken. + # Roll the repository back to $token. # 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 @@ -166,37 +183,28 @@ sub rcs_commit ($$$;$$$) { # 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. + # Remove all patches starting at $token. my $child = open(DARCS_OBLITERATE, "|-"); if (! $child) { open(STDOUT, ">/dev/null"); exec('darcs', "obliterate", "--repodir", $config{srcdir}, - "--match", "hash " . $rcstoken) and + "--match", "hash " . $token) and error("'darcs obliterate' failed"); } 1 while print DARCS_OBLITERATE "y"; close(DARCS_OBLITERATE); - # Restore the $rcstoken one. + # Restore the $token one. silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir}, - "--match", "hash " . $rcstoken, "--all") == 0 || + "--match", "hash " . $token, "--all") == 0 || error("'darcs pull' failed"); - # We're back at $rcstoken. Re-install the modified file. + # We're back at $token. 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"; - } + my $author=commitauthor(%params); if (!defined $message || !length($message)) { $message = "empty message"; } @@ -211,13 +219,13 @@ sub rcs_commit ($$$;$$$) { # 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); + $token = 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) == 0 || error("'darcs record' failed"); - my $conflicts = darcs_rev($file) ne $rcstoken; + my $conflicts = darcs_rev($file) ne $token; unlink("$config{srcdir}/$file.log") or error("failed to remove '$file.log'"); @@ -239,25 +247,18 @@ sub rcs_commit ($$$;$$$) { } } -sub rcs_commit_staged ($$$;$) { - my ($message, $user, $ipaddr, $emailuser) = @_; +sub rcs_commit_staged (@) { + my %params=@_; - 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"; + my $author=commitauthor(%params); + if (!defined $params{message} || !length($params{message})) { + $params{message} = "empty message"; } - silentsystem('darcs', "record", "--repodir", $config{srcdir}, "-a", "-A", $author, - "-m", $message) == 0 || error("'darcs record' failed"); + silentsystem('darcs', "record", "--repodir", $config{srcdir}, + "-a", "-A", $author, + "-m", $params{message}, + ) == 0 || error("'darcs record' failed"); # Push the changes to the main repository. silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') == 0 || diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index a8e75121f..1a04a72b5 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -401,10 +401,12 @@ sub cgi_editpage ($$) { # signaling to it that it should not try to # do anything. disable_commit_hook(); - $conflict=rcs_commit($file, $message, - $form->field("rcsinfo"), - $session->param("name"), - $session->remote_addr()); + $conflict=rcs_commit( + file => $file, + message => $message, + token => $form->field("rcsinfo"), + session => $session, + ); enable_commit_hook(); rcs_update(); } diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index b56f229d7..b02fc118d 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -464,43 +464,55 @@ sub rcs_prepedit ($) { return git_sha1($file); } -sub rcs_commit ($$$;$$$) { +sub rcs_commit (@) { # Try to commit the page; returns undef on _success_ and # a version of the page with the rcs's conflict markers on # failure. - - my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; + my %params=@_; # Check to see if the page has been changed by someone else since # rcs_prepedit was called. - my $cur = git_sha1($file); - my ($prev) = $rcstoken =~ /^($sha1_pattern)$/; # untaint + my $cur = git_sha1($params{file}); + my ($prev) = $params{token} =~ /^($sha1_pattern)$/; # untaint if (defined $cur && defined $prev && $cur ne $prev) { - my $conflict = merge_past($prev, $file, $dummy_commit_msg); + my $conflict = merge_past($prev, $params{file}, $dummy_commit_msg); return $conflict if defined $conflict; } - rcs_add($file); - return rcs_commit_staged($message, $user, $ipaddr); + rcs_add($params{file}); + return rcs_commit_staged( + message => $params{message}, + session => $params{session}, + ); } -sub rcs_commit_staged ($$$;$) { +sub rcs_commit_staged (@) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr, $emailuser)=@_; - - # Set the commit author and email to the web committer. + my %params=@_; + my %env=%ENV; - if (defined $user || defined $ipaddr) { - my $u=encode_utf8(defined $user ? $user : $ipaddr); - $ENV{GIT_AUTHOR_NAME}=$u; - $ENV{GIT_AUTHOR_EMAIL}="$u\@web"; + + if (defined $params{session}) { + # Set the commit author and email based on web session info. + my $u; + if (defined $params{session}->param("name")) { + $u=$params{session}->param("name"); + } + elsif (defined $params{session}->remote_addr()) { + $u=$params{session}->remote_addr(); + } + if (defined $u) { + $u=encode_utf8($u); + $ENV{GIT_AUTHOR_NAME}=$u; + $ENV{GIT_AUTHOR_EMAIL}="$u\@web"; + } } - $message = IkiWiki::possibly_foolish_untaint($message); + $params{message} = IkiWiki::possibly_foolish_untaint($params{message}); my @opts; - if ($message !~ /\S/) { + if ($params{message} !~ /\S/) { # Force git to allow empty commit messages. # (If this version of git supports it.) my ($version)=`git --version` =~ /git version (.*)/; @@ -508,13 +520,13 @@ sub rcs_commit_staged ($$$;$) { push @opts, '--cleanup=verbatim'; } else { - $message.="."; + $params{message}.="."; } } push @opts, '-q'; # git commit returns non-zero if file has not been really changed. # so we should ignore its exit status (hence run_or_non). - if (run_or_non('git', 'commit', @opts, '-m', $message)) { + if (run_or_non('git', 'commit', @opts, '-m', $params{message})) { if (length $config{gitorigin_branch}) { run_or_cry('git', 'push', $config{gitorigin_branch}); } diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index 1793ab4bb..edf915ae9 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -126,26 +126,26 @@ sub rcs_prepedit ($) { return ""; } -sub rcs_commit ($$$;$$$) { - my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; +sub rcs_commit (@) { + my %params=@_; - if (defined $user) { - $user = IkiWiki::possibly_foolish_untaint($user); - } - elsif (defined $ipaddr) { - $user = "Anonymous from ".IkiWiki::possibly_foolish_untaint($ipaddr); - } - else { - $user = "Anonymous"; + my $user="Anonymous"; + if (defined $params{session}) { + if (defined $params{session}->param("name")) { + $user = $params{session}->param("name"); + } + elsif (defined $params{session}->remote_addr()) { + $user = "Anonymous from ".$params{session}->remote_addr(); + } } - $message = IkiWiki::possibly_foolish_untaint($message); - if (! length $message) { - $message = "no message given"; + if (! length $params{message}) { + $params{message} = "no message given"; } my @cmdline = ("hg", "-q", "-R", $config{srcdir}, "commit", - "-m", $message, "-u", $user); + "-m", IkiWiki::possibly_foolish_untaint($params{message}), + "-u", IkiWiki::possibly_foolish_untaint($user)); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } @@ -153,10 +153,10 @@ sub rcs_commit ($$$;$$$) { return undef; # success } -sub rcs_commit_staged ($$$;$) { +sub rcs_commit_staged (@) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr, $emailuser)=@_; + my %params=@_; error("rcs_commit_staged not implemented for mercurial"); # TODO } diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index 55d8039e0..95fbcee76 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -293,32 +293,33 @@ sub rcs_prepedit ($) { return get_rev(); } -sub rcs_commit ($$$;$$$) { +sub commitauthor (@) { + my %params=@_; + + if (defined $params{session}) { + if (defined $params{session}->param("name")) { + return "Web user: " . $params{session}->param("name"); + } + elsif (defined $params{session}->remote_addr()) { + return "Web IP: " . $params{session}->remote_addr(); + } + } + return "Web: Anonymous"; +} + + +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; - my $user=shift; - my $ipaddr=shift; - my $emailuser=shift; - my $author; + my %params=@_; - if (defined $user) { - $author="Web user: " . $user; - } - elsif (defined $ipaddr) { - $author="Web IP: " . $ipaddr; - } - else { - $author="Web: Anonymous"; - } + my $author=IkiWiki::possibly_foolish_untaint(commitauthor(%params)), chdir $config{srcdir} or error("Cannot chdir to $config{srcdir}: $!"); - my ($oldrev)= $rcstoken=~ m/^($sha1_pattern)$/; # untaint + my ($oldrev) = $params{token} =~ m/^($sha1_pattern)$/; # untaint my $rev = get_rev(); if (defined $rev && defined $oldrev && $rev ne $oldrev) { my $automator = Monotone->new(); @@ -327,8 +328,8 @@ sub rcs_commit ($$$;$$$) { # Something has been committed, has this file changed? my ($out, $err); $automator->setOpts("r", $oldrev, "r", $rev); - ($out, $err) = $automator->call("content_diff", $file); - debug("Problem committing $file") if ($err ne ""); + ($out, $err) = $automator->call("content_diff", $params{file}); + debug("Problem committing $params{file}") if ($err ne ""); my $diff = $out; if ($diff) { @@ -337,11 +338,11 @@ sub rcs_commit ($$$;$$$) { # # first get the contents debug("File changed: forming branch"); - my $newfile=readfile("$config{srcdir}/$file"); + my $newfile=readfile("$config{srcdir}/$params{file}"); # then get the old content ID from the diff - if ($diff !~ m/^---\s$file\s+($sha1_pattern)$/m) { - error("Unable to find previous file ID for $file"); + if ($diff !~ m/^---\s$params{file}\s+($sha1_pattern)$/m) { + error("Unable to find previous file ID for $params{file}"); } my $oldFileID = $1; @@ -352,13 +353,13 @@ sub rcs_commit ($$$;$$$) { my $branch = $1; # then put the new content into the DB (and record the new content ID) - my $newRevID = commit_file_to_new_rev($automator, $file, $oldFileID, $newfile, $oldrev, $branch, $author, $message); + my $newRevID = commit_file_to_new_rev($automator, $params{file}, $oldFileID, $newfile, $oldrev, $branch, $author, $params{message}); $automator->close(); # if we made it to here then the file has been committed... revert the local copy - if (system("mtn", "--root=$config{mtnrootdir}", "revert", $file) != 0) { - debug("Unable to revert $file after merge on conflicted commit!"); + if (system("mtn", "--root=$config{mtnrootdir}", "revert", $params{file}) != 0) { + debug("Unable to revert $params{file} after merge on conflicted commit!"); } debug("Divergence created! Attempting auto-merge."); @@ -407,7 +408,7 @@ sub rcs_commit ($$$;$$$) { # for cleanup note, this relies on the fact # that ikiwiki seems to call rcs_prepedit() # again after we return - return readfile("$config{srcdir}/$file"); + return readfile("$config{srcdir}/$params{file}"); } return undef; } @@ -419,11 +420,12 @@ sub rcs_commit ($$$;$$$) { if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet", "--author", $author, "--key", $config{mtnkey}, "-m", - IkiWiki::possibly_foolish_untaint($message), $file) != 0) { + IkiWiki::possibly_foolish_untaint($params{message}), + $params{file}) != 0) { debug("Traditional commit failed! Returning data as conflict."); - my $conflict=readfile("$config{srcdir}/$file"); + my $conflict=readfile("$config{srcdir}/$params{file}"); if (system("mtn", "--root=$config{mtnrootdir}", "revert", - "--quiet", $file) != 0) { + "--quiet", $params{file}) != 0) { debug("monotone revert failed"); } return $conflict; @@ -439,32 +441,21 @@ sub rcs_commit ($$$;$$$) { return undef # success } -sub rcs_commit_staged ($$$;$) { +sub rcs_commit_staged (@) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr, $emailuser)=@_; - + my %params=@_; + # Note - this will also commit any spurious changes that happen to be # lying around in the working copy. There shouldn't be any, but... chdir $config{srcdir} or error("Cannot chdir to $config{srcdir}: $!"); - my $author; - - if (defined $user) { - $author="Web user: " . $user; - } - elsif (defined $ipaddr) { - $author="Web IP: " . $ipaddr; - } - else { - $author="Web: Anonymous"; - } - if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet", - "--author", $author, "--key", $config{mtnkey}, "-m", - IkiWiki::possibly_foolish_untaint($message)) != 0) { + "--author", IkiWiki::possibly_foolish_untaint(commitauthor(%params)), + "--key", $config{mtnkey}, "-m", + IkiWiki::possibly_foolish_untaint($params{message})) != 0) { error("Monotone commit failed"); } } diff --git a/IkiWiki/Plugin/norcs.pm b/IkiWiki/Plugin/norcs.pm index 5131a1502..a3bb6240e 100644 --- a/IkiWiki/Plugin/norcs.pm +++ b/IkiWiki/Plugin/norcs.pm @@ -38,13 +38,11 @@ sub rcs_prepedit ($) { return "" } -sub rcs_commit ($$$;$$$) { - my ($file, $message, $rcstoken, $user, $ipaddr, $emailuser) = @_; +sub rcs_commit (@) { return undef # success } -sub rcs_commit_staged ($$$;$) { - my ($message, $user, $ipaddr, $emailuser)=@_; +sub rcs_commit_staged (@) { return undef # success } diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm index e50efa5e0..b333e2cdc 100644 --- a/IkiWiki/Plugin/poll.pm +++ b/IkiWiki/Plugin/poll.pm @@ -134,10 +134,12 @@ sub sessioncgi ($$) { $oldchoice=$session->param($choice_param); if ($config{rcs}) { IkiWiki::disable_commit_hook(); - IkiWiki::rcs_commit($pagesources{$page}, "poll vote ($choice)", - IkiWiki::rcs_prepedit($pagesources{$page}), - $session->param("name"), - $session->remote_addr()); + IkiWiki::rcs_commit( + file => $pagesources{$page}, + message => "poll vote ($choice)", + token => IkiWiki::rcs_prepedit($pagesources{$page}), + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index b664cbf74..95f148183 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -213,9 +213,10 @@ sub sessioncgi ($$) { foreach my $file (@files) { IkiWiki::rcs_remove($file); } - IkiWiki::rcs_commit_staged(gettext("removed"), - $session->param("name"), - $session->remote_addr()); + IkiWiki::rcs_commit_staged( + message => gettext("removed"), + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index 977c09e67..61d39d4b5 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -349,9 +349,8 @@ sub sessioncgi ($$) { $pagesources{$rename->{src}}=$rename->{destfile}; } IkiWiki::rcs_commit_staged( - sprintf(gettext("rename %s to %s"), $srcfile, $destfile), - $session->param("name"), - $session->remote_addr(), + message => sprintf(gettext("rename %s to %s"), $srcfile, $destfile), + session => $session, ) if $config{rcs}; # Then link fixups. diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index ffacb8cf9..f1e608408 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -144,44 +144,50 @@ sub rcs_prepedit ($) { } } -sub rcs_commit ($$$;$$$) { +sub commitmessage (@) { + my %params=@_; + + if (defined $params{session}) { + if (defined $params{session}->param("name")) { + return "web commit by ". + $params{session}->param("name"). + (length $params{message} ? ": $params{message}" : ""); + } + elsif (defined $params{session}->remote_addr()) { + return "web commit from ". + $params{session}->remote_addr(). + (length $params{message} ? ": $params{message}" : ""); + } + } + return $params{message}; +} + +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; - my $user=shift; - my $ipaddr=shift; - my $emailuser=shift; - - if (defined $user) { - $message="web commit by $user".(length $message ? ": $message" : ""); - } - elsif (defined $ipaddr) { - $message="web commit from $ipaddr".(length $message ? ": $message" : ""); - } + my %params=@_; 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"); + my ($oldrev)=$params{token}=~/^([0-9]+)$/; # untaint + my $rev=svn_info("Revision", "$config{srcdir}/$params{file}"); if (defined $rev && defined $oldrev && $rev != $oldrev) { # Merge their changes into the file that we've # changed. if (system("svn", "merge", "--quiet", "-r$oldrev:$rev", - "$config{srcdir}/$file", "$config{srcdir}/$file") != 0) { + "$config{srcdir}/$params{file}", "$config{srcdir}/$params{file}") != 0) { warn("svn merge -r$oldrev:$rev failed\n"); } } if (system("svn", "commit", "--quiet", "--encoding", "UTF-8", "-m", - IkiWiki::possibly_foolish_untaint($message), + IkiWiki::possibly_foolish_untaint(commitmessage(%params)), $config{srcdir}) != 0) { - my $conflict=readfile("$config{srcdir}/$file"); - if (system("svn", "revert", "--quiet", "$config{srcdir}/$file") != 0) { + my $conflict=readfile("$config{srcdir}/$params{file}"); + if (system("svn", "revert", "--quiet", "$config{srcdir}/$params{file}") != 0) { warn("svn revert failed\n"); } return $conflict; @@ -190,21 +196,14 @@ sub rcs_commit ($$$;$$$) { return undef # success } -sub rcs_commit_staged ($$$;$) { +sub rcs_commit_staged (@) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr, $emailuser)=@_; - - if (defined $user) { - $message="web commit by $user".(length $message ? ": $message" : ""); - } - elsif (defined $ipaddr) { - $message="web commit from $ipaddr".(length $message ? ": $message" : ""); - } + my %params=@_; if (system("svn", "commit", "--quiet", "--encoding", "UTF-8", "-m", - IkiWiki::possibly_foolish_untaint($message), + IkiWiki::possibly_foolish_untaint(commitmessage(%params)), $config{srcdir}) != 0) { warn("svn commit failed\n"); return 1; # failure diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index 62f030f4e..55064a9a3 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -90,7 +90,7 @@ sub gentag ($) { if ($config{rcs}) { IkiWiki::disable_commit_hook(); IkiWiki::rcs_add($tagfile); - IkiWiki::rcs_commit_staged($message, undef, undef); + IkiWiki::rcs_commit_staged(message => $message); IkiWiki::enable_commit_hook(); } }); diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index 80c015e3c..da4385446 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -98,19 +98,23 @@ sub rcs_prepedit ($) { } } -sub rcs_commit ($$$;$$$) { - my $file=shift; - my $message=shift; - my $rcstoken=shift; - my $user=shift; - my $ipaddr=shift; - my $emailuser=shift; - - if (defined $user) { - $message="web commit by $user".(length $message ? ": $message" : ""); - } - elsif (defined $ipaddr) { - $message="web commit from $ipaddr".(length $message ? ": $message" : ""); +sub rcs_commit (@) { + my %params=@_; + + my ($file, $message, $rcstoken)= + ($params{file}, $params{message}, $params{token}); + + if (defined $params{session}) { + if (defined $params{session}->param("name")) { + $message="web commit by ". + $params{session}->param("name"). + (length $message ? ": $message" : ""); + } + elsif (defined $params{session}->remote_addr()) { + $message="web commit from ". + $params{session}->remote_addr(). + (length $message ? ": $message" : ""); + } } if (-d "$config{srcdir}/{arch}") { @@ -140,10 +144,10 @@ sub rcs_commit ($$$;$$$) { return undef # success } -sub rcs_commit_staged ($$$;$) { +sub rcs_commit_staged (@) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr, $emailuser)=@_; + my %params=@_; error("rcs_commit_staged not implemented for tla"); # TODO } diff --git a/debian/changelog b/debian/changelog index 2dfebd0b2..f7452a070 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,8 @@ ikiwiki (3.20100624) UNRELEASED; urgency=low * API: Add new optional field usershort to rcs_recentchanges. - * API: rcs_commit and rcs_commit_staged are passed a new parameter - that may contain the username component of the email address of - the user making the commit. + * API: rcs_commit and rcs_commit_staged are now passed named + parameters. -- Joey Hess Wed, 23 Jun 2010 15:30:04 -0400 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index ab2934bf1..a2b954bd4 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1051,18 +1051,20 @@ token, that will be passed into `rcs_commit` when committing. For example, it might return the current revision ID of the file, and use that information later when merging changes. -#### `rcs_commit($$$;$$$)` +#### `rcs_commit(@)` + +Passed named parameters: `file`, `message`, `token` (from `rcs_prepedit`), +and `session` (optional). -Passed a file, message, token (from `rcs_prepedit`), user, ip address, -and optionally the username component of the committer's email address. Should try to commit the file. Returns `undef` on *success* and a version of the page with the rcs's conflict markers on failure. -#### `rcs_commit_staged($$$;$)` +#### `rcs_commit_staged(@)` + +Passed named parameters: `message`, and `session` (optional). -Passed a message, user, ip address, and optionally the username component of -the committer's email address. Should commit all staged changes. -Returns undef on success, and an error message on failure. +Should commit all staged changes. Returns undef on success, and an +error message on failure. Changes can be staged by calls to `rcs_add`, `rcs_remove`, and `rcs_rename`. diff --git a/ikiwiki-calendar.in b/ikiwiki-calendar.in index 04352b970..60df99855 100755 --- a/ikiwiki-calendar.in +++ b/ikiwiki-calendar.in @@ -59,7 +59,7 @@ foreach my $y ($startyear..$endyear) { } } -IkiWiki::rcs_commit_staged(gettext("calendar update"), undef, undef) +IkiWiki::rcs_commit_staged(message => gettext("calendar update")) if $config{rcs}; exec("ikiwiki", "-setup", $setup, "-refresh"); diff --git a/ikiwiki.spec b/ikiwiki.spec index 9a4bbf6bc..9644fd396 100644 --- a/ikiwiki.spec +++ b/ikiwiki.spec @@ -1,5 +1,5 @@ Name: ikiwiki -Version: 3.20100623 +Version: 3.20100624 Release: 1%{?dist} Summary: A wiki compiler diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 437cdbdcc..e50fa0f68 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: 2010-06-10 15:02-0400\n" +"POT-Creation-Date: 2010-06-23 17:10-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -52,7 +52,7 @@ msgstr "" msgid "You are banned." msgstr "" -#: ../IkiWiki/CGI.pm:426 ../IkiWiki/CGI.pm:427 ../IkiWiki.pm:1316 +#: ../IkiWiki/CGI.pm:426 ../IkiWiki/CGI.pm:427 ../IkiWiki.pm:1317 msgid "Error" msgstr "" @@ -163,19 +163,19 @@ msgstr "" msgid "prohibited by allowed_attachments" msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:141 +#: ../IkiWiki/Plugin/attachment.pm:144 msgid "bad attachment filename" msgstr "" -#: ../IkiWiki/Plugin/attachment.pm:183 +#: ../IkiWiki/Plugin/attachment.pm:188 msgid "attachment upload" msgstr "" -#: ../IkiWiki/Plugin/autoindex.pm:117 +#: ../IkiWiki/Plugin/autoindex.pm:120 msgid "automatic index generation" msgstr "" -#: ../IkiWiki/Plugin/blogspam.pm:109 +#: ../IkiWiki/Plugin/blogspam.pm:110 msgid "" "Sorry, but that looks like spam to blogspam: " @@ -248,19 +248,19 @@ msgstr "" msgid "Added a comment: %s" msgstr "" -#: ../IkiWiki/Plugin/comments.pm:552 ../IkiWiki/Plugin/websetup.pm:272 +#: ../IkiWiki/Plugin/comments.pm:554 ../IkiWiki/Plugin/websetup.pm:268 msgid "you are not logged in as an admin" msgstr "" -#: ../IkiWiki/Plugin/comments.pm:603 +#: ../IkiWiki/Plugin/comments.pm:605 msgid "Comment moderation" msgstr "" -#: ../IkiWiki/Plugin/comments.pm:641 +#: ../IkiWiki/Plugin/comments.pm:645 msgid "comment moderation" msgstr "" -#: ../IkiWiki/Plugin/comments.pm:790 +#: ../IkiWiki/Plugin/comments.pm:802 #, perl-format msgid "%i comment" msgid_plural "%i comments" @@ -270,7 +270,7 @@ msgstr[1] "" #. translators: Here "Comment" is a verb; #. translators: the user clicks on it to #. translators: post a comment. -#: ../IkiWiki/Plugin/comments.pm:800 +#: ../IkiWiki/Plugin/comments.pm:812 msgid "Comment" msgstr "" @@ -305,9 +305,9 @@ msgstr "" msgid "creating %s" msgstr "" -#: ../IkiWiki/Plugin/editpage.pm:312 ../IkiWiki/Plugin/editpage.pm:334 -#: ../IkiWiki/Plugin/editpage.pm:345 ../IkiWiki/Plugin/editpage.pm:390 -#: ../IkiWiki/Plugin/editpage.pm:429 +#: ../IkiWiki/Plugin/editpage.pm:312 ../IkiWiki/Plugin/editpage.pm:332 +#: ../IkiWiki/Plugin/editpage.pm:343 ../IkiWiki/Plugin/editpage.pm:388 +#: ../IkiWiki/Plugin/editpage.pm:430 #, perl-format msgid "editing %s" msgstr "" @@ -320,12 +320,12 @@ msgstr "" msgid "match not specified" msgstr "" -#: ../IkiWiki/Plugin/edittemplate.pm:64 +#: ../IkiWiki/Plugin/edittemplate.pm:70 #, perl-format msgid "edittemplate %s registered for %s" msgstr "" -#: ../IkiWiki/Plugin/edittemplate.pm:125 ../IkiWiki/Plugin/inline.pm:339 +#: ../IkiWiki/Plugin/edittemplate.pm:131 ../IkiWiki/Plugin/inline.pm:339 #: ../IkiWiki/Plugin/template.pm:44 msgid "failed to process template:" msgstr "" @@ -356,18 +356,18 @@ msgstr "" msgid "%s is an attachment, not a page." msgstr "" -#: ../IkiWiki/Plugin/git.pm:687 ../IkiWiki/Plugin/git.pm:705 -#: ../IkiWiki/Receive.pm:130 +#: ../IkiWiki/Plugin/git.pm:724 ../IkiWiki/Plugin/git.pm:742 +#: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:727 +#: ../IkiWiki/Plugin/git.pm:764 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:731 +#: ../IkiWiki/Plugin/git.pm:768 msgid "you are not allowed to change file modes" msgstr "" @@ -513,7 +513,7 @@ msgstr "" msgid "more" msgstr "" -#: ../IkiWiki/Plugin/openid.pm:58 +#: ../IkiWiki/Plugin/openid.pm:70 #, perl-format msgid "failed to load openid module: " msgstr "" @@ -610,7 +610,7 @@ msgstr "" msgid "rebuilding all pages to fix meta titles" msgstr "" -#: ../IkiWiki/Plugin/po.pm:394 ../IkiWiki/Render.pm:769 +#: ../IkiWiki/Plugin/po.pm:394 ../IkiWiki/Render.pm:784 #, perl-format msgid "building %s" msgstr "" @@ -619,48 +619,48 @@ msgstr "" msgid "updated PO files" msgstr "" -#: ../IkiWiki/Plugin/po.pm:456 +#: ../IkiWiki/Plugin/po.pm:455 msgid "" "Can not remove a translation. If the master page is removed, however, its " "translations will be removed as well." msgstr "" -#: ../IkiWiki/Plugin/po.pm:476 +#: ../IkiWiki/Plugin/po.pm:475 msgid "" "Can not rename a translation. If the master page is renamed, however, its " "translations will be renamed as well." msgstr "" -#: ../IkiWiki/Plugin/po.pm:876 +#: ../IkiWiki/Plugin/po.pm:875 #, perl-format msgid "POT file (%s) does not exist" msgstr "" -#: ../IkiWiki/Plugin/po.pm:890 +#: ../IkiWiki/Plugin/po.pm:889 #, perl-format msgid "failed to copy underlay PO file to %s" msgstr "" -#: ../IkiWiki/Plugin/po.pm:899 +#: ../IkiWiki/Plugin/po.pm:898 #, perl-format msgid "failed to update %s" msgstr "" -#: ../IkiWiki/Plugin/po.pm:905 +#: ../IkiWiki/Plugin/po.pm:904 #, perl-format msgid "failed to copy the POT file to %s" msgstr "" -#: ../IkiWiki/Plugin/po.pm:941 +#: ../IkiWiki/Plugin/po.pm:940 msgid "N/A" msgstr "" -#: ../IkiWiki/Plugin/po.pm:954 +#: ../IkiWiki/Plugin/po.pm:953 #, perl-format msgid "failed to translate %s" msgstr "" -#: ../IkiWiki/Plugin/po.pm:1038 +#: ../IkiWiki/Plugin/po.pm:1037 msgid "removed obsolete PO files" msgstr "" @@ -803,7 +803,7 @@ msgstr "" msgid "Please select the attachments to remove." msgstr "" -#: ../IkiWiki/Plugin/remove.pm:216 +#: ../IkiWiki/Plugin/remove.pm:217 msgid "removed" msgstr "" @@ -853,7 +853,7 @@ msgstr "" msgid "rename %s to %s" msgstr "" -#: ../IkiWiki/Plugin/rename.pm:576 +#: ../IkiWiki/Plugin/rename.pm:577 #, perl-format msgid "update for rename of %s to %s" msgstr "" @@ -988,26 +988,26 @@ msgstr "" msgid "enable %s?" msgstr "" -#: ../IkiWiki/Plugin/websetup.pm:276 +#: ../IkiWiki/Plugin/websetup.pm:272 msgid "setup file for this wiki is not known" msgstr "" -#: ../IkiWiki/Plugin/websetup.pm:292 +#: ../IkiWiki/Plugin/websetup.pm:288 msgid "main" msgstr "" -#: ../IkiWiki/Plugin/websetup.pm:435 +#: ../IkiWiki/Plugin/websetup.pm:431 msgid "" "The configuration changes shown below require a wiki rebuild to take effect." msgstr "" -#: ../IkiWiki/Plugin/websetup.pm:439 +#: ../IkiWiki/Plugin/websetup.pm:435 msgid "" "For the configuration changes shown below to fully take effect, you may need " "to rebuild the wiki." msgstr "" -#: ../IkiWiki/Plugin/websetup.pm:476 +#: ../IkiWiki/Plugin/websetup.pm:472 #, perl-format msgid "Error: %s exited nonzero (%s). Discarding setup changes." msgstr "" @@ -1017,7 +1017,7 @@ msgstr "" msgid "cannot determine id of untrusted committer %s" msgstr "" -#: ../IkiWiki/Receive.pm:86 +#: ../IkiWiki/Receive.pm:85 #, perl-format msgid "bad file name %s" msgstr "" @@ -1034,47 +1034,47 @@ msgid "" "allow this" msgstr "" -#: ../IkiWiki/Render.pm:311 +#: ../IkiWiki/Render.pm:316 #, perl-format msgid "skipping bad filename %s" msgstr "" -#: ../IkiWiki/Render.pm:327 +#: ../IkiWiki/Render.pm:332 #, perl-format msgid "%s has multiple possible source pages" msgstr "" -#: ../IkiWiki/Render.pm:369 +#: ../IkiWiki/Render.pm:372 #, perl-format msgid "querying %s for file creation and modification times.." msgstr "" -#: ../IkiWiki/Render.pm:431 +#: ../IkiWiki/Render.pm:446 #, perl-format msgid "removing obsolete %s" msgstr "" -#: ../IkiWiki/Render.pm:505 +#: ../IkiWiki/Render.pm:520 #, perl-format msgid "building %s, which links to %s" msgstr "" -#: ../IkiWiki/Render.pm:514 +#: ../IkiWiki/Render.pm:529 #, perl-format msgid "removing %s, no longer built by %s" msgstr "" -#: ../IkiWiki/Render.pm:597 ../IkiWiki/Render.pm:679 +#: ../IkiWiki/Render.pm:612 ../IkiWiki/Render.pm:694 #, perl-format msgid "building %s, which depends on %s" msgstr "" -#: ../IkiWiki/Render.pm:692 +#: ../IkiWiki/Render.pm:707 #, perl-format msgid "building %s, to update its backlinks" msgstr "" -#: ../IkiWiki/Render.pm:821 +#: ../IkiWiki/Render.pm:836 #, perl-format msgid "ikiwiki: cannot build %s" msgstr "" @@ -1179,31 +1179,31 @@ msgstr "" msgid "cannot use multiple rcs plugins" msgstr "" -#: ../IkiWiki.pm:606 +#: ../IkiWiki.pm:607 #, perl-format msgid "failed to load external plugin needed for %s plugin: %s" msgstr "" -#: ../IkiWiki.pm:1298 +#: ../IkiWiki.pm:1299 #, perl-format msgid "preprocessing loop detected on %s at depth %i" msgstr "" -#: ../IkiWiki.pm:1993 +#: ../IkiWiki.pm:1994 msgid "yes" msgstr "" -#: ../IkiWiki.pm:2070 +#: ../IkiWiki.pm:2071 #, perl-format msgid "invalid sort type %s" msgstr "" -#: ../IkiWiki.pm:2091 +#: ../IkiWiki.pm:2092 #, perl-format msgid "unknown sort type %s" msgstr "" -#: ../IkiWiki.pm:2227 +#: ../IkiWiki.pm:2228 #, perl-format msgid "cannot match pages: %s" msgstr "" diff --git a/t/bazaar.t b/t/bazaar.t index 0bdd883d5..3e54ec4dc 100755 --- a/t/bazaar.t +++ b/t/bazaar.t @@ -24,11 +24,19 @@ IkiWiki::checkconfig(); system "bzr init $config{srcdir}"; +use CGI::Session; +my $session=CGI::Session->new; +$session->param("name", "Joe User"); + # Web commit my $test1 = readfile("t/test1.mdwn"); writefile('test1.mdwn', $config{srcdir}, $test1); IkiWiki::rcs_add("test1.mdwn"); -IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo", "Joe User"); +IkiWiki::rcs_commit( + file => "test1.mdwn", + message => "Added the first page", + token => "moo", + session => $session); my @changes; @changes = IkiWiki::rcs_recentchanges(3); @@ -66,7 +74,10 @@ ok($mtime >= time() - 20); writefile('test3.mdwn', $config{srcdir}, $test1); IkiWiki::rcs_add("test3.mdwn"); IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn"); -IkiWiki::rcs_commit_staged("Added the 4th page", "moo", "Joe User"); +IkiWiki::rcs_commit_staged( + message => "Added the 4th page", + session => $session, +); @changes = IkiWiki::rcs_recentchanges(4); @@ -75,7 +86,10 @@ is($changes[0]{pages}[0]{"page"}, "test4"); ok(mkdir($config{srcdir}."/newdir")); IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn"); -IkiWiki::rcs_commit_staged("Added the 5th page", "moo", "Joe User"); +IkiWiki::rcs_commit_staged( + message => "Added the 5th page", + session => $session, +); @changes = IkiWiki::rcs_recentchanges(4); @@ -83,6 +97,9 @@ is($#changes, 3); is($changes[0]{pages}[0]{"page"}, "newdir/test5"); IkiWiki::rcs_remove("newdir/test5.mdwn"); -IkiWiki::rcs_commit_staged("Remove the 5th page", "moo", "Joe User"); +IkiWiki::rcs_commit_staged( + message => "Remove the 5th page", + session => $session, +); system "rm -rf $dir"; diff --git a/t/cvs.t b/t/cvs.t index 2808973be..96359ab6e 100755 --- a/t/cvs.t +++ b/t/cvs.t @@ -46,7 +46,11 @@ system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null"; my $test1 = readfile("t/test1.mdwn"); writefile('test1.mdwn', $config{srcdir}, $test1); IkiWiki::rcs_add("test1.mdwn"); -IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo"); +IkiWiki::rcs_commit( + files => "test1.mdwn", + message => "Added the first page", + token => "moo" +); my @changes; @changes = IkiWiki::rcs_recentchanges(3); diff --git a/t/git.t b/t/git.t index f1c24b359..ee778ebf0 100755 --- a/t/git.t +++ b/t/git.t @@ -38,7 +38,11 @@ is($changes[0]{pages}[0]{"page"}, ".gitignore"); my $test1 = readfile("t/test1.mdwn"); writefile('test1.mdwn', $config{srcdir}, $test1); IkiWiki::rcs_add("test1.mdwn"); -IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo"); +IkiWiki::rcs_commit( + file => "test1.mdwn", + message => "Added the first page", + token => "moo", +); @changes = IkiWiki::rcs_recentchanges(3); @@ -68,7 +72,7 @@ is($changes[1]{pages}[0]{"page"}, "test1"); writefile('test3.mdwn', $config{srcdir}, $test1); IkiWiki::rcs_add("test3.mdwn"); IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn"); -IkiWiki::rcs_commit_staged("Added the 4th page", "moo", "Joe User"); +IkiWiki::rcs_commit_staged(message => "Added the 4th page"); @changes = IkiWiki::rcs_recentchanges(4); @@ -77,7 +81,7 @@ is($changes[0]{pages}[0]{"page"}, "test4"); ok(mkdir($config{srcdir}."/newdir")); IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn"); -IkiWiki::rcs_commit_staged("Added the 5th page", "moo", "Joe User"); +IkiWiki::rcs_commit_staged(message => "Added the 5th page"); @changes = IkiWiki::rcs_recentchanges(4); @@ -85,6 +89,6 @@ is($#changes, 3); is($changes[0]{pages}[0]{"page"}, "newdir/test5"); IkiWiki::rcs_remove("newdir/test5.mdwn"); -IkiWiki::rcs_commit_staged("Remove the 5th page", "moo", "Joe User"); +IkiWiki::rcs_commit_staged(message => "Remove the 5th page"); system "rm -rf $dir"; diff --git a/t/mercurial.t b/t/mercurial.t index 954b17526..b64ea8e56 100755 --- a/t/mercurial.t +++ b/t/mercurial.t @@ -22,13 +22,22 @@ $config{srcdir} = "$dir/repo"; IkiWiki::loadplugins(); IkiWiki::checkconfig(); +use CGI::Session; +my $session=CGI::Session->new; +$session->param("name", "Joe User"); + system "hg init $config{srcdir}"; # Web commit my $test1 = readfile("t/test1.mdwn"); writefile('test1.mdwn', $config{srcdir}, $test1); IkiWiki::rcs_add("test1.mdwn"); -IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo", "Joe User"); +IkiWiki::rcs_commit( + file => "test1.mdwn", + message => "Added the first page", + token => "moo", + session => $session, +); my @changes; @changes = IkiWiki::rcs_recentchanges(3); diff --git a/t/svn.t b/t/svn.t index 5223b4409..82b71b5fc 100755 --- a/t/svn.t +++ b/t/svn.t @@ -36,7 +36,11 @@ system "svn co file://$svnrepo/trunk $config{srcdir} >/dev/null"; my $test1 = readfile("t/test1.mdwn"); writefile('test1.mdwn', $config{srcdir}, $test1); IkiWiki::rcs_add("test1.mdwn"); -IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo"); +IkiWiki::rcs_commit( + file => "test1.mdwn", + message => "Added the first page", + token => "moo", +); my @changes; @changes = IkiWiki::rcs_recentchanges(3); -- cgit v1.2.3