X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/35ee7e44a62f9126a83c1243b549d47cc5ca7b43..f65fa0ad680fb38b560ae0a459ce6b043f9631ac:/IkiWiki/Rcs/mercurial.pm diff --git a/IkiWiki/Rcs/mercurial.pm b/IkiWiki/Rcs/mercurial.pm index 36972c560..67002ac57 100644 --- a/IkiWiki/Rcs/mercurial.pm +++ b/IkiWiki/Rcs/mercurial.pm @@ -65,12 +65,23 @@ sub rcs_prepedit ($) { #{{{ return ""; } #}}} -sub rcs_commit ($$$) { #{{{ - my ($file, $message, $rcstoken) = @_; +sub rcs_commit ($$$;$$) { #{{{ + my ($file, $message, $rcstoken, $user, $ipaddr) = @_; + + if (defined $user) { + $user = possibly_foolish_untaint($user); + } + elsif (defined $ipaddr) { + $user = "Anonymous from $ipaddr"; + } + else { + $user = "Anonymous"; + } $message = possibly_foolish_untaint($message); - my @cmdline = ("hg", "-R", "$config{srcdir}", "commit", "-m", "$message"); + my @cmdline = ("hg", "-R", "$config{srcdir}", "commit", + "-m", "$message", "-u", "$user"); if (system(@cmdline) != 0) { warn "'@cmdline' failed: $!"; } @@ -96,6 +107,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 = (); @@ -124,7 +138,7 @@ sub rcs_recentchanges ($) { #{{{ rev => $info->{"changeset"}, user => $user, committype => "mercurial", - when => $info->{"date"}, + when => str2time($info->{"date"}), message => [@message], pages => [@pages], }; @@ -138,7 +152,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