hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
my $hash = darcs_info('hash', $repodir, $file);
return defined $hash ? $hash : "";
}
my $hash = darcs_info('hash', $repodir, $file);
return defined $hash ? $hash : "";
}
if (defined $config{darcs_wrapper} && length $config{darcs_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{darcs_wrapper},
if (defined $config{darcs_wrapper} && length $config{darcs_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{darcs_wrapper},
-sub rcs_commit ($$$;$$) {
+sub commitauthor (@) {
+ my %params=@_;
+
+ my $author="anon\@web";
+ if (defined $params{session}) {
+ if (defined $params{session}->param("name")) {
+ return IkiWiki::cloak($params{session}->param("name")).'@web';
+ }
+ elsif (defined $params{session}->remote_addr()) {
+ return IkiWiki::cloak($params{session}->remote_addr()).'@web';
+ }
+ }
+ return 'anon@web';
+}
+
+sub rcs_commit (@) {
# Commit the page. Returns 'undef' on success and a version of the page
# with conflict markers on failure.
# Commit the page. Returns 'undef' on success and a version of the page
# with conflict markers on failure.
- my ($file, $message, $rcstoken, $user, $ipaddr) = @_;
+ my ($file, $message, $token) =
+ ($params{file}, $params{message}, $params{token});
rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or
error("failed to rename $file to $file.save: $!");
rename("$config{srcdir}/$file", "$config{srcdir}/$file.save") or
error("failed to rename $file to $file.save: $!");
# TODO. Can we be sure that no changes are lost? I think that
# we can, if we make sure that the 'darcs push' below will always
# TODO. Can we be sure that no changes are lost? I think that
# we can, if we make sure that the 'darcs push' below will always
# TODO: 'yes | ...' needed? Doesn't seem so.
silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") == 0 ||
error("'darcs revert' failed");
# TODO: 'yes | ...' needed? Doesn't seem so.
silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") == 0 ||
error("'darcs revert' failed");
my $child = open(DARCS_OBLITERATE, "|-");
if (! $child) {
open(STDOUT, ">/dev/null");
exec('darcs', "obliterate", "--repodir", $config{srcdir},
my $child = open(DARCS_OBLITERATE, "|-");
if (! $child) {
open(STDOUT, ">/dev/null");
exec('darcs', "obliterate", "--repodir", $config{srcdir},
silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir},
silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir},
rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or
error("failed to rename $file.save to $file: $!");
}
# Record the changes.
rename("$config{srcdir}/$file.save", "$config{srcdir}/$file") or
error("failed to rename $file.save to $file: $!");
}
# Record the changes.
# If this updating yields any conflicts, we'll record them now to resolve
# them. If nothing is recorded, there are no conflicts.
# If this updating yields any conflicts, we'll record them now to resolve
# them. If nothing is recorded, there are no conflicts.
# TODO: Use only the first line here, i.e. only the patch name?
writefile("$file.log", $config{srcdir}, 'resolve conflicts: ' . $message);
silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all',
'-m', 'resolve conflicts: ' . $message, '--author', $author, $file) == 0 ||
error("'darcs record' failed");
# TODO: Use only the first line here, i.e. only the patch name?
writefile("$file.log", $config{srcdir}, 'resolve conflicts: ' . $message);
silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all',
'-m', 'resolve conflicts: ' . $message, '--author', $author, $file) == 0 ||
error("'darcs record' failed");
- my $author;
- if (defined $user) {
- $author = "$user\@web";
- }
- elsif (defined $ipaddr) {
- $author = "$ipaddr\@web";
- }
- else {
- $author = "anon\@web";
- }
- if (!defined $message || !length($message)) {
- $message = "empty message";
+ my $author=commitauthor(%params);
+ if (!defined $params{message} || !length($params{message})) {
+ $params{message} = "empty message";
- silentsystem('darcs', "record", "--repodir", $config{srcdir}, "-a", "-A", $author,
- "-m", $message) == 0 || error("'darcs record' failed");
+ silentsystem('darcs', "record", "--repodir", $config{srcdir},
+ "-a", "-A", $author,
+ "-m", $params{message},
+ ) == 0 || error("'darcs record' failed");
# Push the changes to the main repository.
silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') == 0 ||
# Push the changes to the main repository.
silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all') == 0 ||
my $child = open(LOG, "-|");
if (! $child) {
$ENV{"DARCS_DONT_ESCAPE_ANYTHING"}=1;
my $child = open(LOG, "-|");
if (! $child) {
$ENV{"DARCS_DONT_ESCAPE_ANYTHING"}=1;
foreach my $patch (@{$log->{patch}}) {
my $date=$patch->{local_date};
my $hash=$patch->{hash};
my $when=str2time($date);
my (@pages, @files, @pg);
foreach my $patch (@{$log->{patch}}) {
my $date=$patch->{local_date};
my $hash=$patch->{hash};
my $when=str2time($date);
my (@pages, @files, @pg);
- push @pages, $_ for (@{$patch->{summary}->[0]->{modify_file}});
- push @pages, $_ for (@{$patch->{summary}->[0]->{add_file}});
- push @pages, $_ for (@{$patch->{summary}->[0]->{remove_file}});
+ push @pages, $_ foreach (@{$patch->{summary}->[0]->{modify_file}});
+ push @pages, $_ foreach (@{$patch->{summary}->[0]->{add_file}});
+ push @pages, $_ foreach (@{$patch->{summary}->[0]->{remove_file}});
foreach my $f (@pages) {
$f = $f->{content} if ref $f;
$f =~ s,^\s+,,; $f =~ s,\s+$,,; # cut whitespace
foreach my $f (@pages) {
$f = $f->{content} if ref $f;
$f =~ s,^\s+,,; $f =~ s,\s+$,,; # cut whitespace
- foreach my $line (silentsystem("darcs", "diff", "--match", "hash ".$rev)) {
+ my $repodir=$config{srcdir};
+ foreach my $line (`darcs diff --repodir $repodir --match 'hash $rev'`) {
my $child = open(LOG, "-|");
if (! $child) {
exec("darcs", "changes", "--xml", "--reverse",
my $child = open(LOG, "-|");
if (! $child) {
exec("darcs", "changes", "--xml", "--reverse",
- "--repodir", "$repodir", "$filer")
- || error("'darcs changes $filer' failed to run");
+ "--repodir", $config{srcdir}, $file)
+ || error("'darcs changes $file' failed to run");