X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/b20d4f6681c0f2ccebc8ea2d75414d3d194c5188..56b9b85e3332fbb920fb74b4dd30574fce6dc469:/IkiWiki/Rcs/mercurial.pm?ds=sidebyside diff --git a/IkiWiki/Rcs/mercurial.pm b/IkiWiki/Rcs/mercurial.pm index 67002ac57..6452a0805 100644 --- a/IkiWiki/Rcs/mercurial.pm +++ b/IkiWiki/Rcs/mercurial.pm @@ -1,14 +1,34 @@ #!/usr/bin/perl +package IkiWiki; + use warnings; use strict; use IkiWiki; use Encode; use open qw{:utf8 :std}; -package IkiWiki; - -sub mercurial_log($) { +hook(type => "getsetup", id => "mercurial", call => sub { #{{{ + return + historyurl => { + type => "string", + default => "", + example => "http://example.com:8000/log/tip/[[file]]", + description => "url to hg serve'd repository, to show file history ([[file]] substituted)", + safe => 1, + rebuild => 1, + }, + diffurl => { + type => "string", + default => "", + example => "http://localhost:8000/?fd=[[r2]];file=[[file]]", + description => "url to hg serve'd repository, to show diff ([[file]] and [[r2]] substituted)", + safe => 1, + rebuild => 1, + }, +}); #}}} + +sub mercurial_log ($) { #{{{ my $out = shift; my @infos; @@ -52,10 +72,10 @@ sub mercurial_log($) { close $out; return @infos; -} +} #}}} sub rcs_update () { #{{{ - my @cmdline = ("hg", "-R", "$config{srcdir}", "update"); + my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "update"); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } @@ -72,16 +92,19 @@ sub rcs_commit ($$$;$$) { #{{{ $user = possibly_foolish_untaint($user); } elsif (defined $ipaddr) { - $user = "Anonymous from $ipaddr"; + $user = "Anonymous from ".possibly_foolish_untaint($ipaddr); } else { $user = "Anonymous"; } $message = possibly_foolish_untaint($message); + if (! length $message) { + $message = "no message given"; + } - my @cmdline = ("hg", "-R", "$config{srcdir}", "commit", - "-m", "$message", "-u", "$user"); + my @cmdline = ("hg", "-q", "-R", $config{srcdir}, "commit", + "-m", $message, "-u", $user); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } @@ -89,22 +112,40 @@ 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)=@_; + + error("rcs_commit_staged not implemented for mercurial"); # TODO +} + sub rcs_add ($) { # {{{ my ($file) = @_; - my @cmdline = ("hg", "-R", "$config{srcdir}", "add", "$file"); + my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "add", "$config{srcdir}/$file"); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } } #}}} +sub rcs_remove ($) { # {{{ + my ($file) = @_; + + error("rcs_remove not implemented for mercurial"); # TODO +} #}}} + +sub rcs_rename ($$) { # {{{ + my ($src, $dest) = @_; + + error("rcs_rename not implemented for mercurial"); # TODO +} #}}} + sub rcs_recentchanges ($) { #{{{ my ($num) = @_; - eval q{use CGI 'escapeHTML'}; - error($@) if $@; - - my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num); + my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num, + "--style", "default"); open (my $out, "@cmdline |"); eval q{use Date::Parse}; @@ -147,7 +188,7 @@ sub rcs_recentchanges ($) { #{{{ return @ret; } #}}} -sub rcs_notify () { #{{{ +sub rcs_diff ($) { #{{{ # TODO } #}}} @@ -156,7 +197,8 @@ sub rcs_getctime ($) { #{{{ # XXX filename passes through the shell here, should try to avoid # that just in case - my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", '1', $file); + my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", '1', + "--style", "default", "$config{srcdir}/$file"); open (my $out, "@cmdline |"); my @log = mercurial_log($out);