10 # See Debian bug #385939.
11 open (SAVEOUT, ">&STDOUT");
13 open (STDOUT, ">/dev/null");
16 open (STDOUT, ">&SAVEOUT");
21 sub rcs_update () { #{{{
22 if (-d "$config{srcdir}/{arch}") {
23 if (quiet_system("tla", "replay", "-d", $config{srcdir}) != 0) {
24 warn("tla replay failed\n");
29 sub rcs_prepedit ($) { #{{{
32 if (-d "$config{srcdir}/{arch}") {
33 # For Arch, return the tree-id of archive when
35 my $rev=`tla tree-id $config{srcdir}`;
36 return defined $rev ? $rev : "";
40 sub rcs_commit ($$$;$$) { #{{{
48 $message="web commit by $user".(length $message ? ": $message" : "");
50 elsif (defined $ipaddr) {
51 $message="web commit from $ipaddr".(length $message ? ": $message" : "");
54 if (-d "$config{srcdir}/{arch}") {
55 # Check to see if the page has been changed by someone
56 # else since rcs_prepedit was called.
57 my ($oldrev)=$rcstoken=~/^([A-Za-z0-9@\/._-]+)$/; # untaint
58 my $rev=`tla tree-id $config{srcdir}`;
59 if (defined $rev && defined $oldrev && $rev ne $oldrev) {
60 # Merge their changes into the file that we've
62 if (quiet_system("tla", "update", "-d",
63 "$config{srcdir}") != 0) {
64 warn("tla update failed\n");
68 if (quiet_system("tla", "commit",
69 "-L".possibly_foolish_untaint($message),
70 '-d', $config{srcdir}) != 0) {
71 my $conflict=readfile("$config{srcdir}/$file");
72 if (system("tla", "undo", "-n", "--quiet", "-d", "$config{srcdir}") != 0) {
73 warn("tla undo failed\n");
78 return undef # success
81 sub rcs_add ($) { #{{{
84 if (-d "$config{srcdir}/{arch}") {
85 if (quiet_system("tla", "add", "$config{srcdir}/$file") != 0) {
86 warn("tla add failed\n");
91 sub rcs_remove ($) { # {{{
94 error("rcs_remove not implemented for tla"); # TODO
97 sub rcs_recentchanges ($) {
101 return unless -d "$config{srcdir}/{arch}";
103 eval q{use Date::Parse};
105 eval q{use Mail::Header};
108 my $logs = `tla logs -d $config{srcdir}`;
109 my @changesets = reverse split(/\n/, $logs);
111 for (my $i=0; $i<$num && $i<$#changesets; $i++) {
112 my ($change)=$changesets[$i]=~/^([A-Za-z0-9@\/._-]+)$/; # untaint
114 open(LOG, "tla cat-log -d $config{srcdir} $change|");
115 my $head = Mail::Header->new(\*LOG);
118 my $rev = $head->get("Revision");
119 my $summ = $head->get("Summary");
120 my $newfiles = $head->get("New-files");
121 my $modfiles = $head->get("Modified-files");
122 my $remfiles = $head->get("Removed-files");
123 my $user = $head->get("Creator");
125 my @paths = grep { !/^(.*\/)?\.arch-ids\/.*\.id$/ }
126 split(/ /, "$newfiles $modfiles .arch-ids/fake.id");
128 my $sdate = $head->get("Standard-date");
129 my $when = str2time($sdate, 'UTC');
131 my $committype = "web";
132 if (defined $summ && $summ =~ /$config{web_commit_regexp}/) {
133 $user = defined $2 ? "$2" : "$3";
141 push @message, { line => $summ };
145 foreach my $file (@paths) {
146 my $diffurl=$config{diffurl};
147 $diffurl=~s/\[\[file\]\]/$file/g;
148 $diffurl=~s/\[\[rev\]\]/$change/g;
150 page => pagename($file),
157 committype => $committype,
159 message => [@message],
169 sub rcs_diff ($) { #{{{
171 my $logs = `tla logs -d $config{srcdir}`;
172 my @changesets = reverse split(/\n/, $logs);
175 for($i=0;$i<$#changesets;$i++) {
176 last if $changesets[$i] eq $rev;
179 my $revminusone = $changesets[$i+1];
180 return `tla diff -d $config{srcdir} $revminusone`;
183 sub rcs_getctime ($) { #{{{
185 eval q{use Date::Parse};
187 eval q{use Mail::Header};
190 my $logs = `tla logs -d $config{srcdir}`;
191 my @changesets = reverse split(/\n/, $logs);
194 for (my $i=0; $i<$#changesets; $i++) {
195 my $change = $changesets[$i];
197 open(LOG, "tla cat-log -d $config{srcdir} $change|");
198 my $head = Mail::Header->new(\*LOG);
201 $sdate = $head->get("Standard-date");
202 my $newfiles = $head->get("New-files");
204 my ($lastcreation) = grep {/^$file$/} split(/ /, "$newfiles");
205 last if defined($lastcreation);
208 my $date=str2time($sdate, 'UTC');
209 debug("found ctime ".localtime($date)." for $file");