Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -r b08179653c00 IkiWiki.pm
- --- a/IkiWiki.pm Wed Jul 20 16:56:09 2011 +0200
- +++ b/IkiWiki.pm Wed Jul 20 19:28:21 2011 +0200
- @@ -2059,6 +2059,10 @@
- $hooks{rcs}{rcs_getmtime}{call}->(@_);
- }
- +sub rcs_wrapper_postcall (@) {
- + $hooks{rcs}{rcs_wrapper_postcall}{call}->(@_);
- +}
- +
- sub rcs_receive () {
- $hooks{rcs}{rcs_receive}{call}->();
- }
- diff -r b08179653c00 IkiWiki/Plugin/mercurial.pm
- --- a/IkiWiki/Plugin/mercurial.pm Wed Jul 20 16:56:09 2011 +0200
- +++ b/IkiWiki/Plugin/mercurial.pm Wed Jul 20 19:28:21 2011 +0200
- @@ -21,6 +21,7 @@
- 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_wrapper_postcall", call => \&rcs_wrapper_postcall);
- }
- sub checkconfig () {
- @@ -28,6 +29,7 @@
- push @{$config{wrappers}}, {
- wrapper => $config{mercurial_wrapper},
- wrappermode => (defined $config{mercurial_wrappermode} ? $config{mercurial_wrappermode} : "06755"),
- + wrapper_postcall => (defined $config{mercurial_wrapper_hgrc_update} ? $config{mercurial_wrapper_hgrc_update} : "1"),
- };
- }
- }
- @@ -53,6 +55,13 @@
- safe => 0,
- rebuild => 0,
- },
- + mercurial_wrapper_hgrc_update => {
- + type => "string",
- + example => "1",
- + description => "updates existing hgrc to reflect path changes for mercurial_wrapper",
- + safe => 0,
- + rebuild => 0,
- + },
- historyurl => {
- type => "string",
- example => "http://example.com:8000/log/tip/[[file]]",
- @@ -402,4 +411,23 @@
- return findtimes($file, 0);
- }
- +sub rcs_wrapper_postcall($) {
- + # Update hgrc if it exists. Change post-commit/incoming hooks with the
- + # .ikiwiki suffix to point to the wrapper path given in the setup file.
- + # Work with a tempfile to not delete hgrc if the loop is interrupted
- + # midway.
- + my $hgrc=$config{srcdir}.'/.hg/hgrc';
- + my $backup_suffix='.ikiwiki.bak';
- + if (-e $hgrc) {
- + use File::Spec;
- + my $mercurial_wrapper_abspath=File::Spec->rel2abs($config{mercurial_wrapper}, $config{srcdir});
- + local ($^I, @ARGV)=($backup_suffix, $hgrc);
- + while (<>) {
- + s/^(post-commit|incoming)(\.ikiwiki[ \t]*=[ \t]*).*$/$1$2$mercurial_wrapper_abspath/;
- + print;
- + }
- + unlink($hgrc.$backup_suffix);
- + }
- +}
- +
- 1
- diff -r b08179653c00 IkiWiki/Setup/Automator.pm
- --- a/IkiWiki/Setup/Automator.pm Wed Jul 20 16:56:09 2011 +0200
- +++ b/IkiWiki/Setup/Automator.pm Wed Jul 20 19:28:21 2011 +0200
- @@ -75,8 +75,7 @@
- print STDERR "warning: do not know how to set up the bzr_wrapper hook!\n";
- }
- elsif ($config{rcs} eq 'mercurial') {
- - # TODO
- - print STDERR "warning: do not know how to set up the mercurial_wrapper hook!\n";
- + $config{mercurial_wrapper}=$config{srcdir}."/.hg/ikiwiki-wrapper";
- }
- elsif ($config{rcs} eq 'tla') {
- # TODO
- @@ -182,6 +181,19 @@
- }
- }
- + # Setup initial config file for Mercurial to hook up the wrapper. The
- + # path to the wrapper will be automatically added when it is generated.
- + if ($config{rcs} eq 'mercurial' && exists $config{mercurial_wrapper}
- + && length $config{mercurial_wrapper}) {
- + open (HGRC, '>', $config{srcdir}.'/.hg/hgrc');
- + print HGRC <<EOF;
- +[hooks]
- +post-commit.ikiwiki =
- +incoming.ikiwiki =
- +EOF
- + close (HGRC);
- + }
- +
- # Add wrappers, make live.
- if (system("ikiwiki", "--wrappers", "--setup", $config{dumpsetup}) != 0) {
- die "ikiwiki --wrappers --setup $config{dumpsetup} failed";
- diff -r b08179653c00 IkiWiki/Wrapper.pm
- --- a/IkiWiki/Wrapper.pm Wed Jul 20 16:56:09 2011 +0200
- +++ b/IkiWiki/Wrapper.pm Wed Jul 20 19:28:21 2011 +0200
- @@ -238,6 +238,10 @@
- }
- #translators: The parameter is a filename.
- debug(sprintf(gettext("successfully generated %s"), $wrapper));
- +
- + if (defined $config{wrapper_postcall} && $config{wrapper_postcall} ) {
- + IkiWiki::rcs_wrapper_postcall();
- + }
- }
- 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement