]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
* Add support for mercurial, contributed by Emanuele Aina.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 6 Sep 2006 20:31:55 +0000 (20:31 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 6 Sep 2006 20:31:55 +0000 (20:31 +0000)
13 files changed:
IkiWiki/Rcs/mercurial.pm [new file with mode: 0644]
debian/changelog
debian/control
doc/about_rcs_backends.mdwn
doc/features.mdwn
doc/ikiwiki.setup
doc/index.mdwn
doc/mercurial.mdwn [new file with mode: 0644]
doc/post-commit.mdwn
doc/roadmap.mdwn
doc/setup.mdwn
doc/todo/mercurial.mdwn [new file with mode: 0644]
doc/usage.mdwn

diff --git a/IkiWiki/Rcs/mercurial.pm b/IkiWiki/Rcs/mercurial.pm
new file mode 100644 (file)
index 0000000..82a2fa6
--- /dev/null
@@ -0,0 +1,143 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use IkiWiki;
+use Encode;
+use open qw{:utf8 :std};
+
+package IkiWiki;
+
+sub mercurial_log($) {
+       my $out = shift;
+       my @infos;
+
+       while (<$out>) {
+               my $line = $_;
+               my ($key, $value);
+
+               if (/^description:/) {
+                       $key = "description";
+                       $value = "";
+
+                       # slurp everything as the description text 
+                       # until the next changeset
+                       while (<$out>) {
+                               if (/^changeset: /) {
+                                       $line = $_;
+                                       last;
+                               }
+
+                               $value .= $_;
+                       }
+
+                       local $/ = "";
+                       chomp $value;
+                       $infos[$#infos]{$key} = $value;
+               }
+
+               chomp $line;
+               ($key, $value) = split /: +/, $line, 2;
+
+               if ($key eq "changeset") {
+                       push @infos, {};
+
+                       # remove the revision index, which is strictly 
+                       # local to the repository
+                       $value =~ s/^\d+://;
+               }
+
+               $infos[$#infos]{$key} = $value;
+       }
+       close $out;
+
+       return @infos;
+}
+
+sub rcs_update () { #{{{
+       my @cmdline = ("hg", "-R", "$config{srcdir}", "update");
+       if (system(@cmdline) != 0) {
+               warn "'@cmdline' failed: $!";
+       }
+} #}}}
+
+sub rcs_prepedit ($) { #{{{
+       return "";
+} #}}}
+
+sub rcs_commit ($$$) { #{{{
+       my ($file, $message, $rcstoken) = @_;
+
+       $message = possibly_foolish_untaint($message);
+
+       my @cmdline = ("hg", "-R", "$config{srcdir}", "commit", "-m", "$message");
+       if (system(@cmdline) != 0) {
+               warn "'@cmdline' failed: $!";
+       }
+
+       return undef; # success
+} #}}}
+
+sub rcs_add ($) { # {{{
+       my ($file) = @_;
+
+       my @cmdline = ("hg", "-R", "$config{srcdir}", "add", "$file");
+       if (system(@cmdline) != 0) {
+               warn "'@cmdline' failed: $!";
+       }
+} #}}}
+
+sub rcs_recentchanges ($) { #{{{
+       my ($num) = @_;
+
+       eval q{use CGI 'escapeHTML'};
+
+       my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num);
+       open (my $out, "@cmdline |");
+
+       my @ret;
+       foreach my $info (mercurial_log($out)) {
+               my @pages = ();
+               my @message = ();
+        
+               foreach my $msgline (split(/\n/, $info->{description})) {
+                       push @message, { line => $msgline };
+               }
+
+               foreach my $file (split / /,$info->{files}) {
+                       my $diffurl = $config{'diffurl'};
+                       $diffurl =~ s/\[\[file\]\]/$file/go;
+                       $diffurl =~ s/\[\[r2\]\]/$info->{changeset}/go;
+
+                       push @pages, {
+                               page => pagename($file),
+                               diffurl => $diffurl,
+                       };
+               }
+
+               my $user = $info->{"user"};
+               $user =~ s/\s*<.*>\s*$//;
+               $user =~ s/^\s*//;
+
+               push @ret, {
+                       rev        => $info->{"changeset"},
+                       user       => $user,
+                       committype => "mercurial",
+                       when       => $info->{"date"},
+                       message    => [@message],
+                       pages      => [@pages],
+               };
+       }
+
+       return @ret;
+} #}}}
+
+sub rcs_notify () { #{{{
+       # TODO
+} #}}}
+
+sub rcs_getctime ($) { #{{{
+       error "getctime not implemented";
+} #}}}
+
+1
index 99932e00738d6ba82a86ca7545a3fbef0a032a20..8f9bfe2ec3baf2b36ef464407f0c8ca7000262c1 100644 (file)
@@ -5,8 +5,9 @@ ikiwiki (1.25) UNRELEASED; urgency=low
   * Drop real uid/gid in the suid wrapper, thus allowing commits to remote
     subversion repos and fixing some other issues.
   * Add support for tla, contributed by Clint Adams. Closes: #385936
   * Drop real uid/gid in the suid wrapper, thus allowing commits to remote
     subversion repos and fixing some other issues.
   * Add support for tla, contributed by Clint Adams. Closes: #385936
+  * Add support for mercurial, contributed by Emanuele Aina.
 
 
- -- Joey Hess <joeyh@debian.org>  Wed,  6 Sep 2006 15:47:25 -0400
+ -- Joey Hess <joeyh@debian.org>  Wed,  6 Sep 2006 15:55:39 -0400
 
 ikiwiki (1.24) unstable; urgency=low
 
 
 ikiwiki (1.24) unstable; urgency=low
 
index 2b8bdbb320a3d24927962d9427bb1f4a21b4c39f..05ea1bcf58227b2c5dc134f0ba31a0106c379c9a 100644 (file)
@@ -9,13 +9,13 @@ Standards-Version: 3.7.2
 Package: ikiwiki
 Architecture: all
 Depends: ${perl:Depends}, libxml-simple-perl, markdown, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, libcgi-formbuilder-perl (>= 3.02.02), libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler, libc6-dev | libc-dev, libhtml-parser-perl
 Package: ikiwiki
 Architecture: all
 Depends: ${perl:Depends}, libxml-simple-perl, markdown, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, libcgi-formbuilder-perl (>= 3.02.02), libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler, libc6-dev | libc-dev, libhtml-parser-perl
-Recommends: subversion | git-core | tla, hyperestraier
+Recommends: subversion | git-core | tla | mercurual, hyperestraier
 Suggests: viewcvs, librpc-xml-perl, libtext-wikiformat-perl, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl
 Description: a wiki compiler
  ikiwiki converts a directory full of wiki pages into html pages suitable
  for publishing on a website. Unlike many wikis, ikiwiki does not have its
 Suggests: viewcvs, librpc-xml-perl, libtext-wikiformat-perl, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl
 Description: a wiki compiler
  ikiwiki converts a directory full of wiki pages into html pages suitable
  for publishing on a website. Unlike many wikis, ikiwiki does not have its
- own means of storing page history. Instead it can use Subversion (or
Git or tla).
+ own means of storing page history, and instead uses a revision control
system (such as  Subversion).
  .
  ikiwiki implements all of the other standard features of a wiki, including
  web-based page editing, user registration and logins, a RecentChanges
  .
  ikiwiki implements all of the other standard features of a wiki, including
  web-based page editing, user registration and logins, a RecentChanges
index 0a95b7f54feb7976f90ce2b7a957b00588cd0146..95d641e726dc4161a43ac69a2f55314794f27d44 100644 (file)
@@ -117,8 +117,33 @@ part).  GIT doesn't have a similar functionality like 'svn merge -rOLD:NEW
 FILE' (please see the relevant comment in mergepast for more details), so I
 had to invent an ugly hack just for the purpose.
 
 FILE' (please see the relevant comment in mergepast for more details), so I
 had to invent an ugly hack just for the purpose.
 
-## [mercurial](http://www.selenic.com/mercurial/)
+## [Mercurial](http://www.selenic.com/mercurial/)
 
 
-Being worked on by Emanuele Aina.
+The Mercurial backend is still in a early phase, so it may not be mature 
+enough, but it should be simple to understand and use.
 
 
-<http://techn.ocracy.org/ikiwiki>
+As Mercurial is a distributed RCS, it lacks the distinction between 
+repository and working copy (every wc is a repo).
+
+This means that the Mercurial backend uses directly the repository as 
+working copy (the master M and the working copy W described in the svn 
+example are the same thing).
+
+You only need to specify 'srcdir' (the repository M) and 'destdir' (where
+the HTML will be generated).
+
+Master repository M.
+
+RCS commit from the outside are installed into M.
+
+M is directly used as working copy (M is also W).
+
+HTML is generated from the working copy in M. rcs_update() will update 
+to the last committed revision in M (the same as 'hg update').
+If you use an 'update' hook you can generate automatically the HTML
+in the destination directory each time 'hg update' is called.
+
+CGI operates on M. rcs_commit() will commit directly in M.
+
+If you have any question or suggestion about the Mercurial backend 
+please refer to [Emanuele](http://nerd.ocracy.org/em/).
index d5fa4026b20bb90fba1dc5f81fafb9e4a1977677..c568213bf3093d31c31ea027e94fcff1527f8a74 100644 (file)
@@ -4,18 +4,18 @@ An overview of some of ikiwiki's features:
 ## Uses a real RCS
 
 Rather than implement its own system for storing page histories etc,
 ## Uses a real RCS
 
 Rather than implement its own system for storing page histories etc,
-ikiwiki uses a real RCS. This isn't because we're lazy, it's because a
-real RCS is a good thing to have, and there are advantages to using one
-that are not possible with a standard wiki.
+ikiwiki uses a real Revision Control System. This isn't because we're
+lazy, it's because a real RCS is a good thing to have, and there are
+advantages to using one that are not possible with a standard wiki.
 
 Instead of editing pages in a stupid web form, you can use vim and commit
 
 Instead of editing pages in a stupid web form, you can use vim and commit
-changes via svn. Or work disconnected using svk and push your changes out
-when you come online. Or use git or tla to work in a distributed fashion
-all the time. (It's also possible to [[plugins/write]] a plugin to support
-other systems.)
+changes via [[Subversion]]. Or work disconnected using svk and push your
+changes out when you come online. Or use [[git]], [[tla]], or [[mercurial]]
+to work in a distributed fashion all the time. (It's also possible to
+[[plugins/write]] a plugin to support other systems.)
 
 ikiwiki can be run from a [[post-commit]] hook to update your wiki
 
 ikiwiki can be run from a [[post-commit]] hook to update your wiki
-immediately whenever you commit.
+immediately whenever you commit a change using the RCS.
 
 Note that ikiwiki does not require a RCS to function. If you want to
 run a simple wiki without page history, it can do that too.
 
 Note that ikiwiki does not require a RCS to function. If you want to
 run a simple wiki without page history, it can do that too.
index 95d2d46af9e146e9e5c70b01381dc40670463787..ac84352df3e51f47f7e7128e8f0b18c784248d1d 100644 (file)
@@ -35,6 +35,11 @@ use IkiWiki::Setup::Standard {
        #historyurl => ??,
        #diffurl => ??,
 
        #historyurl => ??,
        #diffurl => ??,
 
+       # Mercurial stuff.
+       #rcs => "mercurial",
+       #historyurl => "http://localhost:8000/", # hg serve'd local repository
+       #diffurl => "http://localhost:8000/?fd=[[changeset]];file=[[file]]",
+
        wrappers => [
                #{
                #       # The cgi wrapper.
        wrappers => [
                #{
                #       # The cgi wrapper.
index 67f099210f168617de771dad36dd741e5fcfb86a..2dd90247c38b662dabdf1fe2255d3e92f1d0ba3b 100644 (file)
@@ -1,8 +1,8 @@
 [[ikiwiki_logo|logo/ikiwiki.png]]  
 ikiwiki is a **wiki compiler**. It converts wiki pages
 into html pages suitable for publishing on a website. Unlike a traditional
 [[ikiwiki_logo|logo/ikiwiki.png]]  
 ikiwiki is a **wiki compiler**. It converts wiki pages
 into html pages suitable for publishing on a website. Unlike a traditional
-wiki, ikiwiki does not have its own means of storing page history.
-Instead it can use [[Subversion]] (or [[Git]] or [[tla]]).
+wiki, ikiwiki does not have its own means of storing page history,
+and instead uses a revision control system (such as [[Subversion]]).
 
 * [[News]] is a blog (built using ikiwiki) of news items about ikiwiki.
   It's the best way to find out when there's a new version to [[Download]].
 
 * [[News]] is a blog (built using ikiwiki) of news items about ikiwiki.
   It's the best way to find out when there's a new version to [[Download]].
diff --git a/doc/mercurial.mdwn b/doc/mercurial.mdwn
new file mode 100644 (file)
index 0000000..5eaae19
--- /dev/null
@@ -0,0 +1,8 @@
+[Mercurial](http://selenic.com/mercurial) is a distributed revison control
+system developed by Matt Mackall. Ikiwiki supports storing a wiki in a
+mercurial repository.
+
+Ikiwiki can run as a post-update hook to update a wiki whenever commits
+come in. When running as a [[cgi]] with Mercurial, ikiwiki automatically
+commits edited pages, and uses the Mercurial history to generate the
+[[RecentChanges]] page.
index 8def3d751661a8863aad68b4bfa8e24ecc6e967d..84375dad03155bf209f540912b3dc8426f11c590 100644 (file)
@@ -1,5 +1,5 @@
 A post-commit hook is run every time you commit a change to your
 A post-commit hook is run every time you commit a change to your
-[[subversion]] (or [[git]]) repository. To make the wiki be updated each
+[[subversion]] (or [[git]] or [[mercurial]]) repository. To make the wiki be updated each
 time a commit is made, it can be run from (or as) a post-commit hook.
 
 The best way to run ikiwiki in a post-commit hook is using a wrapper, which
 time a commit is made, it can be run from (or as) a post-commit hook.
 
 The best way to run ikiwiki in a post-commit hook is using a wrapper, which
index 4bd9ab671fd62c577db58cf6a668e5dffa7b56da..a4b4919d4cac88ac72711e3760ed8d887eb3d79d 100644 (file)
@@ -22,9 +22,8 @@ Released 29 April 2006.
   possible)_
 * Improved [[todo/html]] stylesheets and templates.
 * Improved scalable [[logo]]. _(status: done)_
   possible)_
 * Improved [[todo/html]] stylesheets and templates.
 * Improved scalable [[logo]]. _(status: done)_
-* Support for at least one RCS aside from svn. Once it supports two, it should
-  quickly grow to support them all.. See [[about_rcs_backends]]
-  _(status: supports git and tla in tree)_
+* Support for at other revision control systems aside from svn.
+  See [[about_rcs_backends]] _(status: supports git, tla, mercurial)_
 * Support for one other markup language, probably restructured text.
   _(status: done, but the rst plugin needs improvement)_
 * No serious known [[bugs]]
 * Support for one other markup language, probably restructured text.
   _(status: done, but the rst plugin needs improvement)_
 * No serious known [[bugs]]
index e2396f777355a374441f4d9e06378ba9c06f92ff..c6a8f297eb2ff313afc33090c63b0933ffc54f61 100644 (file)
@@ -1,6 +1,6 @@
 So you want to set up your own wiki using ikiwiki? This tutorial will walk
 So you want to set up your own wiki using ikiwiki? This tutorial will walk
-you through setting up a wiki that is stored in [[Subversion]], [[Git]], or
-[[TLA]], and that has optional support for commits from the web.
+you through setting up a wiki that is stored in [[Subversion]], [[Git]],
+[[TLA]] or [[Mercurial]], and that has optional support for commits from the web.
 
 1. [[Install]] ikiwiki. See [[download]] for where to get it.
 
 
 1. [[Install]] ikiwiki. See [[download]] for where to get it.
 
@@ -26,6 +26,9 @@ you through setting up a wiki that is stored in [[Subversion]], [[Git]], or
                # Edit {arch}/=tagging-method and change the precious
                # line to add the .ikiwiki directory to the regexp.
 
                # Edit {arch}/=tagging-method and change the precious
                # line to add the .ikiwiki directory to the regexp.
 
+               # Mercurial
+               hg init /hg/wikirepo
+
 3. Check out the repository to make the working copy that ikiwiki will use.
 
                # Subversion
 3. Check out the repository to make the working copy that ikiwiki will use.
 
                # Subversion
@@ -41,6 +44,12 @@ you through setting up a wiki that is stored in [[Subversion]], [[Git]], or
                tla init-tree me@localhost--wiki/wiki--0
                tla import
 
                tla init-tree me@localhost--wiki/wiki--0
                tla import
 
+               # Mercurial
+               # Mercurial uses a single repo approach, so no need to
+               # clone anything. Because the following examples
+               # refer to the ~/wikiwc working copy we symlink it:
+               ln -s /hg/wikirepo ~/wikiwc
+
 4. Build your wiki for the first time.
 
                ikiwiki --verbose ~/wikiwc/ ~/public_html/wiki/ \
 4. Build your wiki for the first time.
 
                ikiwiki --verbose ~/wikiwc/ ~/public_html/wiki/ \
@@ -70,6 +79,10 @@ you through setting up a wiki that is stored in [[Subversion]], [[Git]], or
                tla add index.mdwn
                tla commit
 
                tla add index.mdwn
                tla commit
 
+               # Mercurial
+               hg add index.mdwn
+               hg commit -m customised index.mdwn
+
    You can also add any files you like from scratch of course.
 
 6. Repeat steps 4 and 5 as desired, editing or adding pages and rebuilding
    You can also add any files you like from scratch of course.
 
 6. Repeat steps 4 and 5 as desired, editing or adding pages and rebuilding
@@ -92,12 +105,13 @@ you through setting up a wiki that is stored in [[Subversion]], [[Git]], or
    that all of these are pointing to the right directories, and read
    through and configure the rest of the file to your liking.
 
    that all of these are pointing to the right directories, and read
    through and configure the rest of the file to your liking.
 
-   If you want to use git, comment out the subversion stuff, uncomment and
-   edit the git stuff.
+   If you want to use something other than subversion, comment out the
+   subversion configuration, and uncomment and edit the configuration for
+   your chosen RCS.
 
    Note that the default file has a block to configure an [[post-commit]] 
    wrapper to update the wiki. You need to uncomment the related block for
 
    Note that the default file has a block to configure an [[post-commit]] 
    wrapper to update the wiki. You need to uncomment the related block for
-   whatever rcs you use and comment out the other rcs blocks.
+   whatever RCS you use and comment out the other rcs blocks.
 
    When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it
    will set everything up and update your wiki.
 
    When you're satisfied, run `ikiwiki --setup ikiwiki.setup`, and it
    will set everything up and update your wiki.
@@ -111,7 +125,7 @@ you through setting up a wiki that is stored in [[Subversion]], [[Git]], or
 9. Add [[PageHistory]] links to the top of pages. This requires you to have
    setup a repository browser.  For Subversion, you may use [[ViewCVS]] or
    something similar to access your [[Subversion]] repository.  For Git,
 9. Add [[PageHistory]] links to the top of pages. This requires you to have
    setup a repository browser.  For Subversion, you may use [[ViewCVS]] or
    something similar to access your [[Subversion]] repository.  For Git,
-   [[Gitweb]] can be used.
+   [[Gitweb]] can be used, etc.
    
    The `historyurl` setting makes ikiwiki add the links, and in that url,
    "\[[file]]" is replaced with the name of the file to view. So edit
    
    The `historyurl` setting makes ikiwiki add the links, and in that url,
    "\[[file]]" is replaced with the name of the file to view. So edit
diff --git a/doc/todo/mercurial.mdwn b/doc/todo/mercurial.mdwn
new file mode 100644 (file)
index 0000000..e25039b
--- /dev/null
@@ -0,0 +1,4 @@
+* Need to get post commit hook working (or an example of how to use it.)
+* Need --ctime support.
+* rcs_notify is not implemented
+* Is the code sufficiently robust? It just warns when mercurial fails.
index 4456e8c1ce66119bd981169f366b76ba2bbc6829..0c7e7d036cb266c30374cb81a0c481b63b13a631 100644 (file)
@@ -120,6 +120,11 @@ configuration options of their own.
   If you use git, the `source` directory is assumed to be a clone of the
   [[git]] repository.
 
   If you use git, the `source` directory is assumed to be a clone of the
   [[git]] repository.
 
+  If you use tla, the `source` directory is assumed to be a tla import.
+
+  If you use mercurial, the `source` directory is assumed to be the
+  [[mercurial]] repository.
+
   In [[CGI]] mode, with a revision control system enabled pages edited via
   the web will be committed. Also, the [[RecentChanges]] link will be placed
   on pages.
   In [[CGI]] mode, with a revision control system enabled pages edited via
   the web will be committed. Also, the [[RecentChanges]] link will be placed
   on pages.