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_recentchanges ($) {
95 return unless -d "$config{srcdir}/{arch}";
97 eval q{use Date::Parse};
99 eval q{use Mail::Header};
102 my $logs = `tla logs -d $config{srcdir}`;
103 my @changesets = reverse split(/\n/, $logs);
105 for (my $i=0; $i<$num && $i<$#changesets; $i++) {
106 my ($change)=$changesets[$i]=~/^([A-Za-z0-9@\/._-]+)$/; # untaint
108 open(LOG, "tla cat-log -d $config{srcdir} $change|");
109 my $head = Mail::Header->new(\*LOG);
112 my $rev = $head->get("Revision");
113 my $summ = $head->get("Summary");
114 my $newfiles = $head->get("New-files");
115 my $modfiles = $head->get("Modified-files");
116 my $remfiles = $head->get("Removed-files");
117 my $user = $head->get("Creator");
119 my @paths = grep { !/^(.*\/)?\.arch-ids\/.*\.id$/ }
120 split(/ /, "$newfiles $modfiles .arch-ids/fake.id");
122 my $sdate = $head->get("Standard-date");
123 my $when = str2time($sdate, 'UTC');
125 my $committype = "web";
126 if (defined $summ && $summ =~ /$config{web_commit_regexp}/) {
127 $user = defined $2 ? "$2" : "$3";
135 push @message, { line => $summ };
139 foreach my $file (@paths) {
140 my $diffurl=$config{diffurl};
141 $diffurl=~s/\[\[file\]\]/$file/g;
142 $diffurl=~s/\[\[rev\]\]/$change/g;
144 page => pagename($file),
151 committype => $committype,
153 message => [@message],
163 sub rcs_diff ($) { #{{{
165 my $logs = `tla logs -d $config{srcdir}`;
166 my @changesets = reverse split(/\n/, $logs);
169 for($i=0;$i<$#changesets;$i++) {
170 last if $changesets[$i] eq $rev;
173 my $revminusone = $changesets[$i+1];
174 return `tla diff -d $config{srcdir} $revminusone`;
177 sub rcs_getctime ($) { #{{{
179 eval q{use Date::Parse};
181 eval q{use Mail::Header};
184 my $logs = `tla logs -d $config{srcdir}`;
185 my @changesets = reverse split(/\n/, $logs);
188 for (my $i=0; $i<$#changesets; $i++) {
189 my $change = $changesets[$i];
191 open(LOG, "tla cat-log -d $config{srcdir} $change|");
192 my $head = Mail::Header->new(\*LOG);
195 $sdate = $head->get("Standard-date");
196 my $newfiles = $head->get("New-files");
198 my ($lastcreation) = grep {/^$file$/} split(/ /, "$newfiles");
199 last if defined($lastcreation);
202 my $date=str2time($sdate, 'UTC');
203 debug("found ctime ".localtime($date)." for $file");