| SVN-Web documentation | Contained in the SVN-Web distribution. |
SVN::Web::Checkout - SVN::Web action to checkout a given file
In config.yaml
actions:
...
checkout:
class: SVN::Web::Checkout
action_menu:
show:
- file
link_text: (checkout)
...
Returns the contents of the given filename. Uses the svn:mime-type
property.
The repository revision to checkout. Defaults to the repository's youngest revision.
N/A
The given path is not a file in the given revision.
Copyright 2003-2004 by Chia-liang Kao <clkao@clkao.org>.
Copyright 2005-2007 by Nik Clayton <nik@FreeBSD.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| SVN-Web documentation | Contained in the SVN-Web distribution. |
package SVN::Web::Checkout; use strict; use warnings; use base 'SVN::Web::action'; use SVN::Web::X; our $VERSION = 0.53;
sub run { my $self = shift; my $ctx = $self->{repos}{client}; my $ra = $self->{repos}{ra}; my $uri = $self->{repos}{uri}; my $rev = $self->{cgi}->param('rev') || $ra->get_latest_revnum(); my $path = $self->{path}; my $node_kind; $ctx->info("$uri$path", $rev, $rev, sub { $node_kind = $_[1]->kind(); }, 0); if($node_kind != $SVN::Node::file) { SVN::Web::X->throw( error => '(path %1 is not a file in revision %2)', vars => [$path, $rev] ); } my($fh, $fc) = (undef, ''); open($fh, '>', \$fc); $ctx->cat($fh, $uri . $path, $rev); close($fh); my $mime_type; my $props = $ctx->propget('svn:mime-type', $uri . $path, $rev, 0); if(exists $props->{$uri . $path}) { $mime_type = $props->{$uri . $path}; } else { $mime_type = 'text/plain'; } return { mimetype => $mime_type, body => $fc, }; } 1;