summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/monotone.pm
blob: 38313a542aff9bd231b036ae3d47367f55289578 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::monotone;
  3. use warnings;
  4. use strict;
  5. use IkiWiki;
  6. use Monotone;
  7. use Date::Parse qw(str2time);
  8. use Date::Format qw(time2str);
  9. my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate sha1sums
  10. sub import {
  11. hook(type => "checkconfig", id => "monotone", call => \&checkconfig);
  12. hook(type => "getsetup", id => "monotone", call => \&getsetup);
  13. hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
  14. hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
  15. hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
  16. hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged);
  17. hook(type => "rcs", id => "rcs_add", call => \&rcs_add);
  18. hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove);
  19. hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename);
  20. hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
  21. hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
  22. hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
  23. hook(type => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime);
  24. }
  25. sub checkconfig () {
  26. if (!defined($config{mtnrootdir})) {
  27. $config{mtnrootdir} = $config{srcdir};
  28. }
  29. if (! -d "$config{mtnrootdir}/_MTN") {
  30. error("Ikiwiki srcdir does not seem to be a Monotone workspace (or set the mtnrootdir)!");
  31. }
  32. my $child = open(MTN, "-|");
  33. if (! $child) {
  34. open STDERR, ">/dev/null";
  35. exec("mtn", "version") || error("mtn version failed to run");
  36. }
  37. my $version=undef;
  38. while (<MTN>) {
  39. if (/^monotone (\d+\.\d+)(?:(?:\.\d+){0,2}|dev)? /) {
  40. $version=$1;
  41. }
  42. }
  43. close MTN || debug("mtn version exited $?");
  44. if (!defined($version)) {
  45. error("Cannot determine monotone version");
  46. }
  47. if ($version < 0.38) {
  48. error("Monotone version too old, is $version but required 0.38");
  49. }
  50. if (defined $config{mtn_wrapper} && length $config{mtn_wrapper}) {
  51. push @{$config{wrappers}}, {
  52. wrapper => $config{mtn_wrapper},
  53. wrappermode => (defined $config{mtn_wrappermode} ? $config{mtn_wrappermode} : "06755"),
  54. };
  55. }
  56. }
  57. sub getsetup () {
  58. return
  59. plugin => {
  60. safe => 0, # rcs plugin
  61. rebuild => undef,
  62. section => "rcs",
  63. },
  64. mtn_wrapper => {
  65. type => "string",
  66. example => "/srv/mtn/wiki/_MTN/ikiwiki-netsync-hook",
  67. description => "monotone netsync hook to generate",
  68. safe => 0, # file
  69. rebuild => 0,
  70. },
  71. mtn_wrappermode => {
  72. type => "string",
  73. example => '06755',
  74. description => "mode for mtn_wrapper (can safely be made suid)",
  75. safe => 0,
  76. rebuild => 0,
  77. },
  78. mtnkey => {
  79. type => "string",
  80. example => 'web@example.com',
  81. description => "your monotone key",
  82. safe => 1,
  83. rebuild => 0,
  84. },
  85. historyurl => {
  86. type => "string",
  87. example => "http://viewmtn.example.com/branch/head/filechanges/com.example.branch/[[file]]",
  88. description => "viewmtn url to show file history ([[file]] substituted)",
  89. safe => 1,
  90. rebuild => 1,
  91. },
  92. diffurl => {
  93. type => "string",
  94. example => "http://viewmtn.example.com/revision/diff/[[r1]]/with/[[r2]]/[[file]]",
  95. description => "viewmtn url to show a diff ([[r1]], [[r2]], and [[file]] substituted)",
  96. safe => 1,
  97. rebuild => 1,
  98. },
  99. mtnsync => {
  100. type => "boolean",
  101. example => 0,
  102. description => "sync on update and commit?",
  103. safe => 0, # paranoia
  104. rebuild => 0,
  105. },
  106. mtnrootdir => {
  107. type => "string",
  108. description => "path to your workspace (defaults to the srcdir; specify if the srcdir is a subdirectory of the workspace)",
  109. safe => 0, # path
  110. rebuild => 0,
  111. },
  112. }
  113. sub get_rev () {
  114. my $sha1 = `mtn --root=$config{mtnrootdir} automate get_base_revision_id`;
  115. ($sha1) = $sha1 =~ m/($sha1_pattern)/; # sha1 is untainted now
  116. if (! $sha1) {
  117. debug("Unable to get base revision for '$config{srcdir}'.")
  118. }
  119. return $sha1;
  120. }
  121. sub get_rev_auto ($) {
  122. my $automator=shift;
  123. my @results = $automator->call("get_base_revision_id");
  124. my $sha1 = $results[0];
  125. ($sha1) = $sha1 =~ m/($sha1_pattern)/; # sha1 is untainted now
  126. if (! $sha1) {
  127. debug("Unable to get base revision for '$config{srcdir}'.")
  128. }
  129. return $sha1;
  130. }
  131. sub mtn_merge ($$$$) {
  132. my $leftRev=shift;
  133. my $rightRev=shift;
  134. my $branch=shift;
  135. my $author=shift;
  136. my $mergeRev;
  137. my $child = open(MTNMERGE, "-|");
  138. if (! $child) {
  139. open STDERR, ">&STDOUT";
  140. exec("mtn", "--root=$config{mtnrootdir}",
  141. "explicit_merge", $leftRev, $rightRev,
  142. $branch, "--author", $author, "--key",
  143. $config{mtnkey}) || error("mtn merge failed to run");
  144. }
  145. while (<MTNMERGE>) {
  146. if (/^mtn.\s.merged.\s($sha1_pattern)$/) {
  147. $mergeRev=$1;
  148. }
  149. }
  150. close MTNMERGE || return undef;
  151. debug("merged $leftRev, $rightRev to make $mergeRev");
  152. return $mergeRev;
  153. }
  154. sub commit_file_to_new_rev ($$$$$$$$) {
  155. my $automator=shift;
  156. my $wsfilename=shift;
  157. my $oldFileID=shift;
  158. my $newFileContents=shift;
  159. my $oldrev=shift;
  160. my $branch=shift;
  161. my $author=shift;
  162. my $message=shift;
  163. #store the file
  164. my ($out, $err) = $automator->call("put_file", $oldFileID, $newFileContents);
  165. my ($newFileID) = ($out =~ m/^($sha1_pattern)$/);
  166. error("Failed to store file data for $wsfilename in repository")
  167. if (! defined $newFileID || length $newFileID != 40);
  168. # get the mtn filename rather than the workspace filename
  169. ($out, $err) = $automator->call("get_corresponding_path", $oldrev, $wsfilename, $oldrev);
  170. my ($filename) = ($out =~ m/^file "(.*)"$/);
  171. error("Couldn't find monotone repository path for file $wsfilename") if (! $filename);
  172. debug("Converted ws filename of $wsfilename to repos filename of $filename");
  173. # then stick in a new revision for this file
  174. my $manifest = "format_version \"1\"\n\n".
  175. "new_manifest [0000000000000000000000000000000000000000]\n\n".
  176. "old_revision [$oldrev]\n\n".
  177. "patch \"$filename\"\n".
  178. " from [$oldFileID]\n".
  179. " to [$newFileID]\n";
  180. ($out, $err) = $automator->call("put_revision", $manifest);
  181. my ($newRevID) = ($out =~ m/^($sha1_pattern)$/);
  182. error("Unable to make new monotone repository revision")
  183. if (! defined $newRevID || length $newRevID != 40);
  184. debug("put revision: $newRevID");
  185. # now we need to add certs for this revision...
  186. # author, branch, changelog, date
  187. $automator->call("cert", $newRevID, "author", $author);
  188. $automator->call("cert", $newRevID, "branch", $branch);
  189. $automator->call("cert", $newRevID, "changelog", $message);
  190. $automator->call("cert", $newRevID, "date",
  191. time2str("%Y-%m-%dT%T", time, "UTC"));
  192. debug("Added certs for rev: $newRevID");
  193. return $newRevID;
  194. }
  195. sub read_certs ($$) {
  196. my $automator=shift;
  197. my $rev=shift;
  198. my @results = $automator->call("certs", $rev);
  199. my @ret;
  200. my $line = $results[0];
  201. while ($line =~ m/\s+key\s["\[](.*?)[\]"]\nsignature\s"(ok|bad|unknown)"\n\s+name\s"(.*?)"\n\s+value\s"(.*?)"\n\s+trust\s"(trusted|untrusted)"\n/sg) {
  202. push @ret, {
  203. key => $1,
  204. signature => $2,
  205. name => $3,
  206. value => $4,
  207. trust => $5,
  208. };
  209. }
  210. return @ret;
  211. }
  212. sub get_changed_files ($$) {
  213. my $automator=shift;
  214. my $rev=shift;
  215. my @results = $automator->call("get_revision", $rev);
  216. my $changes=$results[0];
  217. my @ret;
  218. my %seen = ();
  219. # we need to strip off the relative path to the source dir
  220. # because monotone outputs all file paths absolute according
  221. # to the workspace root
  222. my $rel_src_dir = $config{'srcdir'};
  223. $rel_src_dir =~ s/^\Q$config{'mtnrootdir'}\E\/?//;
  224. $rel_src_dir .= "/" if length $rel_src_dir;
  225. while ($changes =~ m/\s*(add_file|patch|delete|rename)\s"(.*?)(?<!\\)"\n/sg) {
  226. my $file = $2;
  227. # ignore all file changes outside the source dir
  228. next unless $file =~ m/^\Q$rel_src_dir\E/;
  229. $file =~ s/^\Q$rel_src_dir\E//;
  230. # don't add the same file multiple times
  231. if (! $seen{$file}) {
  232. push @ret, $file;
  233. $seen{$file} = 1;
  234. }
  235. }
  236. return @ret;
  237. }
  238. sub rcs_update () {
  239. chdir $config{srcdir}
  240. or error("Cannot chdir to $config{srcdir}: $!");
  241. if (defined($config{mtnsync}) && $config{mtnsync}) {
  242. if (system("mtn", "--root=$config{mtnrootdir}", "sync",
  243. "--quiet", "--ticker=none",
  244. "--key", $config{mtnkey}) != 0) {
  245. debug("monotone sync failed before update");
  246. }
  247. }
  248. if (system("mtn", "--root=$config{mtnrootdir}", "update", "--quiet") != 0) {
  249. debug("monotone update failed");
  250. }
  251. }
  252. sub rcs_prepedit ($) {
  253. my $file=shift;
  254. chdir $config{srcdir}
  255. or error("Cannot chdir to $config{srcdir}: $!");
  256. # For monotone, return the revision of the file when
  257. # editing begins.
  258. return get_rev();
  259. }
  260. sub commitauthor (@) {
  261. my %params=@_;
  262. if (defined $params{session}) {
  263. if (defined $params{session}->param("name")) {
  264. return "Web user: " . $params{session}->param("name");
  265. }
  266. elsif (defined $params{session}->remote_addr()) {
  267. return "Web IP: " . $params{session}->remote_addr();
  268. }
  269. }
  270. return "Web: Anonymous";
  271. }
  272. sub rcs_commit (@) {
  273. # Tries to commit the page; returns undef on _success_ and
  274. # a version of the page with the rcs's conflict markers on failure.
  275. # The file is relative to the srcdir.
  276. my %params=@_;
  277. my $author=IkiWiki::possibly_foolish_untaint(commitauthor(%params)),
  278. chdir $config{srcdir}
  279. or error("Cannot chdir to $config{srcdir}: $!");
  280. my ($oldrev) = $params{token} =~ m/^($sha1_pattern)$/; # untaint
  281. my $rev = get_rev();
  282. if (defined $rev && defined $oldrev && $rev ne $oldrev) {
  283. my $automator = Monotone->new();
  284. $automator->open_args("--root", $config{mtnrootdir}, "--key", $config{mtnkey});
  285. # Something has been committed, has this file changed?
  286. my ($out, $err);
  287. $automator->setOpts("r", $oldrev, "r", $rev);
  288. ($out, $err) = $automator->call("content_diff", $params{file});
  289. debug("Problem committing $params{file}") if ($err ne "");
  290. my $diff = $out;
  291. if ($diff) {
  292. # Commit a revision with just this file changed off
  293. # the old revision.
  294. #
  295. # first get the contents
  296. debug("File changed: forming branch");
  297. my $newfile=readfile("$config{srcdir}/$params{file}");
  298. # then get the old content ID from the diff
  299. if ($diff !~ m/^---\s$params{file}\s+($sha1_pattern)$/m) {
  300. error("Unable to find previous file ID for $params{file}");
  301. }
  302. my $oldFileID = $1;
  303. # get the branch we're working in
  304. ($out, $err) = $automator->call("get_option", "branch");
  305. chomp $out;
  306. error("Illegal branch name in monotone workspace") if ($out !~ m/^([-\@\w\.]+)$/);
  307. my $branch = $1;
  308. # then put the new content into the DB (and record the new content ID)
  309. my $newRevID = commit_file_to_new_rev($automator, $params{file}, $oldFileID, $newfile, $oldrev, $branch, $author, $params{message});
  310. $automator->close();
  311. # if we made it to here then the file has been committed... revert the local copy
  312. if (system("mtn", "--root=$config{mtnrootdir}", "revert", $params{file}) != 0) {
  313. debug("Unable to revert $params{file} after merge on conflicted commit!");
  314. }
  315. debug("Divergence created! Attempting auto-merge.");
  316. # see if it will merge cleanly
  317. $ENV{MTN_MERGE}="fail";
  318. my $mergeResult = mtn_merge($newRevID, $rev, $branch, $author);
  319. $ENV{MTN_MERGE}="";
  320. # push any changes so far
  321. if (defined($config{mtnsync}) && $config{mtnsync}) {
  322. if (system("mtn", "--root=$config{mtnrootdir}", "push", "--quiet", "--ticker=none", "--key", $config{mtnkey}) != 0) {
  323. debug("monotone push failed");
  324. }
  325. }
  326. if (defined($mergeResult)) {
  327. # everything is merged - bring outselves up to date
  328. if (system("mtn", "--root=$config{mtnrootdir}",
  329. "update", "-r", $mergeResult) != 0) {
  330. debug("Unable to update to rev $mergeResult after merge on conflicted commit!");
  331. }
  332. }
  333. else {
  334. debug("Auto-merge failed. Using diff-merge to add conflict markers.");
  335. $ENV{MTN_MERGE}="diffutils";
  336. $ENV{MTN_MERGE_DIFFUTILS}="partial=true";
  337. $mergeResult = mtn_merge($newRevID, $rev, $branch, $author);
  338. $ENV{MTN_MERGE}="";
  339. $ENV{MTN_MERGE_DIFFUTILS}="";
  340. if (!defined($mergeResult)) {
  341. debug("Unable to insert conflict markers!");
  342. error("Your commit succeeded. Unfortunately, someone else committed something to the same ".
  343. "part of the wiki at the same time. Both versions are stored in the monotone repository, ".
  344. "but at present the different versions cannot be reconciled through the web interface. ".
  345. "Please use the non-web interface to resolve the conflicts.");
  346. }
  347. if (system("mtn", "--root=$config{mtnrootdir}",
  348. "update", "-r", $mergeResult) != 0) {
  349. debug("Unable to update to rev $mergeResult after conflict-enhanced merge on conflicted commit!");
  350. }
  351. # return "conflict enhanced" file to the user
  352. # for cleanup note, this relies on the fact
  353. # that ikiwiki seems to call rcs_prepedit()
  354. # again after we return
  355. return readfile("$config{srcdir}/$params{file}");
  356. }
  357. return undef;
  358. }
  359. $automator->close();
  360. }
  361. # If we reached here then the file we're looking at hasn't changed
  362. # since $oldrev. Commit it.
  363. if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet",
  364. "--author", $author, "--key", $config{mtnkey}, "-m",
  365. IkiWiki::possibly_foolish_untaint($params{message}),
  366. $params{file}) != 0) {
  367. debug("Traditional commit failed! Returning data as conflict.");
  368. my $conflict=readfile("$config{srcdir}/$params{file}");
  369. if (system("mtn", "--root=$config{mtnrootdir}", "revert",
  370. "--quiet", $params{file}) != 0) {
  371. debug("monotone revert failed");
  372. }
  373. return $conflict;
  374. }
  375. if (defined($config{mtnsync}) && $config{mtnsync}) {
  376. if (system("mtn", "--root=$config{mtnrootdir}", "push",
  377. "--quiet", "--ticker=none", "--key",
  378. $config{mtnkey}) != 0) {
  379. debug("monotone push failed");
  380. }
  381. }
  382. return undef # success
  383. }
  384. sub rcs_commit_staged (@) {
  385. # Commits all staged changes. Changes can be staged using rcs_add,
  386. # rcs_remove, and rcs_rename.
  387. my %params=@_;
  388. # Note - this will also commit any spurious changes that happen to be
  389. # lying around in the working copy. There shouldn't be any, but...
  390. chdir $config{srcdir}
  391. or error("Cannot chdir to $config{srcdir}: $!");
  392. if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet",
  393. "--author", IkiWiki::possibly_foolish_untaint(commitauthor(%params)),
  394. "--key", $config{mtnkey}, "-m",
  395. IkiWiki::possibly_foolish_untaint($params{message})) != 0) {
  396. error("Monotone commit failed");
  397. }
  398. }
  399. sub rcs_add ($) {
  400. my $file=shift;
  401. chdir $config{srcdir}
  402. or error("Cannot chdir to $config{srcdir}: $!");
  403. if (system("mtn", "--root=$config{mtnrootdir}", "add", "--quiet",
  404. $file) != 0) {
  405. error("Monotone add failed");
  406. }
  407. }
  408. sub rcs_remove ($) {
  409. my $file = shift;
  410. chdir $config{srcdir}
  411. or error("Cannot chdir to $config{srcdir}: $!");
  412. # Note: it is difficult to undo a remove in Monotone at the moment.
  413. # Until this is fixed, it might be better to make 'rm' move things
  414. # into an attic, rather than actually remove them.
  415. # To resurrect a file, you currently add a new file with the contents
  416. # you want it to have. This loses all connectivity and automated
  417. # merging with the 'pre-delete' versions of the file.
  418. if (system("mtn", "--root=$config{mtnrootdir}", "rm", "--quiet",
  419. $file) != 0) {
  420. error("Monotone remove failed");
  421. }
  422. }
  423. sub rcs_rename ($$) {
  424. my ($src, $dest) = @_;
  425. chdir $config{srcdir}
  426. or error("Cannot chdir to $config{srcdir}: $!");
  427. if (system("mtn", "--root=$config{mtnrootdir}", "rename", "--quiet",
  428. $src, $dest) != 0) {
  429. error("Monotone rename failed");
  430. }
  431. }
  432. sub rcs_recentchanges ($) {
  433. my $num=shift;
  434. my @ret;
  435. chdir $config{srcdir}
  436. or error("Cannot chdir to $config{srcdir}: $!");
  437. # use log --brief to get a list of revs, as this
  438. # gives the results in a nice order
  439. # (otherwise we'd have to do our own date sorting)
  440. my @revs;
  441. my $child = open(MTNLOG, "-|");
  442. if (! $child) {
  443. exec("mtn", "log", "--root=$config{mtnrootdir}", "--no-graph",
  444. "--brief", "--last=$num") || error("mtn log failed to run");
  445. }
  446. while (my $line = <MTNLOG>) {
  447. if ($line =~ m/^($sha1_pattern)/) {
  448. push @revs, $1;
  449. }
  450. }
  451. close MTNLOG || debug("mtn log exited $?");
  452. my $automator = Monotone->new();
  453. $automator->open(undef, $config{mtnrootdir});
  454. while (@revs != 0) {
  455. my $rev = shift @revs;
  456. # first go through and figure out the messages, etc
  457. my $certs = [read_certs($automator, $rev)];
  458. my $user;
  459. my $when;
  460. my $committype;
  461. my (@pages, @message);
  462. foreach my $cert (@$certs) {
  463. if ($cert->{signature} eq "ok" &&
  464. $cert->{trust} eq "trusted") {
  465. if ($cert->{name} eq "author") {
  466. $user = $cert->{value};
  467. # detect the source of the commit
  468. # from the changelog
  469. if ($cert->{key} eq $config{mtnkey}) {
  470. $committype = "web";
  471. }
  472. else {
  473. $committype = "mtn";
  474. }
  475. } elsif ($cert->{name} eq "date") {
  476. $when = str2time($cert->{value}, 'UTC');
  477. } elsif ($cert->{name} eq "changelog") {
  478. my $messageText = $cert->{value};
  479. # split the changelog into multiple
  480. # lines
  481. foreach my $msgline (split(/\n/, $messageText)) {
  482. push @message, { line => $msgline };
  483. }
  484. }
  485. }
  486. }
  487. my @changed_files = get_changed_files($automator, $rev);
  488. my ($out, $err) = $automator->call("parents", $rev);
  489. my @parents = ($out =~ m/^($sha1_pattern)$/);
  490. my $parent = $parents[0];
  491. foreach my $file (@changed_files) {
  492. next unless length $file;
  493. if (defined $config{diffurl} and (@parents == 1)) {
  494. my $diffurl=$config{diffurl};
  495. $diffurl=~s/\[\[r1\]\]/$parent/g;
  496. $diffurl=~s/\[\[r2\]\]/$rev/g;
  497. $diffurl=~s/\[\[file\]\]/$file/g;
  498. push @pages, {
  499. page => pagename($file),
  500. diffurl => $diffurl,
  501. };
  502. }
  503. else {
  504. push @pages, {
  505. page => pagename($file),
  506. }
  507. }
  508. }
  509. push @ret, {
  510. rev => $rev,
  511. user => $user,
  512. committype => $committype,
  513. when => $when,
  514. message => [@message],
  515. pages => [@pages],
  516. } if @pages;
  517. }
  518. $automator->close();
  519. return @ret;
  520. }
  521. sub rcs_diff ($;$) {
  522. my $rev=shift;
  523. my $maxlines=shift;
  524. my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
  525. chdir $config{srcdir}
  526. or error("Cannot chdir to $config{srcdir}: $!");
  527. my $child = open(MTNDIFF, "-|");
  528. if (! $child) {
  529. exec("mtn", "diff", "--root=$config{mtnrootdir}", "-r", "p:".$sha1, "-r", $sha1) || error("mtn diff $sha1 failed to run");
  530. }
  531. my @lines;
  532. while (my $line=<MTNDIFF>) {
  533. last if defined $maxlines && @lines == $maxlines;
  534. push @lines, $line;
  535. }
  536. close MTNDIFF || debug("mtn diff $sha1 exited $?");
  537. if (wantarray) {
  538. return @lines;
  539. }
  540. else {
  541. return join("", @lines);
  542. }
  543. }
  544. sub rcs_getctime ($) {
  545. my $file=shift;
  546. chdir $config{srcdir}
  547. or error("Cannot chdir to $config{srcdir}: $!");
  548. my $child = open(MTNLOG, "-|");
  549. if (! $child) {
  550. exec("mtn", "log", "--root=$config{mtnrootdir}", "--no-graph",
  551. "--brief", $file) || error("mtn log $file failed to run");
  552. }
  553. my $firstRev;
  554. while (<MTNLOG>) {
  555. if (/^($sha1_pattern)/) {
  556. $firstRev=$1;
  557. }
  558. }
  559. close MTNLOG || debug("mtn log $file exited $?");
  560. if (! defined $firstRev) {
  561. debug "failed to parse mtn log for $file";
  562. return 0;
  563. }
  564. my $automator = Monotone->new();
  565. $automator->open(undef, $config{mtnrootdir});
  566. my $certs = [read_certs($automator, $firstRev)];
  567. $automator->close();
  568. my $date;
  569. foreach my $cert (@$certs) {
  570. if ($cert->{signature} eq "ok" && $cert->{trust} eq "trusted") {
  571. if ($cert->{name} eq "date") {
  572. $date = $cert->{value};
  573. }
  574. }
  575. }
  576. if (! defined $date) {
  577. debug "failed to find date cert for revision $firstRev when looking for creation time of $file";
  578. return 0;
  579. }
  580. $date=str2time($date, 'UTC');
  581. debug("found ctime ".localtime($date)." for $file");
  582. return $date;
  583. }
  584. sub rcs_getmtime ($) {
  585. error "rcs_getmtime is not implemented for monotone\n"; # TODO
  586. }
  587. 1