X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/04a9dbfe7daa9c352ae4e9af17df8134248f3806..1b8402c22a656401434f98fc6c19a2be442c9f4c:/IkiWiki/Rcs/mercurial.pm diff --git a/IkiWiki/Rcs/mercurial.pm b/IkiWiki/Rcs/mercurial.pm index 66ff0996a..84bf99c68 100644 --- a/IkiWiki/Rcs/mercurial.pm +++ b/IkiWiki/Rcs/mercurial.pm @@ -55,7 +55,7 @@ sub mercurial_log($) { } 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: $!"; } @@ -65,19 +65,26 @@ sub rcs_prepedit ($) { #{{{ return ""; } #}}} -sub rcs_commit ($$$) { #{{{ +sub rcs_commit ($$$;$$) { #{{{ my ($file, $message, $rcstoken, $user, $ipaddr) = @_; if (defined $user) { - $message="web commit by $user".(length $message ? ": $message" : ""); + $user = possibly_foolish_untaint($user); } elsif (defined $ipaddr) { - $message="web commit from $ipaddr".(length $message ? ": $message" : ""); + $user = "Anonymous from $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"); + my @cmdline = ("hg", "-q", "-R", $config{srcdir}, "commit", + "-m", $message, "-u", $user); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } @@ -88,7 +95,7 @@ sub rcs_commit ($$$) { #{{{ sub rcs_add ($) { # {{{ my ($file) = @_; - my @cmdline = ("hg", "-R", "$config{srcdir}", "add", "$file"); + my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "add", "$file"); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } @@ -103,6 +110,9 @@ sub rcs_recentchanges ($) { #{{{ my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num); open (my $out, "@cmdline |"); + eval q{use Date::Parse}; + error($@) if $@; + my @ret; foreach my $info (mercurial_log($out)) { my @pages = (); @@ -131,7 +141,7 @@ sub rcs_recentchanges ($) { #{{{ rev => $info->{"changeset"}, user => $user, committype => "mercurial", - when => $info->{"date"}, + when => time - str2time($info->{"date"}), message => [@message], pages => [@pages], }; @@ -145,7 +155,24 @@ sub rcs_notify () { #{{{ } #}}} sub rcs_getctime ($) { #{{{ - error "getctime not implemented"; + my ($file) = @_; + + # 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); + open (my $out, "@cmdline |"); + + my @log = mercurial_log($out); + + if (length @log < 1) { + return 0; + } + + eval q{use Date::Parse}; + error($@) if $@; + + my $ctime = str2time($log[0]->{"date"}); + return $ctime; } #}}} 1