9 use open qw{:utf8 :std};
11 sub mercurial_log($) {
19 if (/^description:/) {
23 # slurp everything as the description text
24 # until the next changeset
36 $infos[$#infos]{$key} = $value;
40 ($key, $value) = split /: +/, $line, 2;
42 if ($key eq "changeset") {
45 # remove the revision index, which is strictly
46 # local to the repository
50 $infos[$#infos]{$key} = $value;
57 sub rcs_update () { #{{{
58 my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "update");
59 if (system(@cmdline) != 0) {
60 warn "'@cmdline' failed: $!";
64 sub rcs_prepedit ($) { #{{{
68 sub rcs_commit ($$$;$$) { #{{{
69 my ($file, $message, $rcstoken, $user, $ipaddr) = @_;
72 $user = possibly_foolish_untaint($user);
74 elsif (defined $ipaddr) {
75 $user = "Anonymous from ".possibly_foolish_untaint($ipaddr);
81 $message = possibly_foolish_untaint($message);
82 if (! length $message) {
83 $message = "no message given";
86 my @cmdline = ("hg", "-q", "-R", $config{srcdir}, "commit",
87 "-m", $message, "-u", $user);
88 if (system(@cmdline) != 0) {
89 warn "'@cmdline' failed: $!";
92 return undef; # success
95 sub rcs_commit_staged ($$$) {
96 # Commits all staged changes. Changes can be staged using rcs_add,
97 # rcs_remove, and rcs_rename.
98 my ($message, $user, $ipaddr)=@_;
100 error("rcs_commit_staged not implemented for mercurial"); # TODO
103 sub rcs_add ($) { # {{{
106 my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "add", "$config{srcdir}/$file");
107 if (system(@cmdline) != 0) {
108 warn "'@cmdline' failed: $!";
112 sub rcs_remove ($) { # {{{
115 error("rcs_remove not implemented for mercurial"); # TODO
118 sub rcs_rename ($$) { # {{{
119 my ($src, $dest) = @_;
121 error("rcs_rename not implemented for mercurial"); # TODO
124 sub rcs_recentchanges ($) { #{{{
127 my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num,
128 "--style", "default");
129 open (my $out, "@cmdline |");
131 eval q{use Date::Parse};
135 foreach my $info (mercurial_log($out)) {
139 foreach my $msgline (split(/\n/, $info->{description})) {
140 push @message, { line => $msgline };
143 foreach my $file (split / /,$info->{files}) {
144 my $diffurl = $config{'diffurl'};
145 $diffurl =~ s/\[\[file\]\]/$file/go;
146 $diffurl =~ s/\[\[r2\]\]/$info->{changeset}/go;
149 page => pagename($file),
154 my $user = $info->{"user"};
155 $user =~ s/\s*<.*>\s*$//;
159 rev => $info->{"changeset"},
161 committype => "mercurial",
162 when => str2time($info->{"date"}),
163 message => [@message],
171 sub rcs_diff ($) { #{{{
175 sub rcs_getctime ($) { #{{{
178 # XXX filename passes through the shell here, should try to avoid
180 my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", '1',
181 "--style", "default", "$config{srcdir}/$file");
182 open (my $out, "@cmdline |");
184 my @log = mercurial_log($out);
186 if (length @log < 1) {
190 eval q{use Date::Parse};
193 my $ctime = str2time($log[0]->{"date"});