1 #Ikiwiki plugin for the Monotone revision control system.
3 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:
5 <http://www.cse.unsw.edu.au/~willu/monotone-ikiwiki.diff>
7 At the moment it is basically complete. At present rcs_notify() is implemeted but untested, the rest is implemented and tested.
9 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.
11 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>.
13 > The setup instructions to add 40 lines of code to monotonerc is pretty frightning stuff.
14 > Is there some way this can be automated? --[[Joey]]
16 >> I've committed a bunch of this to monotone so that in future it could be removed.
17 >> I've also just fixed this so it is in a separate, automagically generated, rc file.
19 >>> Fair enough. Didn't realize you were a monotone committer. :-)
21 >>>> I am, but still a little newish. Feedback is good. In particular, this is my first major bit of PERL.
23 > Having rcs_commit return a warning message when there's an unresolved conflict
24 > isn't right; that message will populate the page edit box. You might want
25 > to use the error() function here?
27 >> It should never reach that case, so I have changed that to error.
29 > There'an incomplete comment ending with "note, this relies on the fact that"
31 >> erg... sorry, fixed.
35 >> I've [[accepted|done]] this patch, thank you!
37 >>> Thanks for committing it. I hate keeping my own diffs. :)
39 >> I did make a few changes. Please review, and make sure it still works
40 >> (a test case like we have for some of the other RCSes would be nice..)
42 >>> Tested. It still works at least as well as it did. I'll try to get to a test case soon.
43 >>> In checking the source I noticed a few bogus comments I left in when editing,
44 >>> and a bug in page adding.
45 >>> Here is a small patch for them:
49 Here is another patch. It fixes a FIXME you added. I was using $file within backticks because
50 I was getting an error trying to do it right. I've figured out the error, and now do it right. This
51 should also speed things up (very slightly)
55 >> BTW, will all the monotone output parsing work if LANG != C?
57 >>> It should (he says crossing fingers).
58 >>> In the places where I do any complex parsing I'm using a special
59 >>> version of the mtn commands designed for scripting. They have a
60 >>> stable, easy to parse, output that doesn't get translated (I think).
62 >> Do monotone post-commit hooks actually use REV?
64 >>> Monotone post-commit hooks are written in Lua and can do
65 >>> what they please. Setting the REV environment var before
66 >>> calling Ikiwiki seems reasonable, but I've not written the
69 >>>> So the rcs_notify support is not just untested, but can't work
70 >>>> at all w/o further development.
72 I've just done this further development... The following patch adds support for diffurls.
73 I've also partially tested the commit message support. I was unable to get Ikiwiki to send
74 change emails at all (cgi or otherwise), so I tested by adding warn() calls. There were a
75 few things that needed to be fixed. Support is much closer now (including a simple default
78 When I stick this diff inline into the page, I have to indent it by four spaces, and that's fine.
79 But markdown seems to still be interpreting parts of it (e.g. the diff url) in strange ways. I
80 think it is the square brackets.
82 Index: IkiWiki/Rcs/monotone.pm
83 ===================================================================
84 --- IkiWiki/Rcs/monotone.pm (revision 4252)
85 +++ IkiWiki/Rcs/monotone.pm (working copy)
89 if (defined($config{mtnsync}) && $config{mtnsync}) {
91 if (system("mtn", "--root=$config{mtnrootdir}", "sync",
92 - "--quiet", "--ticker=none",
93 + "--quiet", "--ticker=none", "--rcfile", $config{mtnmergerc},
94 "--key", $config{mtnkey}) != 0) {
95 debug("monotone sync failed before update");
100 if (defined($config{mtnsync}) && $config{mtnsync}) {
101 - if (system("mtn", "--root=$config{mtnrootdir}", "sync",
102 + if (system("mtn", "--root=$config{mtnrootdir}", "push",
103 "--quiet", "--ticker=none", "--key",
104 $config{mtnkey}) != 0) {
105 - debug("monotone sync failed");
106 + debug("monotone push failed");
110 @@ -431,10 +432,28 @@
111 my @changed_files = get_changed_files($automator, $rev);
114 + my ($out, $err) = $automator->call("parents", $rev);
115 + my @parents = ($out =~ m/^($sha1_pattern)$/);
116 + my $parent = $parents[0];
118 foreach $file (@changed_files) {
120 - page => pagename($file),
122 + if (length($file)) {
123 + if (defined $config{diffurl} and (@parents == 1)) {
124 + my $diffurl=$config{diffurl};
125 + $diffurl=~s/\[\[r1\]\]/$parent/g;
126 + $diffurl=~s/\[\[r2\]\]/$rev/g;
127 + $diffurl=~s/\[\[file\]\]/$file/g;
129 + page => pagename($file),
130 + diffurl => $diffurl,
135 + page => pagename($file),
144 my @changed_pages = get_changed_files($automator, $rev);
146 + my ($out, $err) = $automator->call("parents", $rev);
147 + my @parents = ($out =~ m/^($sha1_pattern)$/);
148 + my $parent = $parents[0];
152 + if (@parents == 1) {
153 + $automator->setOpts("r", $parent, "r", $rev);
154 + ($out, $err) = $automator->call("content_diff");
160 require IkiWiki::UserInfo;
165 - `mtn --root=$config{mtnrootdir} au content_diff -r $rev`;
168 $user, @changed_pages);
174 + function note_netsync_revision_received(new_id, revision, certs, session_id)
175 + if (program_exists_in_path("ikiwiki-netsync-hook")) then
176 + execute("ikiwiki-netsync-hook", new_id)
180 Index: IkiWiki/Wrapper.pm
181 ===================================================================
182 --- IkiWiki/Wrapper.pm (revision 4252)
183 +++ IkiWiki/Wrapper.pm (working copy)
188 + if ($config{rcs} eq "monotone" && $config{notify}) {
189 + # Support running directly as hooks/post-commit by passing
190 + # $1 in REV in the environment.
193 + addenv("REV", argv[1]);
194 + else if ((s=getenv("REV")))
198 if ($config{rcs} eq "tla" && $config{notify}) {
200 if ((s=getenv("ARCH_VERSION")))
201 Index: doc/rcs/monotone.mdwn
202 ===================================================================
203 --- doc/rcs/monotone.mdwn (revision 4252)
204 +++ doc/rcs/monotone.mdwn (working copy)
206 -[monotone](http://monotone.ca/) is a distributed revision control system.
207 -Ikiwiki supports storing a wiki in Monotone and editing it using the [[cgi]] interface.
208 +[Monotone](http://monotone.ca/) is a distributed revision control system.
209 +Ikiwiki supports storing a wiki in a Monotone repository and editing it using the [[cgi]] interface.
210 It will use the Monotone logs to generate the [[RecentChanges]] page.
212 -The monotone support requires the Monotone perl module (from the contrib/ directory
213 -in the monotone source) to be installed. In particular, it needs version 0.03 or higher of that module.
214 +The monotone support in Ikiwiki requires the Monotone perl module to be installed
215 +(available from the contrib/ directory in the monotone source).
216 +In particular, it needs version 0.03 or higher of that module.
217 The module is available from the monotone source repository at:
218 <http://viewmtn.angrygoats.net/branch/changes/net.venge.monotone>
220 -Monotone support works, but there are still a few minor missing bits (listed here so they are not forgotten):
221 +At present the [[post-commit]] hook support is implemented but only partially tested.
223 -* 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.
224 -* 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.
225 -* Documentation (this page) could be improved.
227 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.
228 Index: doc/ikiwiki.setup
229 ===================================================================
230 --- doc/ikiwiki.setup (revision 4252)
231 +++ doc/ikiwiki.setup (working copy)
235 #mtnkey => "web\@machine.company.com",
236 + #historyurl => "http://viewmtn.company.com/",
237 + #diffurl => "http://viewmtn.company.com/revision/diff/[[r1]]/with/[[r2]]/[[file]]",
238 # Set if you want the wiki to sync on update and commit.
240 # The path to your workspace (defaults to the srcdir itself)
242 # # Enable mail notifications of commits.
246 + # # The monotone netsync revision received wrapper.
247 + # # Note that you also need to install a lua
248 + # # hook into monotone to make this work
249 + # # see: http://ikiwiki.info/rcs/monotone/
250 + # wrapper => "/usr/local/bin/ikiwiki-netsync-hook",
251 + # wrappermode => "04755",
252 + # # Enable mail notifications of commits.
257 # Generate rss feeds for blogs?