#Ikiwiki plugin for the Monotone revision control system.
I've just made a patch to the ikiwiki code that allows it to use the [[rcs/Monotone]] revision control system. It is available at:
http://www.cse.unsw.edu.au/~willu/monotone-ikiwiki.diff
At the moment it is basically complete. At present rcs_notify() is implemeted but untested, the rest is implemented and tested.
The current version of the patch handles conflicts through the web interface. It is still not perfect as it will break if there is a rename that conflicts with a web change (but so will the other Rcs plugins I think). It also commits a revision with conflict markers if there is a conflict requiring such markers... ick.
Note: This patch requires a rather recent Monotone perl module (18 August 2007 or later). It is available from the monotone repository here: http://viewmtn.angrygoats.net/branch/changes/net.venge.monotone.
The setup instructions to add 40 lines of code to monotonerc is pretty frightning stuff.
Is there some way this can be automated? --[[Joey]]
I've committed a bunch of this to monotone so that in future it could be removed.
I've also just fixed this so it is in a separate, automagically generated, rc file.
Fair enough. Didn't realize you were a monotone committer. :-)
I am, but still a little newish. Feedback is good. In particular, this is my first major bit of PERL.
Having rcs_commit return a warning message when there's an unresolved conflict
isn't right; that message will populate the page edit box. You might want
to use the error() function here?
It should never reach that case, so I have changed that to error.
There'an incomplete comment ending with "note, this relies on the fact that"
erg... sorry, fixed.
[[tag patch]]
I've [[accepted|done]] this patch, thank you!
Thanks for committing it. I hate keeping my own diffs. :)
I did make a few changes. Please review, and make sure it still works
(a test case like we have for some of the other RCSes would be nice..)
Tested. It still works at least as well as it did. I'll try to get to a test case soon.
In checking the source I noticed a few bogus comments I left in when editing,
and a bug in page adding.
Here is a small patch for them:
applied
Here is another patch. It fixes a FIXME you added. I was using $file within backticks because
I was getting an error trying to do it right. I've figured out the error, and now do it right. This
should also speed things up (very slightly)
applied
BTW, will all the monotone output parsing work if LANG != C?
It should (he says crossing fingers).
In the places where I do any complex parsing I'm using a special
version of the mtn commands designed for scripting. They have a
stable, easy to parse, output that doesn't get translated (I think).
Do monotone post-commit hooks actually use REV?
Monotone post-commit hooks are written in Lua and can do
what they please. Setting the REV environment var before
calling Ikiwiki seems reasonable, but I've not written the
Lua hook.
So the rcs_notify support is not just untested, but can't work
at all w/o further development.
I've just done this further development... The following patch adds support for diffurls.
I've also partially tested the commit message support. I was unable to get Ikiwiki to send
change emails at all (cgi or otherwise), so I tested by adding warn() calls. There were a
few things that needed to be fixed. Support is much closer now (including a simple default
monotone lua hook).
When I stick this diff inline into the page, I have to indent it by four spaces, and that's fine.
But markdown seems to still be interpreting parts of it (e.g. the diff url) in strange ways. I
think it is the square brackets.
Index: IkiWiki/Rcs/monotone.pm
===================================================================
--- IkiWiki/Rcs/monotone.pm (revision 4252)
+++ IkiWiki/Rcs/monotone.pm (working copy)
@@ -186,8 +186,9 @@
check_config();
if (defined($config{mtnsync}) && $config{mtnsync}) {
+ check_mergerc();
if (system("mtn", "--root=$config{mtnrootdir}", "sync",
- "--quiet", "--ticker=none",
+ "--quiet", "--ticker=none", "--rcfile", $config{mtnmergerc},
"--key", $config{mtnkey}) != 0) {
debug("monotone sync failed before update");
}
@@ -342,10 +343,10 @@
return $conflict;
}
if (defined($config{mtnsync}) && $config{mtnsync}) {
- if (system("mtn", "--root=$config{mtnrootdir}", "sync",
+ if (system("mtn", "--root=$config{mtnrootdir}", "push",
"--quiet", "--ticker=none", "--key",
$config{mtnkey}) != 0) {
- debug("monotone sync failed");
+ debug("monotone push failed");
}
}
@@ -431,10 +432,28 @@
my @changed_files = get_changed_files($automator, $rev);
my $file;
+ my ($out, $err) = $automator->call("parents", $rev);
+ my @parents = ($out =~ m/^($sha1_pattern)$/);
+ my $parent = $parents[0];
+
foreach $file (@changed_files) {
- push @pages, {
- page => pagename($file),
- } if length $file;
+ if (length($file)) {
+ if (defined $config{diffurl} and (@parents == 1)) {
+ my $diffurl=$config{diffurl};
+ $diffurl=~s/\[\[r1\]\]/$parent/g;
+ $diffurl=~s/\[\[r2\]\]/$rev/g;
+ $diffurl=~s/\[\[file\]\]/$file/g;
+ push @pages, {
+ page => pagename($file),
+ diffurl => $diffurl,
+ };
+ }
+ else {
+ push @pages, {
+ page => pagename($file),
+ };
+ }
+ }
}
push @ret, {
@@ -487,6 +506,18 @@
my @changed_pages = get_changed_files($automator, $rev);
+ my ($out, $err) = $automator->call("parents", $rev);
+ my @parents = ($out =~ m/^($sha1_pattern)$/);
+ my $parent = $parents[0];
+
+ my $diff;
+
+ if (@parents == 1) {
+ $automator->setOpts("r", $parent, "r", $rev);
+ ($out, $err) = $automator->call("content_diff");
+ $diff = $out;
+ }
+
$automator->close();
require IkiWiki::UserInfo;
@@ -495,7 +526,7 @@
return $message;
},
sub {
- `mtn --root=$config{mtnrootdir} au content_diff -r $rev`;
+ return $diff;
},
$user, @changed_pages);
} #}}}
@@ -604,4 +635,9 @@
return true
end
}
+ function note_netsync_revision_received(new_id, revision, certs, session_id)
+ if (program_exists_in_path("ikiwiki-netsync-hook")) then
+ execute("ikiwiki-netsync-hook", new_id)
+ end
+ end
EOF
Index: IkiWiki/Wrapper.pm
===================================================================
--- IkiWiki/Wrapper.pm (revision 4252)
+++ IkiWiki/Wrapper.pm (working copy)
@@ -46,6 +46,16 @@
addenv("REV", s);
EOF
}
+ if ($config{rcs} eq "monotone" && $config{notify}) {
+ # Support running directly as hooks/post-commit by passing
+ # $1 in REV in the environment.
+ $envsave.=<<"EOF"
+ if (argc == 2)
+ addenv("REV", argv[1]);
+ else if ((s=getenv("REV")))
+ addenv("REV", s);
+EOF
+ }
if ($config{rcs} eq "tla" && $config{notify}) {
$envsave.=<<"EOF"
if ((s=getenv("ARCH_VERSION")))
Index: doc/rcs/monotone.mdwn
===================================================================
--- doc/rcs/monotone.mdwn (revision 4252)
+++ doc/rcs/monotone.mdwn (working copy)
@@ -1,16 +1,13 @@
-[monotone](http://monotone.ca/) is a distributed revision control system.
-Ikiwiki supports storing a wiki in Monotone and editing it using the [[cgi]] interface.
+[Monotone](http://monotone.ca/) is a distributed revision control system.
+Ikiwiki supports storing a wiki in a Monotone repository and editing it using the [[cgi]] interface.
It will use the Monotone logs to generate the [[RecentChanges]] page.
-The monotone support requires the Monotone perl module (from the contrib/ directory
-in the monotone source) to be installed. In particular, it needs version 0.03 or higher of that module.
+The monotone support in Ikiwiki requires the Monotone perl module to be installed
+(available from the contrib/ directory in the monotone source).
+In particular, it needs version 0.03 or higher of that module.
The module is available from the monotone source repository at:
<http://viewmtn.angrygoats.net/branch/changes/net.venge.monotone>
-Monotone support works, but there are still a few minor missing bits (listed here so they are not forgotten):
+At present the [[post-commit]] hook support is implemented but only partially tested.
-* At the moment there are no links to display diffs between revisions. It shouldn't be hard to add links to a [ViewMTN](http://grahame.angrygoats.net/moinmoin/ViewMTN) instance, but it hasn't been done yet.
-* The [[post-commit]] hook support, so that Ikiwiki sends change notifications when people commit using Monotone rather than the web interface, is partially implemented and untested.
-* Documentation (this page) could be improved.
-
There is also a mismatch between the way Ikiwiki handles conflicts and the way Monotone handles conflicts. At present, if there is a conflict, then Ikiwiki will commit a revision with conflict markers before presenting it to the user. This is ugly, but there is no clean way to fix it at present.
Index: doc/ikiwiki.setup
===================================================================
--- doc/ikiwiki.setup (revision 4252)
+++ doc/ikiwiki.setup (working copy)
@@ -46,6 +46,8 @@
# Monotone stuff
#rcs => "monotone",
#mtnkey => "web\@machine.company.com",
+ #historyurl => "http://viewmtn.company.com/",
+ #diffurl => "http://viewmtn.company.com/revision/diff/[[r1]]/with/[[r2]]/[[file]]",
# Set if you want the wiki to sync on update and commit.
#mtnsync => 0,
# The path to your workspace (defaults to the srcdir itself)
@@ -88,6 +90,16 @@
# # Enable mail notifications of commits.
# notify => 1,
#},
+ #{
+ # # The monotone netsync revision received wrapper.
+ # # Note that you also need to install a lua
+ # # hook into monotone to make this work
+ # # see: http://ikiwiki.info/rcs/monotone/
+ # wrapper => "/usr/local/bin/ikiwiki-netsync-hook",
+ # wrappermode => "04755",
+ # # Enable mail notifications of commits.
+ # notify => 1,
+ #},
],
# Generate rss feeds for blogs?
|