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_commit_staged ($$$) {
82 # Commits all staged changes. Changes can be staged using rcs_add,
83 # rcs_remove, and rcs_rename.
84 my ($message, $user, $ipaddr)=@_;
86 error("rcs_commit_staged not implemented for tla"); # TODO
89 sub rcs_add ($) { #{{{
92 if (-d "$config{srcdir}/{arch}") {
93 if (quiet_system("tla", "add", "$config{srcdir}/$file") != 0) {
94 warn("tla add failed\n");
99 sub rcs_remove ($) { # {{{
102 error("rcs_remove not implemented for tla"); # TODO
105 sub rcs_rename ($$) { # {{{a
106 my ($src, $dest) = @_;
108 error("rcs_rename not implemented for tla"); # TODO
111 sub rcs_recentchanges ($) {
115 return unless -d "$config{srcdir}/{arch}";
117 eval q{use Date::Parse};
119 eval q{use Mail::Header};
122 my $logs = `tla logs -d $config{srcdir}`;
123 my @changesets = reverse split(/\n/, $logs);
125 for (my $i=0; $i<$num && $i<$#changesets; $i++) {
126 my ($change)=$changesets[$i]=~/^([A-Za-z0-9@\/._-]+)$/; # untaint
128 open(LOG, "tla cat-log -d $config{srcdir} $change|");
129 my $head = Mail::Header->new(\*LOG);
132 my $rev = $head->get("Revision");
133 my $summ = $head->get("Summary");
134 my $newfiles = $head->get("New-files");
135 my $modfiles = $head->get("Modified-files");
136 my $remfiles = $head->get("Removed-files");
137 my $user = $head->get("Creator");
139 my @paths = grep { !/^(.*\/)?\.arch-ids\/.*\.id$/ }
140 split(/ /, "$newfiles $modfiles .arch-ids/fake.id");
142 my $sdate = $head->get("Standard-date");
143 my $when = str2time($sdate, 'UTC');
145 my $committype = "web";
146 if (defined $summ && $summ =~ /$config{web_commit_regexp}/) {
147 $user = defined $2 ? "$2" : "$3";
155 push @message, { line => $summ };
159 foreach my $file (@paths) {
160 my $diffurl=$config{diffurl};
161 $diffurl=~s/\[\[file\]\]/$file/g;
162 $diffurl=~s/\[\[rev\]\]/$change/g;
164 page => pagename($file),
171 committype => $committype,
173 message => [@message],
183 sub rcs_diff ($) { #{{{
185 my $logs = `tla logs -d $config{srcdir}`;
186 my @changesets = reverse split(/\n/, $logs);
189 for($i=0;$i<$#changesets;$i++) {
190 last if $changesets[$i] eq $rev;
193 my $revminusone = $changesets[$i+1];
194 return `tla diff -d $config{srcdir} $revminusone`;
197 sub rcs_getctime ($) { #{{{
199 eval q{use Date::Parse};
201 eval q{use Mail::Header};
204 my $logs = `tla logs -d $config{srcdir}`;
205 my @changesets = reverse split(/\n/, $logs);
208 for (my $i=0; $i<$#changesets; $i++) {
209 my $change = $changesets[$i];
211 open(LOG, "tla cat-log -d $config{srcdir} $change|");
212 my $head = Mail::Header->new(\*LOG);
215 $sdate = $head->get("Standard-date");
216 my $newfiles = $head->get("New-files");
218 my ($lastcreation) = grep {/^$file$/} split(/ /, "$newfiles");
219 last if defined($lastcreation);
222 my $date=str2time($sdate, 'UTC');
223 debug("found ctime ".localtime($date)." for $file");